X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=include%2Fcallable.h;h=544b37115fb2cbe4b756ae1bb10f439812c76c8b;hb=0d52a8d02278592356f94ac17b1ccc5fcea388a5;hp=7e6e503c436e23f086306d7c0dd33f1267795eff;hpb=dd5fbed80e02dbb68a864fb59723dd106eebe14f;p=command.git diff --git a/include/callable.h b/include/callable.h index 7e6e503..544b371 100644 --- a/include/callable.h +++ b/include/callable.h @@ -24,6 +24,7 @@ namespace command { Callable(void (*function)(ArgumentType)) : func(function) { } + virtual ~Callable() { } protected: @@ -36,6 +37,38 @@ namespace command { 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 */