36#ifndef _OPENLCB_CALLBACKEVENTHANDLER_HXX_
37#define _OPENLCB_CALLBACKEVENTHANDLER_HXX_
157 this, entry_bits, 0xFFFFFFFFu);
240 event->event_write_helper<1>()->WriteAsync(
node_, mti,
252 event->event_write_helper<3>()->WriteAsync(
node_, mti,
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.
BarrierNotifiable * new_child()
Call this for each child task.
static EventRegistry * instance()
Event handler implementation class that calls a user-specified std::function callback every time an e...
std::function< EventState(const EventRegistryEntry ®istry_entry, EventReport *report)> EventStateHandlerFn
Function signature that returns the event state for the current registry entry.
void handle_consumer_identified(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Called on another node sending ConsumerIdentified for this event.
std::function< void(const EventRegistryEntry ®istry_entry, EventReport *report, BarrierNotifiable *done)> EventReportHandlerFn
This function (signature) is called every time a given event report arrives.
Node * node_
Node on which we are registered.
EventIdentifiedHandlerFn identifiedHandler_
Stores the user callback for P/C identified messages.
void send_consumer_identified(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done)
Helper function for implementations.
void remove_entry(uint32_t entry_bits)
Removes the registration of entries added before with a given user_arg value.
void handle_event_report(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Called on incoming EventReport messages.
void handle_producer_identified(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
Called on another node sending ProducerIdentified for this event.
void add_entry(EventId event, uint32_t entry_bits)
Registers this event handler for a given event ID in the global event service's registry.
EventStateHandlerFn stateHandler_
Stores the user callback for getting state for event identified responses.
void remove_all_entries()
Removes the registration of every single entry added so far.
void handle_identify_global(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) override
Called on the need of sending out identification messages.
@ IS_CONSUMER
Set this bit in the param entry_bits in order to mark the event as being consumed.
@ IS_PRODUCER
Set this bit in the param entry_bits in order to mark the event as being produced.
@ USER_BIT_MASK
This is the mask of bits that can be used by the caller for storing arbitrary information next to the...
void handle_identify_consumer(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) override
Called on another node sending IdentifyConsumer.
std::function< void(openlcb::Defs::MTI mti, const EventRegistryEntry ®istry_entry, EventReport *report, BarrierNotifiable *done)> EventIdentifiedHandlerFn
This function (signature) is called when a producer/consumer identified message arrives.
void send_producer_identified(const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done)
Helper function for implementations.
void handle_identify_producer(const EventRegistryEntry ®istry_entry, EventReport *event, BarrierNotifiable *done) override
Called on another node sending IdentifyProducer.
EventReportHandlerFn reportHandler_
Stores the user callback for event reports.
CallbackEventHandler(Node *node, EventReportHandlerFn report_handler, EventStateHandlerFn state_handler=nullptr, EventIdentifiedHandlerFn identified_handler=nullptr)
Constructor.
Structure used in registering event handlers.
uint32_t user_arg
Opaque user argument.
EventId event
Stores the event ID or beginning of range for which to register the given handler.
Base class for NMRAnet nodes conforming to the asynchronous interface.
SimpleEventHandler ignores all non-essential callbacks.
EventState
Allowed states of producers and consumers.
Payload eventid_to_buffer(uint64_t eventid)
Converts an Event ID to a Payload suitable to be sent as an event report.
MTI
Known Message type indicators.
@ MTI_CONSUMER_IDENTIFIED_UNKNOWN
consumer broadcast, validity unknown
@ MTI_PRODUCER_IDENTIFIED_VALID
producer broadcast, valid state
@ MTI_PRODUCER_IDENTIFIED_UNKNOWN
producer broadcast, validity unknown
@ MTI_CONSUMER_IDENTIFIED_VALID
consumer broadcast, valid state
Shared notification structure that is assembled for each incoming event-related message,...