BeeeOn Gateway
v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
|
EventSource implements common logic for firing events to listeners. More...
#include <EventSource.h>
Public Member Functions | |
void | setAsyncExecutor (AsyncExecutor::Ptr executor) |
AsyncExecutor::Ptr | asyncExecutor () const |
void | addListener (typename Listener::Ptr listener) |
void | clearListeners () |
template<typename Event , typename Method > | |
void | fireEvent (const Event &e, const Method &m) |
Additional Inherited Members | |
Protected Member Functions inherited from BeeeOn::Loggable | |
void | setupLogger (Poco::Logger *logger=0) const |
Poco::Logger & | logger () const |
Loggable (const ClassInfo &info) | |
Loggable (const std::type_info &info) | |
Static Protected Member Functions inherited from BeeeOn::Loggable | |
static Poco::Logger & | forMethod (const char *name) |
static Poco::Logger & | forClass (const ClassInfo &info) |
static Poco::Logger & | forClass (const std::type_info &info) |
template<typename T > | |
static Poco::Logger & | forInstance (const T *i) |
static void | configureSimple (Poco::Logger &logger, const std::string &level) |
static void | logException (Poco::Logger &logger, const Poco::Message::Priority priority, const Poco::Exception &e, const char *file, size_t line) |
EventSource implements common logic for firing events to listeners.
The EventSource can be inherited or used as member of another class (preferred) to provide common logic for firing events. It registers listeners and fires events via the provided AsyncExecutor.
void BeeeOn::EventSource< Listener >::fireEvent | ( | const Event & | e, |
const Method & | m | ||
) |
Fire the given instance of some event via the given method. The method argument should be pointer to some method of the Listener. Example:
class SomeListener { public: virtual void onSome(const SomeEvent &e) = 0; };
EventSource<SomeListener> source; source.addListener(...); source.setAsyncExecutor(...);
SomeEvent e = ....; source.fireEvent(e, &SomeListener::onSome);