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

Event producer for range of bits (event pairs) that is non-autoritative. More...

#include <NonAuthoritativeEventProducer.hxx>

Inheritance diagram for openlcb::BitRangeNonAuthoritativeEventP:
openlcb::SimpleEventHandler openlcb::EventHandler

Public Member Functions

 BitRangeNonAuthoritativeEventP (Node *node, uint64_t event_base, uint32_t size, std::function< void(unsigned, bool)> state_callback=nullptr)
 Constructor.
 
 BitRangeNonAuthoritativeEventP (Node *node, uint64_t event_base_on, uint64_t event_base_off, uint32_t size, std::function< void(unsigned, bool)> state_callback=nullptr)
 Constructor.
 
 ~BitRangeNonAuthoritativeEventP ()
 Destructor.
 
void send_query_consumer (unsigned bit, WriteHelper *writer, BarrierNotifiable *done)
 Queries consumer and acquires the current state of the bit.
 
void set (unsigned bit, bool new_value, WriteHelper *writer, BarrierNotifiable *done)
 Requests the event associated with the current value of the bit to be produced (unconditionally).
 
void handle_event_report (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Handle an incoming event.
 
void handle_consumer_identified (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Handle an incoming consumer identified message.
 
void handle_identify_global (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Handle an incoming identify global or addressed message.
 
void handle_identify_producer (const EventRegistryEntry &entry, EventReport *event, BarrierNotifiable *done) override
 Handle an incoming identify producer message.
 
- Public Member Functions inherited from openlcb::SimpleEventHandler
 IGNOREFN (handle_event_report)
 
 IGNOREFN (handle_consumer_identified)
 
 IGNOREFN (handle_consumer_range_identified)
 
 IGNOREFN (handle_producer_identified)
 
 IGNOREFN (handle_producer_range_identified)
 
 IGNOREFN (handle_identify_consumer)
 
 IGNOREFN (handle_identify_producer)
 
- Public Member Functions inherited from openlcb::EventHandler
virtual void handle_consumer_range_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ConsumerRangeIdentified.
 
virtual void handle_producer_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ProducerIdentified for this event.
 
virtual void handle_producer_range_identified (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)
 Called on another node sending ProducerRangeIdentified for this event.
 
virtual void handle_identify_consumer (const EventRegistryEntry &registry_entry, EventReport *event, BarrierNotifiable *done)=0
 Called on another node sending IdentifyConsumer.
 

Private Types

enum  EventBaseType : unsigned { EVENT_BASE = 1 , EVENT_BASE_ON , EVENT_BASE_OFF }
 Identifiers for the types of event range registration. More...
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (BitRangeNonAuthoritativeEventP)
 

Private Attributes

Nodenode_
 Node ID that this producer is attached to.
 
union { 
 
   uint64_t   eventBase_ 
 base event ID of the full range More...
 
   uint64_t   eventBaseOn_ 
 base event ID for "on" range More...
 
};  
 
uint64_t eventBaseOff_
 base event ID for "off" range
 
unsigned size_
 number of bits stored
 
std::function< void(unsigned, bool)> stateCallback_
 Callback method that will be invoked when a consumer identified message is received with a known state.
 

Additional Inherited Members

- Public Types inherited from openlcb::EventHandler
using EventReport = openlcb::EventReport
 
using EventRegistryEntry = openlcb::EventRegistryEntry
 
using EventId = openlcb::EventId
 

Detailed Description

Event producer for range of bits (event pairs) that is non-autoritative.

Definition at line 46 of file NonAuthoritativeEventProducer.hxx.

Member Enumeration Documentation

◆ EventBaseType

Identifiers for the types of event range registration.

Enumerator
EVENT_BASE_ON 

one unified range starting at eventBase_

EVENT_BASE_OFF 

on range starting at eventBaseOn_

Definition at line 171 of file NonAuthoritativeEventProducer.hxx.

Constructor & Destructor Documentation

◆ BitRangeNonAuthoritativeEventP() [1/2]

openlcb::BitRangeNonAuthoritativeEventP::BitRangeNonAuthoritativeEventP ( Node node,
uint64_t  event_base,
uint32_t  size,
std::function< void(unsigned, bool)>  state_callback = nullptr 
)
inline

Constructor.

Creates a new bit range producer.

Parameters
nodethe node that the producer will be bound to
event_basethe starting event ID for the event range
sizeThe total event range size in "pairs" of events. Each pair of sequential events represents a single "bit" with a binary state.
state_callbackCallback method for delivering the results of a consumer identified. The first unsigned parameter represents the bit offset for the range and the second bool parameter indicates the state as true for valid and false for invalid

Definition at line 61 of file NonAuthoritativeEventProducer.hxx.

◆ BitRangeNonAuthoritativeEventP() [2/2]

openlcb::BitRangeNonAuthoritativeEventP::BitRangeNonAuthoritativeEventP ( Node node,
uint64_t  event_base_on,
uint64_t  event_base_off,
uint32_t  size,
std::function< void(unsigned, bool)>  state_callback = nullptr 
)
inline

Constructor.

Creates a new bit range producer.

Parameters
nodethe node that the producer will be bound to
event_base_onthe starting event ID for the "on" event range
event_base_offthe starting event ID for the "off" event range
sizeThe total event range size in "pairs" of events. Each pair of sequential events represents a single "bit" with a binary state.
state_callbackCallback method for delivering the results of a consumer identified or event report. The first unsigned parameter represents the bit offset for the range and the second bool parameter indicates the state as true for valid and false for invalid.

Definition at line 88 of file NonAuthoritativeEventProducer.hxx.

◆ ~BitRangeNonAuthoritativeEventP()

openlcb::BitRangeNonAuthoritativeEventP::~BitRangeNonAuthoritativeEventP ( )
inline

Destructor.

Definition at line 109 of file NonAuthoritativeEventProducer.hxx.

Member Function Documentation

◆ handle_consumer_identified()

void openlcb::BitRangeNonAuthoritativeEventP::handle_consumer_identified ( const EventRegistryEntry entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Handle an incoming consumer identified message.

Parameters
entryreference to this entry in the event registry
eventevent metadata
donenotifible to wakup when finished with the report processing

Reimplemented from openlcb::EventHandler.

Definition at line 106 of file NonAuthoritativeEventProducer.cxx.

◆ handle_event_report()

void openlcb::BitRangeNonAuthoritativeEventP::handle_event_report ( const EventRegistryEntry entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Handle an incoming event.

Parameters
entryreference to this entry in the event registry
eventevent metadata
donenotifible to wakup when finished with the report processing

Implements openlcb::EventHandler.

Definition at line 61 of file NonAuthoritativeEventProducer.cxx.

◆ handle_identify_global()

void openlcb::BitRangeNonAuthoritativeEventP::handle_identify_global ( const EventRegistryEntry entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Handle an incoming identify global or addressed message.

Parameters
entryreference to this entry in the event registry
eventevent metadata
donenotifible to wakup when finished with the report processing

Implements openlcb::EventHandler.

Definition at line 168 of file NonAuthoritativeEventProducer.cxx.

◆ handle_identify_producer()

void openlcb::BitRangeNonAuthoritativeEventP::handle_identify_producer ( const EventRegistryEntry entry,
EventReport event,
BarrierNotifiable done 
)
overridevirtual

Handle an incoming identify producer message.

Parameters
entryreference to this entry in the event registry
eventevent metadata
donenotifible to wakup when finished with the report processing

Implements openlcb::EventHandler.

Definition at line 204 of file NonAuthoritativeEventProducer.cxx.

◆ send_query_consumer()

void openlcb::BitRangeNonAuthoritativeEventP::send_query_consumer ( unsigned  bit,
WriteHelper writer,
BarrierNotifiable done 
)

Queries consumer and acquires the current state of the bit.

Parameters
bitbit pair offset from the base event ID of the range, (0 <= bit < size)
writerobject that will assist in the write transaction
donenotifible to wakup when finished

Definition at line 46 of file NonAuthoritativeEventProducer.cxx.

◆ set()

void openlcb::BitRangeNonAuthoritativeEventP::set ( unsigned  bit,
bool  new_value,
WriteHelper writer,
BarrierNotifiable done 
)

Requests the event associated with the current value of the bit to be produced (unconditionally).

Parameters
bitis the offset of the bit to set (0 <= bit < size)
new_valueis the new value of the bit
writeris the output flow to be used
donenotifible to wakup when query is sent on the bus

Definition at line 253 of file NonAuthoritativeEventProducer.cxx.

Member Data Documentation

◆ eventBase_

uint64_t openlcb::BitRangeNonAuthoritativeEventP::eventBase_

base event ID of the full range

Definition at line 182 of file NonAuthoritativeEventProducer.hxx.

◆ eventBaseOff_

uint64_t openlcb::BitRangeNonAuthoritativeEventP::eventBaseOff_
private

base event ID for "off" range

Definition at line 185 of file NonAuthoritativeEventProducer.hxx.

◆ eventBaseOn_

uint64_t openlcb::BitRangeNonAuthoritativeEventP::eventBaseOn_

base event ID for "on" range

Definition at line 183 of file NonAuthoritativeEventProducer.hxx.

◆ node_

Node* openlcb::BitRangeNonAuthoritativeEventP::node_
private

Node ID that this producer is attached to.

Definition at line 179 of file NonAuthoritativeEventProducer.hxx.

◆ size_

unsigned openlcb::BitRangeNonAuthoritativeEventP::size_
private

number of bits stored

Definition at line 186 of file NonAuthoritativeEventProducer.hxx.

◆ stateCallback_

std::function<void(unsigned, bool)> openlcb::BitRangeNonAuthoritativeEventP::stateCallback_
private

Callback method that will be invoked when a consumer identified message is received with a known state.

Definition at line 190 of file NonAuthoritativeEventProducer.hxx.


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