Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::MemoryBit< T > Class Template Reference

Simple implementation of a BitEventInterface when the true state ofthe variable is mapped in memory (e.g. More...

#include <EventHandlerTemplates.hxx>

Inheritance diagram for openlcb::MemoryBit< T >:
openlcb::BitEventInterface

Public Member Functions

 MemoryBit (Node *node, uint64_t event_on, uint64_t event_off, T *ptr, T mask)
 
Nodenode () override
 returns the OpenLCB virtual node from which to send the respective events when the bit changes.
 
EventState get_current_state () override
 returns the current hardware state: true for ON, false for OFF.
 
void set_state (bool new_value) override
 Updates the hardware for the new event state.
 
- Public Member Functions inherited from openlcb::BitEventInterface
 BitEventInterface (uint64_t event_on, uint64_t event_off)
 
virtual EventState get_requested_state ()
 Get the requested state.
 
uint64_t event_on ()
 returns the event ID for representing the state transition OFF->ON.
 
uint64_t event_off ()
 returns the event ID for representing the state transition ON->OFF.
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (MemoryBit)
 

Private Attributes

Nodenode_
 
T * ptr_
 
mask_
 

Detailed Description

template<class T>
class openlcb::MemoryBit< T >

Simple implementation of a BitEventInterface when the true state ofthe variable is mapped in memory (e.g.

mmap-ed gpio, or if there is no real hardware but a bit in RAM).

The template argument is the C++ type of the raw pointer, usually uint32_t or uint8_t.

Definition at line 447 of file EventHandlerTemplates.hxx.

Constructor & Destructor Documentation

◆ MemoryBit()

template<class T >
openlcb::MemoryBit< T >::MemoryBit ( Node node,
uint64_t  event_on,
uint64_t  event_off,
T *  ptr,
mask 
)
inline
Parameters
ptrdefines the memory address of the bit where the hardware state is located in the address space.
maskdefines which bit at that address. If there are multiple bits set in mask, they will all be set/cleared for output purposes, and if any of them is set, the input will be considered on.

Definition at line 456 of file EventHandlerTemplates.hxx.

Member Function Documentation

◆ get_current_state()

template<class T >
EventState openlcb::MemoryBit< T >::get_current_state ( )
inlineoverridevirtual

returns the current hardware state: true for ON, false for OFF.

Implements openlcb::BitEventInterface.

Definition at line 468 of file EventHandlerTemplates.hxx.

◆ node()

template<class T >
Node * openlcb::MemoryBit< T >::node ( )
inlineoverridevirtual

returns the OpenLCB virtual node from which to send the respective events when the bit changes.

Implements openlcb::BitEventInterface.

Definition at line 464 of file EventHandlerTemplates.hxx.

◆ set_state()

template<class T >
void openlcb::MemoryBit< T >::set_state ( bool  new_value)
inlineoverridevirtual

Updates the hardware for the new event state.

Parameters
new_valueis true for state ON, false for state OFF.

Implements openlcb::BitEventInterface.

Definition at line 472 of file EventHandlerTemplates.hxx.

Member Data Documentation

◆ mask_

template<class T >
T openlcb::MemoryBit< T >::mask_
private

Definition at line 487 of file EventHandlerTemplates.hxx.

◆ node_

template<class T >
Node* openlcb::MemoryBit< T >::node_
private

Definition at line 485 of file EventHandlerTemplates.hxx.

◆ ptr_

template<class T >
T* openlcb::MemoryBit< T >::ptr_
private

Definition at line 486 of file EventHandlerTemplates.hxx.


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