X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=include%2Fcallable.h;h=4ac1bd97635e43d8b9956b35857155e59ba0ec1e;hb=a62cd661611b4c90b5ebe70f6f466f04a7f98684;hp=7e6e503c436e23f086306d7c0dd33f1267795eff;hpb=dd5fbed80e02dbb68a864fb59723dd106eebe14f;p=command.git diff --git a/include/callable.h b/include/callable.h index 7e6e503..4ac1bd9 100644 --- a/include/callable.h +++ b/include/callable.h @@ -7,13 +7,13 @@ namespace command { /** * Callable behaviour class. */ - template + template class Callable { protected: /** * Function handling user Arguments */ - void (*func)(ArgumentType); + void (*func)(ParameterType); public: /** @@ -21,9 +21,10 @@ namespace command { * * @param function Function that will be invoked */ - Callable(void (*function)(ArgumentType)) + Callable(void (*function)(ParameterType)) : func(function) { } + virtual ~Callable() { } protected: @@ -32,10 +33,42 @@ namespace command { * * @param value Value passed to program argument */ - void call(ArgumentType value) { + void call(ParameterType value) { this->func(value); } }; + + /** + * Template specialization of Callable behaviour class. + * Allows passing functions with void argument + */ + template<> + class Callable { + protected: + /** + * Function handling user Arguments + */ + void (*func)(void); + + public: + /** + * Default constructor. + * + * @param function Function that will be invoked + */ + Callable(void (*function)(void)) + : func(function) { + } + virtual ~Callable() { } + + protected: + /** + * Executes command + */ + void call() { + this->func(); + } + }; } #endif /* __COMMAND_DESCRIPTIVE_H */