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

OpenLCB implementation of a binary network state. More...

#include <NetworkState.hxx>

Inheritance diagram for openlcb::NetworkState:
NetworkState

Public Member Functions

 NetworkState (Node *node, WriteHelper *write_helper, uint64_t event_on, uint64_t event_off)
 Constructor.
 
- Public Member Functions inherited from NetworkState
virtual ~NetworkState ()
 Destructor.
 

Private Member Functions

void set_callback (std::function< void()> cb) override
 Set the change notification callback.
 
void toggle (Notifiable *done) override
 Toggle the state.
 
void set_state (bool state, Notifiable *done) override
 Set the state.
 
State get_state () override
 Get the current state.
 
bool is_state_known () override
 Get an indication as to if the state is known.
 
void initiate_query (BarrierNotifiable *done) override
 Queries and acquires the current state of the bit.
 
void reset () override
 Reset the network state to unknown.
 

Private Attributes

WriteHelperwriteHelper_
 helper for generating events
 
CallbackNetworkInitializedBit bit_
 bit (dual event) container
 
BitEventPC bitPC_
 bit event producer/consumer
 

Additional Inherited Members

- Public Types inherited from NetworkState
enum  State { VALID = 0 , INVALID = 1 , UNKNOWN = 3 }
 

Detailed Description

OpenLCB implementation of a binary network state.

Definition at line 36 of file openlcb/NetworkState.hxx.

Constructor & Destructor Documentation

◆ NetworkState()

openlcb::NetworkState::NetworkState ( Node node,
WriteHelper write_helper,
uint64_t  event_on,
uint64_t  event_off 
)
inline

Constructor.

Parameters
nodethe virtual node who exposes this bit.
write_helperhelper for generating events
event_onevent ID to set the state to true
event_offevent ID to set the state to false

Definition at line 44 of file openlcb/NetworkState.hxx.

Member Function Documentation

◆ get_state()

State openlcb::NetworkState::get_state ( )
inlineoverrideprivatevirtual

Get the current state.

Returns
VALID, INVALID, or UNKNOWN

Implements NetworkState.

Definition at line 82 of file openlcb/NetworkState.hxx.

◆ initiate_query()

void openlcb::NetworkState::initiate_query ( BarrierNotifiable done)
inlineoverrideprivatevirtual

Queries and acquires the current state of the bit.

Parameters
doneis the notification callback. If it is NULL, the writer will be invoked inline and potentially block the calling thread.

Implements NetworkState.

Definition at line 105 of file openlcb/NetworkState.hxx.

◆ is_state_known()

bool openlcb::NetworkState::is_state_known ( )
inlineoverrideprivatevirtual

Get an indication as to if the state is known.

Returns
true if known, else false

Implements NetworkState.

Definition at line 97 of file openlcb/NetworkState.hxx.

◆ reset()

void openlcb::NetworkState::reset ( )
inlineoverrideprivatevirtual

Reset the network state to unknown.

Implements NetworkState.

Definition at line 111 of file openlcb/NetworkState.hxx.

◆ set_callback()

void openlcb::NetworkState::set_callback ( std::function< void()>  cb)
inlineoverrideprivatevirtual

Set the change notification callback.

Parameters
cbwill be involked every time the state is changed (both from local calls as well as from the network stack)

Implements NetworkState.

Definition at line 56 of file openlcb/NetworkState.hxx.

◆ set_state()

void openlcb::NetworkState::set_state ( bool  state,
Notifiable done 
)
inlineoverrideprivatevirtual

Set the state.

Parameters
statenew state value
doneis the notification callback. If it is NULL, the writer will be invoked inline and potentially block the calling thread.

Implements NetworkState.

Definition at line 74 of file openlcb/NetworkState.hxx.

◆ toggle()

void openlcb::NetworkState::toggle ( Notifiable done)
inlineoverrideprivatevirtual

Toggle the state.

Parameters
doneis the notification callback. If it is NULL, the writer will be invoked inline and potentially block the calling thread.

Implements NetworkState.

Definition at line 64 of file openlcb/NetworkState.hxx.

Member Data Documentation

◆ bit_

CallbackNetworkInitializedBit openlcb::NetworkState::bit_
private

bit (dual event) container

Definition at line 120 of file openlcb/NetworkState.hxx.

◆ bitPC_

BitEventPC openlcb::NetworkState::bitPC_
private

bit event producer/consumer

Definition at line 123 of file openlcb/NetworkState.hxx.

◆ writeHelper_

WriteHelper* openlcb::NetworkState::writeHelper_
private

helper for generating events

Definition at line 117 of file openlcb/NetworkState.hxx.


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