|
Open Model Railroad Network (OpenMRN)
|
Global static object for registering event handlers. More...
#include <EventHandler.hxx>
Public Member Functions | |
| virtual void | register_handler (const EventRegistryEntry &entry, unsigned mask)=0 |
| Adds a new event handler to the registry. | |
| virtual void | unregister_handler (EventHandler *handler, uint32_t user_arg=0, uint32_t user_arg_mask=0)=0 |
| Removes all registered instances of a given event handler pointer. | |
| virtual void | reserve (size_t count) |
| Prepares storage for adding many event handlers. | |
| virtual EventIterator * | create_iterator ()=0 |
| Creates a new event iterator. Caller takes ownership of object. | |
| unsigned | get_epoch () |
| Returns a monotonically increasing number that will change every time the set of registered event handlers change. | |
Static Public Member Functions | |
| static unsigned | align_mask (EventId *event, unsigned size) |
| Computes the alignment mask for registering an event range. | |
Static Public Member Functions inherited from Singleton< EventRegistry > | |
| static EventRegistry * | instance () |
| static bool | exists () |
Protected Member Functions | |
| void | set_dirty () |
| Implementations must call this function from register and unregister handler to mark iterators being invalidated. | |
Private Member Functions | |
| DISALLOW_COPY_AND_ASSIGN (EventRegistry) | |
Private Attributes | |
| unsigned | dirtyCounter_ = 0 |
| This counter will be incremented every time the set of event handlers change (and thus the event iterators are invalidated). | |
Static Private Attributes | |
| static EventRegistry * | instance_ |
Global static object for registering event handlers.
Usage: create one of the implementation classes depending on the resource requirements of your binary. In the event handlers constructor, register the event handler via the singleton pointer.
Definition at line 253 of file EventHandler.hxx.
|
virtual |
Definition at line 44 of file EventHandler.cxx.
|
protected |
Definition at line 40 of file EventHandler.cxx.
|
static |
Computes the alignment mask for registering an event range.
Updates the event by rounding and returns the mask value to be sent to the register_handler function.
| event | is the event id to be registered. Will be modified. |
| size | is the number of events to register from that offset. [event, event+size) will be the registration range. |
Definition at line 49 of file EventHandler.cxx.
|
pure virtual |
Creates a new event iterator. Caller takes ownership of object.
Implemented in openlcb::VectorEventHandlers, and openlcb::TreeEventHandlers.
|
inline |
Returns a monotonically increasing number that will change every time the set of registered event handlers change.
Whenever this number changes, the iterators are invalidated and must be cleared.
Definition at line 293 of file EventHandler.hxx.
|
pure virtual |
Adds a new event handler to the registry.
| entry | is the structure parametrizingthe registration. |
| mask | is used for registering consecutive events; zero for registering just one event; otherwise use {align_mask} to compute the base value and mask to use for registering a range of events. |
Implemented in openlcb::VectorEventHandlers, and openlcb::TreeEventHandlers.
|
inlinevirtual |
Prepares storage for adding many event handlers.
| count | how many empty slots to reserve. |
Reimplemented in openlcb::TreeEventHandlers.
Definition at line 283 of file EventHandler.hxx.
|
inlineprotected |
Implementations must call this function from register and unregister handler to mark iterators being invalidated.
Definition at line 303 of file EventHandler.hxx.
|
pure virtual |
Removes all registered instances of a given event handler pointer.
| handler | the handler for which to unregister entries |
| user_arg | values of the 32-bit user arg to remove |
| user_arg_mask | 32-bit mask where to verify user_arg being equal |
Implemented in openlcb::VectorEventHandlers, and openlcb::TreeEventHandlers.
|
private |
This counter will be incremented every time the set of event handlers change (and thus the event iterators are invalidated).
Definition at line 313 of file EventHandler.hxx.
|
staticprivate |
Definition at line 309 of file EventHandler.hxx.