Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::VectorEventHandlers Class Reference

EventRegistry implementation that keeps all event handlers in a vector and forwards every single call to each event handler. More...

#include <EventHandlerContainer.hxx>

Inheritance diagram for openlcb::VectorEventHandlers:
openlcb::EventRegistry Atomic Singleton< EventRegistry >

Public Member Functions

EventIteratorcreate_iterator () OVERRIDE
 Creates a new event iterator. Caller takes ownership of object.
 
void register_handler (const EventRegistryEntry &entry, unsigned mask) OVERRIDE
 Adds a new event handler to the registry.
 
void unregister_handler (EventHandler *handler, uint32_t user_arg=0, uint32_t user_arg_mask=0) OVERRIDE
 Removes all registered instances of a given event handler pointer.
 
- Public Member Functions inherited from openlcb::EventRegistry
virtual void reserve (size_t count)
 Prepares storage for adding many event handlers.
 
unsigned get_epoch ()
 Returns a monotonically increasing number that will change every time the set of registered event handlers change.
 

Private Types

typedef std::forward_list< EventRegistryEntryHandlersList
 

Private Attributes

HandlersList handlers_
 

Additional Inherited Members

- Static Public Member Functions inherited from openlcb::EventRegistry
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 inherited from openlcb::EventRegistry
void set_dirty ()
 Implementations must call this function from register and unregister handler to mark iterators being invalidated.
 
- Private Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 

Detailed Description

EventRegistry implementation that keeps all event handlers in a vector and forwards every single call to each event handler.

Definition at line 113 of file EventHandlerContainer.hxx.

Member Typedef Documentation

◆ HandlersList

typedef std::forward_list<EventRegistryEntry> openlcb::VectorEventHandlers::HandlersList
private

Definition at line 143 of file EventHandlerContainer.hxx.

Constructor & Destructor Documentation

◆ VectorEventHandlers()

openlcb::VectorEventHandlers::VectorEventHandlers ( )
inline

Definition at line 116 of file EventHandlerContainer.hxx.

Member Function Documentation

◆ create_iterator()

EventIterator * openlcb::VectorEventHandlers::create_iterator ( )
inlinevirtual

Creates a new event iterator. Caller takes ownership of object.

Implements openlcb::EventRegistry.

Definition at line 119 of file EventHandlerContainer.hxx.

◆ register_handler()

void openlcb::VectorEventHandlers::register_handler ( const EventRegistryEntry entry,
unsigned  mask 
)
inlinevirtual

Adds a new event handler to the registry.

Parameters
entryis the structure parametrizingthe registration.
maskis 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.

Implements openlcb::EventRegistry.

Definition at line 123 of file EventHandlerContainer.hxx.

◆ unregister_handler()

void openlcb::VectorEventHandlers::unregister_handler ( EventHandler handler,
uint32_t  user_arg = 0,
uint32_t  user_arg_mask = 0 
)
inlinevirtual

Removes all registered instances of a given event handler pointer.

Parameters
handlerthe handler for which to unregister entries
user_argvalues of the 32-bit user arg to remove
user_arg_mask32-bit mask where to verify user_arg being equal

Implements openlcb::EventRegistry.

Definition at line 130 of file EventHandlerContainer.hxx.

Member Data Documentation

◆ handlers_

HandlersList openlcb::VectorEventHandlers::handlers_
private

Definition at line 144 of file EventHandlerContainer.hxx.


The documentation for this class was generated from the following file: