Possibility to pass class method reference
[command.git] / tests / callable / TestCallable.h
1 #include "callable.h"
2
3 using namespace command;
4
5 template<typename ArgumentType>
6 class TestCallable : public Callable<ArgumentType> {
7 public:
8     TestCallable(void (*function)(ArgumentType))
9         : Callable<ArgumentType>(function) {
10     }
11
12     TestCallable(std::function<void(ArgumentType)> function)
13         : Callable<ArgumentType>(function) {
14     }
15
16     void callFunction(ArgumentType test) {
17         this->call(test);
18     }
19 };
20
21 template<>
22 class TestCallable<void> : public Callable<void> {
23 public:
24     TestCallable(void (*function)(void))
25         : Callable<void>(function) {
26     }
27
28     TestCallable(std::function<void(void)> function)
29         : Callable<void>(function) {
30     }
31
32     void callFunction() {
33         this->call();
34     }
35 };