#include <senf/PPI/Events.hh>
EventImplementation provides the base-class for all Event implementations.
class SomeEvent : public EventImplementation<SomeEventArg> { public: SomeEvent() {} private: virtual void v_enable() { // register cb() to be called when the event occurs } virtual void v_disable() { // unregister cb() } void cb() { // Build event argument SomeEventArg arg (...); // Call the event callback callback(arg); } };
Every event needs to implement v_enable() and v_disable(). v_enable() should register some member (in the example cb()
) to be called whenever the event occurs, while v_disable() should unregister it.
The EventType argument to EventImplementation defines the type of argument passed to the user callback. It defaults to void
. . This user callback is called from within the registered member (e.g. cb()
) by calling the inherited callback() member. This member takes an EventType reference as argument which will be forwarded to the user callback. If available, you should also provide the expected event time as a second argument.
Definition at line 178 of file Events.hh.
Public Types |
|
typedef EventType | Event |
typedef detail::EventArgType < EventType >::type |
EventArg |
Public Member Functions |
|
module::Module & | module () const |
Module in which the event is registered. |
|
EventManager & | manager () const |
EventManager of the event. |
|
Protected Member Functions |
|
EventImplementation () |
typedef EventType senf::ppi::EventImplementation< EventType >:: | ||||
Event | ||||
typedef detail::EventArgType<EventType>::type senf::ppi::EventImplementation< EventType >:: | ||||
EventArg | ||||
senf::ppi::EventImplementation< EventType >:: | ||||
EventImplementation | () | |||
Definition at line 119 of file Events.cti.
senf::ppi::EventManager & senf::ppi::EventImplementation< EventType >:: | ||||
manager | () | |||
EventManager of the event.
Definition at line 109 of file Events.cti.
senf::ppi::module::Module & senf::ppi::EventImplementation< EventType >:: | ||||
module | () | |||
Module in which the event is registered.
Definition at line 102 of file Events.cti.