|
@@ -23,6 +23,10 @@
|
|
|
#include "pset.h"
|
|
#include "pset.h"
|
|
|
#include "pmap.h"
|
|
#include "pmap.h"
|
|
|
|
|
|
|
|
|
|
+#ifndef CPPPARSER
|
|
|
|
|
+#include <functional>
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
class EventQueue;
|
|
class EventQueue;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -40,6 +44,12 @@ public:
|
|
|
typedef void EventFunction(const Event *);
|
|
typedef void EventFunction(const Event *);
|
|
|
typedef void EventCallbackFunction(const Event *, void *);
|
|
typedef void EventCallbackFunction(const Event *, void *);
|
|
|
|
|
|
|
|
|
|
+#ifdef CPPPARSER
|
|
|
|
|
+ typedef EventFunction EventLambda;
|
|
|
|
|
+#else
|
|
|
|
|
+ typedef std::function<void (const Event *)> EventLambda;
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
PUBLISHED:
|
|
PUBLISHED:
|
|
|
explicit EventHandler(EventQueue *ev_queue);
|
|
explicit EventHandler(EventQueue *ev_queue);
|
|
|
~EventHandler() {}
|
|
~EventHandler() {}
|
|
@@ -58,6 +68,7 @@ public:
|
|
|
bool add_hook(const std::string &event_name, EventFunction *function);
|
|
bool add_hook(const std::string &event_name, EventFunction *function);
|
|
|
bool add_hook(const std::string &event_name, EventCallbackFunction *function,
|
|
bool add_hook(const std::string &event_name, EventCallbackFunction *function,
|
|
|
void *data);
|
|
void *data);
|
|
|
|
|
+ void add_hook(const std::string &event_name, EventLambda function);
|
|
|
bool has_hook(const std::string &event_name) const;
|
|
bool has_hook(const std::string &event_name) const;
|
|
|
bool has_hook(const std::string &event_name, EventFunction *function) const;
|
|
bool has_hook(const std::string &event_name, EventFunction *function) const;
|
|
|
bool has_hook(const std::string &event_name, EventCallbackFunction *function,
|
|
bool has_hook(const std::string &event_name, EventCallbackFunction *function,
|
|
@@ -78,10 +89,13 @@ protected:
|
|
|
typedef std::pair<EventCallbackFunction*, void*> CallbackFunction;
|
|
typedef std::pair<EventCallbackFunction*, void*> CallbackFunction;
|
|
|
typedef pset<CallbackFunction> CallbackFunctions;
|
|
typedef pset<CallbackFunction> CallbackFunctions;
|
|
|
typedef pmap<std::string, CallbackFunctions> CallbackHooks;
|
|
typedef pmap<std::string, CallbackFunctions> CallbackHooks;
|
|
|
|
|
+ typedef pvector<EventLambda> LambdaFunctions;
|
|
|
|
|
+ typedef pmap<std::string, LambdaFunctions> LambdaHooks;
|
|
|
typedef pmap<std::string, PT(AsyncFuture)> Futures;
|
|
typedef pmap<std::string, PT(AsyncFuture)> Futures;
|
|
|
|
|
|
|
|
Hooks _hooks;
|
|
Hooks _hooks;
|
|
|
CallbackHooks _cbhooks;
|
|
CallbackHooks _cbhooks;
|
|
|
|
|
+ LambdaHooks _lambdahooks;
|
|
|
Futures _futures;
|
|
Futures _futures;
|
|
|
EventQueue &_queue;
|
|
EventQueue &_queue;
|
|
|
|
|
|