7e6e503c436e23f086306d7c0dd33f1267795eff
[command.git] / include / callable.h
1 #ifndef __COMMAND_CALLABLE_H
2 #define __COMMAND_CALLABLE_H
3
4 #include <string>
5
6 namespace command {
7     /**
8      * Callable behaviour class.
9      */
10     template<typename ArgumentType>
11     class Callable {
12     protected:
13         /**
14          * Function handling user Arguments
15          */
16         void (*func)(ArgumentType);
17
18     public:
19         /**
20          * Default constructor.
21          *
22          * @param function Function that will be invoked
23          */
24         Callable(void (*function)(ArgumentType))
25             : func(function) {
26         }
27         virtual ~Callable() { }
28
29     protected:
30         /**
31          * Executes command binded with argument
32          *
33          * @param value Value passed to program argument
34          */
35         void call(ArgumentType value) {
36             this->func(value);
37         }
38     };
39 }
40
41 #endif /* __COMMAND_DESCRIPTIVE_H */