dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
command.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Possibility to pass class method reference
[command.git]
/
include
/
callable.h
diff --git
a/include/callable.h
b/include/callable.h
index 4ac1bd97635e43d8b9956b35857155e59ba0ec1e..f4d9e084cabe385dfcee6cfbfb0adcf87016e551 100644
(file)
--- a/
include/callable.h
+++ b/
include/callable.h
@@
-2,6
+2,7
@@
#define __COMMAND_CALLABLE_H
#include <string>
#define __COMMAND_CALLABLE_H
#include <string>
+#include <functional>
namespace command {
/**
namespace command {
/**
@@
-13,7
+14,8
@@
namespace command {
/**
* Function handling user Arguments
*/
/**
* Function handling user Arguments
*/
- void (*func)(ParameterType);
+// void (*func)(ParameterType);
+ std::function<void(ParameterType)> func;
public:
/**
public:
/**
@@
-21,7
+23,11
@@
namespace command {
*
* @param function Function that will be invoked
*/
*
* @param function Function that will be invoked
*/
- Callable(void (*function)(ParameterType))
+// Callable(void (*function)(ParameterType))
+// : func(function) {
+// }
+
+ Callable(std::function<void(ParameterType)> function)
: func(function) {
}
: func(function) {
}
@@
-48,7
+54,8
@@
namespace command {
/**
* Function handling user Arguments
*/
/**
* Function handling user Arguments
*/
- void (*func)(void);
+// void (*func)(void);
+ std::function<void(void)> func;
public:
/**
public:
/**
@@
-56,9
+63,14
@@
namespace command {
*
* @param function Function that will be invoked
*/
*
* @param function Function that will be invoked
*/
- Callable(void (*function)(void))
+// Callable(void (*function)(void))
+// : func(function) {
+// }
+
+ Callable(std::function<void(void)> function)
: func(function) {
}
: func(function) {
}
+
virtual ~Callable() { }
protected:
virtual ~Callable() { }
protected: