|
|
@@ -6,7 +6,7 @@ |
|
|
|
#define ctx_HEADER |
|
|
|
|
|
|
|
template <class T> class ctx_Controller { |
|
|
|
std::list<std::function<T(T)> > callbacks; |
|
|
|
std::list<std::function<void(T)> > callbacks; |
|
|
|
std::list<std::function<T(T)> > functions; |
|
|
|
std::queue<T> queue; |
|
|
|
|
|
|
@@ -49,12 +49,14 @@ template <class T> class ctx_Controller { |
|
|
|
functions.push_back(f); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
void registerCallback(void (*cb)(T)) { |
|
|
|
void registerCallback(std::function<void(T)> cb) { |
|
|
|
callbacks.push_back(cb); |
|
|
|
} |
|
|
|
|
|
|
|
void registerFieldCallback(const std::string &fieldName, void (*cb)(T)) { |
|
|
|
void registerFieldCallback( |
|
|
|
const std::string &fieldName, |
|
|
|
std::function<void(T)> cb |
|
|
|
) { |
|
|
|
auto execCB = [fieldName, cb](T c) { |
|
|
|
if (c.recentField == fieldName) { |
|
|
|
cb(c); |
|
|
@@ -63,6 +65,7 @@ template <class T> class ctx_Controller { |
|
|
|
callbacks.push_back(execCB); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
void registerFunctions(const std::list<T *(T)> funcs) { |
|
|
|
for (const auto &f : funcs) { |
|
|
|
functions.push_back(f); |
|
|
|