34#ifndef _OPENLCB_EVENTHANDLER_HXX_
35#define _OPENLCB_EVENTHANDLER_HXX_
48typedef uint64_t EventId;
90 static_assert(1 <= N && N <= 4,
"WriteHelper out of range.");
106 friend class DecoderRangeTest;
147 using EventId = openlcb::EventId;
265 static unsigned align_mask(EventId *event,
unsigned size);
279 uint32_t user_arg = 0, uint32_t user_arg_mask = 0) = 0;
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
void notify() override
Implementation of the barrier semantics.
Abstract base class for all event handlers.
virtual void handle_identify_global(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)=0
Called on the need of sending out identification messages.
virtual void handle_consumer_range_identified(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)
Called on another node sending ConsumerRangeIdentified.
virtual void handle_producer_range_identified(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)
Called on another node sending ProducerRangeIdentified for this event.
virtual void handle_event_report(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)=0
Called on incoming EventReport messages.
virtual void handle_identify_consumer(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)=0
Called on another node sending IdentifyConsumer.
virtual void handle_producer_identified(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)
Called on another node sending ProducerIdentified for this event.
virtual void handle_consumer_identified(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)
Called on another node sending ConsumerIdentified for this event.
virtual void handle_identify_producer(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done)=0
Called on another node sending IdentifyProducer.
Flow to receive incoming messages of event protocol, and dispatch them to the registered event handle...
Abstract class for representing iteration through a container for event handlers.
Structure used in registering event handlers.
EventHandler * handler
Pointer to the handler.
uint32_t user_arg
Opaque user argument.
EventId event
Stores the event ID or beginning of range for which to register the given handler.
Global static object for registering event handlers.
static unsigned align_mask(EventId *event, unsigned size)
Computes the alignment mask for registering an event range.
virtual void register_handler(const EventRegistryEntry &entry, unsigned mask)=0
Adds a new event handler to the registry.
unsigned dirtyCounter_
This counter will be incremented every time the set of event handlers change (and thus the event iter...
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.
unsigned get_epoch()
Returns a monotonically increasing number that will change every time the set of registered event han...
void set_dirty()
Implementations must call this function from register and unregister handler to mark iterators being ...
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.
Base class for NMRAnet nodes conforming to the asynchronous interface.
A statically allocated buffer for sending one message to the OpenLCB bus.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
EventState
Allowed states of producers and consumers.
Shared notification structure that is assembled for each incoming event-related message,...
EventId mask
Specifies the mask in case the request is for an event range.
WriteHelper write_helpers[4]
Static objects usable by all event handler implementations.
EventState state
For producer/consumer identified messages, specifies the state of the producer/consumer as the sender...
EventReport()
Constrained access to the constructors.
NodeHandle src_node
Information about the sender of the incoming event-related OpenLCB message.
EventId event
The event ID from the incoming message.
Node * dst_node
nullptr for global messages; points to the specific virtual node for addressed events identify messag...
EventReport(TestingEnum)
Public constructor for use in tests only.
WriteHelper * event_write_helper()
These allow event handlers to produce up to four messages per invocation.
Container of both a NodeID and NodeAlias.