X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;ds=sidebyside;f=include%2Fcallable.h;h=f4d9e084cabe385dfcee6cfbfb0adcf87016e551;hb=ae6743a2a2c69b7a927f64ff1d3abf38a5e7d4bc;hp=544b37115fb2cbe4b756ae1bb10f439812c76c8b;hpb=9bc6a44ad1a07a6420ce4fd75dfea0796bcd0d46;p=command.git diff --git a/include/callable.h b/include/callable.h index 544b371..f4d9e08 100644 --- a/include/callable.h +++ b/include/callable.h @@ -2,18 +2,20 @@ #define __COMMAND_CALLABLE_H #include +#include namespace command { /** * Callable behaviour class. */ - template + template class Callable { protected: /** * Function handling user Arguments */ - void (*func)(ArgumentType); +// void (*func)(ParameterType); + std::function func; public: /** @@ -21,7 +23,11 @@ namespace command { * * @param function Function that will be invoked */ - Callable(void (*function)(ArgumentType)) +// Callable(void (*function)(ParameterType)) +// : func(function) { +// } + + Callable(std::function function) : func(function) { } @@ -33,7 +39,7 @@ namespace command { * * @param value Value passed to program argument */ - void call(ArgumentType value) { + void call(ParameterType value) { this->func(value); } }; @@ -48,7 +54,8 @@ namespace command { /** * Function handling user Arguments */ - void (*func)(void); +// void (*func)(void); + std::function func; public: /** @@ -56,9 +63,14 @@ namespace command { * * @param function Function that will be invoked */ - Callable(void (*function)(void)) +// Callable(void (*function)(void)) +// : func(function) { +// } + + Callable(std::function function) : func(function) { } + virtual ~Callable() { } protected: