Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::MemoryConfigClient Class Reference
Inheritance diagram for openlcb::MemoryConfigClient:
CallableFlow< MemoryConfigClientRequest > StateFlow< MessageType, QueueType > TypedStateFlow< MessageType, UntypedStateFlow< QueueType > > UntypedStateFlow< QueueType > FlowInterface< MessageType > StateFlowWithQueue StateFlowBase Atomic LinkedObject< StateFlowWithQueue > Executable Notifiable QMember Destructable openlcb::MemoryConfigClientWithStream

Classes

class  ResponseFlow
 

Public Types

enum  ResultCodes { OPERATION_PENDING , TIMEOUT }
 These result codes are written into request()->resultCode during and as a return from the flow. More...
 
- Public Types inherited from TypedStateFlow< MessageType, UntypedStateFlow< QueueType > >
typedef Base::Action Action
 Allows using Action without having StateFlowBase:: prefix in front of it.
 
- Public Types inherited from FlowInterface< MessageType >
typedef MessageType message_type
 Stores the message template type for external reference.
 

Public Member Functions

 MemoryConfigClient (Node *node, MemoryConfigHandler *memcfg)
 
Nodenode ()
 
MemoryConfigHandlermem_cfg ()
 
- Public Member Functions inherited from CallableFlow< MemoryConfigClientRequest >
 CallableFlow (Service *s)
 Creates a callable flow.
 
- Public Member Functions inherited from StateFlow< MessageType, QueueType >
 StateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from TypedStateFlow< MessageType, UntypedStateFlow< QueueType > >
 TypedStateFlow (Service *service)
 Constructor.
 
virtual ~TypedStateFlow ()
 Destructor.
 
void send (MessageType *msg, unsigned priority=UINT_MAX) OVERRIDE
 Sends a message to the state flow for processing.
 
- Public Member Functions inherited from UntypedStateFlow< QueueType >
 UntypedStateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from StateFlowWithQueue
void notify () override
 Wakeup call arrived. Schedules *this on the executor.
 
bool is_waiting ()
 
- Public Member Functions inherited from StateFlowBase
void run () override
 Callback from the executor.
 
Serviceservice ()
 Return a pointer to the service I am bound to.
 
- Public Member Functions inherited from Executable
void test_deletion ()
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 
- Public Member Functions inherited from LinkedObject< StateFlowWithQueue >
StateFlowWithQueuelink_next ()
 
- Public Member Functions inherited from FlowInterface< MessageType >
virtual Poolpool ()
 
virtual MessageType * type_helper ()
 This function is never user in the code, but GDB can use it to infer the correct message types.
 
MessageType * alloc ()
 Synchronously allocates a message buffer from the pool of this flow.
 
void alloc_async (Executable *target)
 Asynchronously allocates a message buffer from the pool of this flow.
 

Protected Member Functions

Action entry () override
 Entry into the StateFlow activity.
 
Action handle_read_error (int error)
 
void cleanup_read ()
 
Action finish_read ()
 
DatagramServicedg_service ()
 
- Protected Member Functions inherited from CallableFlow< MemoryConfigClientRequest >
MemoryConfigClientRequest * request ()
 
bool has_request ()
 
Action return_ok ()
 Terminates the flow and returns the request buffer to the caller with an error code of OK (zero).
 
Action wait_and_return_ok ()
 Waits to be notified before moving onto the next state for termination.
 
Action wait_done ()
 Terminates the flow and returns the request buffer to the caller with an error code of OK (zero).
 
Action return_with_error (int error)
 Terminates the flow and returns the request buffer to the caller with an specific error code.
 
- Protected Member Functions inherited from TypedStateFlow< MessageType, UntypedStateFlow< QueueType > >
void release () OVERRIDE
 Unrefs the current buffer.
 
void return_buffer ()
 For state flows that are operated using invoke_subflow_and_wait this is a way to hand back the buffer to the caller.
 
MessageType * message ()
 
MessageType * transfer_message ()
 Releases ownership of the current message.
 
- Protected Member Functions inherited from UntypedStateFlow< QueueType >
void send (BufferBase *msg, unsigned priority=UINT_MAX)
 Sends a message to the state flow for processing.
 
QMemberqueue_next (unsigned *priority) OVERRIDE
 Takes the front entry in the queue.
 
bool queue_empty () OVERRIDE
 
Action call_immediately (Callback c)
 Imediately call the next state upon return.
 
- Protected Member Functions inherited from StateFlowWithQueue
 StateFlowWithQueue (Service *service)
 Constructor.
 
Action exit ()
 Terminates the processing of this flow.
 
Action release_and_exit ()
 Terminates the processing of the current message.
 
BufferBasemessage ()
 
BufferBasetransfer_message ()
 Releases ownership of the current message.
 
void reset_message (BufferBase *message, unsigned priority)
 Sets the current message being processed.
 
unsigned priority ()
 
void set_priority (unsigned priority)
 Overrides the current priority.
 
void start_flow_at_init (Callback c)
 Call this from the constructor of the child class to do some work before the main queue processing loop begins.
 
- Protected Member Functions inherited from StateFlowBase
 StateFlowBase (Service *service)
 Constructor.
 
 ~StateFlowBase ()
 Destructor.
 
void reset_flow (Callback c)
 Resets the flow to the specified state.
 
bool is_state (Callback c)
 
bool is_terminated ()
 
void start_flow (Callback c)
 Resets the flow to the specified state and starts it.
 
Action again ()
 Call the current state again via call_immediately.
 
Action exit ()
 Terminate current StateFlow activity.
 
Action delete_this ()
 Terminates the flow and deletes *this.
 
Action set_terminated ()
 Sets the flow to terminated state.
 
Action call_immediately (Callback c)
 Imediately call the next state upon return.
 
Action wait ()
 Wait for an asynchronous call.
 
Action wait_and_call (Callback c)
 Wait for resource to become available before proceeding to next state.
 
template<class T >
Action allocate_and_call (FlowInterface< Buffer< T > > *target_flow, Callback c, Pool *pool=nullptr)
 Allocates a buffer from a pool and proceed to the next state when allocation is successful.
 
Action allocate_and_call (Callback c, QAsync *queue)
 Allocates an entry from an asynchronous queue, and transitions to a state once the allocation is complete.
 
template<class T >
Buffer< T > * full_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
T * full_allocation_result (TypedQAsync< T > *queue)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
void cast_allocation_result (T **member)
 Takes the result of the asynchronous allocation without resetting the object.
 
template<class T >
Buffer< T > * get_allocation_result (FlowInterface< Buffer< T > > *target_flow)
 Takes the result of the asynchronous allocation.
 
Action yield_and_call (Callback c)
 Place the current flow to the back of the executor, and transition to a new state after we get the CPU again.
 
Action yield ()
 Place the current flow to the back of the executor, and re-try the current state after we get the CPU again.
 
Action sleep_and_call (::Timer *timer, long long timeout_nsec, Callback c)
 Suspends execution of this control flow for a specified time.
 
template<class T , typename... Args>
Action invoke_subflow_and_wait (FlowInterface< Buffer< T > > *target_flow, Callback c, Args &&... args)
 Calls a helper flow to perform some actions.
 
Action read_repeated (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read and then invokes the next state.
 
Action read_single (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size_t bytes, and blocks the caller until at least one byte is read.
 
Action read_nonblocking (StateFlowSelectHelper *helper, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Attempts to read at most size bytes, and then invokes the next state, even if only zero bytes are available right now.
 
Action read_repeated_with_timeout (StateFlowTimedSelectHelper *helper, long long timeout_nsec, int fd, void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Blocks until size bytes are read, or a timeout expires.
 
Action internal_try_read ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on reading.
 
Action write_repeated (StateFlowSelectHelper *helper, int fd, const void *buf, size_t size, Callback c, unsigned priority=Selectable::MAX_PRIO)
 Writes some data into a file descriptor, repeating the operation as necessary until all bytes are written.
 
Action internal_try_write ()
 Implementation state that gets repeatedly called upon every wakeup and tries to make progress on writing.
 
- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Member Functions inherited from Atomic
void lock ()
 
void unlock ()
 
- Protected Member Functions inherited from LinkedObject< StateFlowWithQueue >
StateFlowWithQueuelink_this ()
 
 LinkedObject ()
 Constructor. Puts *this on the linked list.
 
 ~LinkedObject ()
 Constructor. Removes *this from the linked list.
 
StateFlowWithQueuelink_next ()
 

Protected Attributes

Nodenode_
 Node from which to send the requests out.
 
MemoryConfigHandlermemoryConfigHandler_
 Hook into the parent node's memory config handler service.
 
DatagramClientdgClient_ {nullptr}
 The allocated datagram client which we hold on for the time that we are querying.
 
ResponseFlow responseFlow_ {this}
 Handler for the incoming reply datagrams.
 
BarrierNotifiable bn_
 Notify helper.
 
std::unique_ptr< openlcb::NodeIdLookupFlownodeIdlookupFlow_
 Rarely used helper flow to look up full node IDs from aliases.
 
uint32_t offset_
 Next byte to read from the memory space.
 
uint32_t payloadOffset_
 Next byte in the payload to write.
 
uint16_t writeLength_
 How many bytes we wrote in this datagram.
 
StateFlowTimer timer_ {this}
 timing helper
 
string responsePayload_
 The data that came back from reading.
 
int responseCode_
 error code that came with the response. 0 for success.
 
uint8_t isWaitingForTimer_: 1
 1 if we are pending on the timer.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 
- Protected Attributes inherited from LinkedObject< StateFlowWithQueue >
StateFlowWithQueuelink_
 Linked list pointer.
 

Private Member Functions

Action do_read ()
 
Action send_next_read ()
 
Action send_read_datagram ()
 
Action read_complete ()
 
Action read_response_timeout ()
 
Action do_write ()
 
Action send_next_write ()
 
Action send_write_datagram ()
 
Action write_complete ()
 
Action write_response_timeout ()
 
Action handle_write_error (int error)
 
void cleanup_write ()
 
Action finish_write ()
 
Action do_meta_request ()
 
Action send_meta_datagram ()
 
Action meta_complete ()
 
Action prepare_factory_reset ()
 Before we send out a factory reset command, we have to ensure that we know the target node's node ID, not just the alias.
 
Action dst_id_complete ()
 Completed the ID lookup flow.
 
Action factory_reset_have_id ()
 Called from different places to do the factory reset request once we have the node ID filled in the dst handle.
 

Additional Inherited Members

- Static Public Member Functions inherited from StateFlowBase
template<class T , typename... Args>
static void invoke_subflow_and_ignore_result (FlowInterface< Buffer< T > > *target_flow, Args &&... args)
 Calls a helper flow to perform some actions.
 
- Static Public Member Functions inherited from LinkedObject< StateFlowWithQueue >
static StateFlowWithQueuelink_head ()
 
static Atomichead_mu ()
 Locks the list for modification (at any entry!).
 
- Static Public Member Functions inherited from FlowInterface< MessageType >
static MessageType * cast_alloc (QMember *entry)
 Down casts and initializes an asynchronous allocation result to the appropriate flow's buffer type.
 
- Protected Types inherited from CallableFlow< MemoryConfigClientRequest >
using Action = StateFlowBase::Action
 
- Protected Types inherited from UntypedStateFlow< QueueType >
typedef Action(StateFlowBase::* Callback) ()
 State Flow callback prototype.
 
- Protected Types inherited from StateFlowBase
typedef Action(StateFlowBase::* Callback) ()
 State Flow callback prototype.
 
- Static Protected Member Functions inherited from LinkedObject< StateFlowWithQueue >
static StateFlowWithQueuelink_head ()
 
static Atomichead_mu ()
 Locks the list for modification (at any entry!).
 
- Static Protected Attributes inherited from LinkedObject< StateFlowWithQueue >
static StateFlowWithQueuehead_
 Beginning of the list.
 

Detailed Description

Definition at line 294 of file MemoryConfigClient.hxx.

Member Enumeration Documentation

◆ ResultCodes

These result codes are written into request()->resultCode during and as a return from the flow.

Enumerator
OPERATION_PENDING 

cleared when done is called.

TIMEOUT 

Timeout waiting for ack/nack.

Definition at line 305 of file MemoryConfigClient.hxx.

Constructor & Destructor Documentation

◆ MemoryConfigClient()

openlcb::MemoryConfigClient::MemoryConfigClient ( Node node,
MemoryConfigHandler memcfg 
)
inline

Definition at line 297 of file MemoryConfigClient.hxx.

Member Function Documentation

◆ cleanup_read()

void openlcb::MemoryConfigClient::cleanup_read ( )
inlineprotected

Definition at line 473 of file MemoryConfigClient.hxx.

◆ cleanup_write()

void openlcb::MemoryConfigClient::cleanup_write ( )
inlineprivate

Definition at line 606 of file MemoryConfigClient.hxx.

◆ dg_service()

DatagramService * openlcb::MemoryConfigClient::dg_service ( )
inlineprotected

Definition at line 794 of file MemoryConfigClient.hxx.

◆ do_meta_request()

Action openlcb::MemoryConfigClient::do_meta_request ( )
inlineprivate

Definition at line 620 of file MemoryConfigClient.hxx.

◆ do_read()

Action openlcb::MemoryConfigClient::do_read ( )
inlineprivate

Definition at line 352 of file MemoryConfigClient.hxx.

◆ do_write()

Action openlcb::MemoryConfigClient::do_write ( )
inlineprivate

Definition at line 488 of file MemoryConfigClient.hxx.

◆ dst_id_complete()

Action openlcb::MemoryConfigClient::dst_id_complete ( )
inlineprivate

Completed the ID lookup flow.

Definition at line 678 of file MemoryConfigClient.hxx.

◆ entry()

Action openlcb::MemoryConfigClient::entry ( )
inlineoverrideprotectedvirtual

Entry into the StateFlow activity.

Pure virtual which must be defined by derived class.

Returns
function pointer to next state

Implements TypedStateFlow< MessageType, UntypedStateFlow< QueueType > >.

Reimplemented in openlcb::MemoryConfigClientWithStream.

Definition at line 328 of file MemoryConfigClient.hxx.

◆ factory_reset_have_id()

Action openlcb::MemoryConfigClient::factory_reset_have_id ( )
inlineprivate

Called from different places to do the factory reset request once we have the node ID filled in the dst handle.

Definition at line 694 of file MemoryConfigClient.hxx.

◆ finish_read()

Action openlcb::MemoryConfigClient::finish_read ( )
inlineprotected

Definition at line 481 of file MemoryConfigClient.hxx.

◆ finish_write()

Action openlcb::MemoryConfigClient::finish_write ( )
inlineprivate

Definition at line 614 of file MemoryConfigClient.hxx.

◆ handle_read_error()

Action openlcb::MemoryConfigClient::handle_read_error ( int  error)
inlineprotected

Definition at line 463 of file MemoryConfigClient.hxx.

◆ handle_write_error()

Action openlcb::MemoryConfigClient::handle_write_error ( int  error)
inlineprivate

Definition at line 596 of file MemoryConfigClient.hxx.

◆ mem_cfg()

MemoryConfigHandler * openlcb::MemoryConfigClient::mem_cfg ( )
inline
Returns
OpenLCB memory config handler (which was given in the constructor).

Definition at line 322 of file MemoryConfigClient.hxx.

◆ meta_complete()

Action openlcb::MemoryConfigClient::meta_complete ( )
inlineprivate

Definition at line 640 of file MemoryConfigClient.hxx.

◆ node()

Node * openlcb::MemoryConfigClient::node ( )
inline
Returns
OpenLCB node (ourselves) for outgoing communications.

Definition at line 315 of file MemoryConfigClient.hxx.

◆ prepare_factory_reset()

Action openlcb::MemoryConfigClient::prepare_factory_reset ( )
inlineprivate

Before we send out a factory reset command, we have to ensure that we know the target node's node ID, not just the alias.

Definition at line 659 of file MemoryConfigClient.hxx.

◆ read_complete()

Action openlcb::MemoryConfigClient::read_complete ( )
inlineprivate

Definition at line 384 of file MemoryConfigClient.hxx.

◆ read_response_timeout()

Action openlcb::MemoryConfigClient::read_response_timeout ( )
inlineprivate

Definition at line 403 of file MemoryConfigClient.hxx.

◆ send_meta_datagram()

Action openlcb::MemoryConfigClient::send_meta_datagram ( )
inlineprivate

Definition at line 629 of file MemoryConfigClient.hxx.

◆ send_next_read()

Action openlcb::MemoryConfigClient::send_next_read ( )
inlineprivate

Definition at line 360 of file MemoryConfigClient.hxx.

◆ send_next_write()

Action openlcb::MemoryConfigClient::send_next_write ( )
inlineprivate

Definition at line 497 of file MemoryConfigClient.hxx.

◆ send_read_datagram()

Action openlcb::MemoryConfigClient::send_read_datagram ( )
inlineprivate

Definition at line 366 of file MemoryConfigClient.hxx.

◆ send_write_datagram()

Action openlcb::MemoryConfigClient::send_write_datagram ( )
inlineprivate

Definition at line 503 of file MemoryConfigClient.hxx.

◆ write_complete()

Action openlcb::MemoryConfigClient::write_complete ( )
inlineprivate

Definition at line 522 of file MemoryConfigClient.hxx.

◆ write_response_timeout()

Action openlcb::MemoryConfigClient::write_response_timeout ( )
inlineprivate

Definition at line 541 of file MemoryConfigClient.hxx.

Member Data Documentation

◆ bn_

BarrierNotifiable openlcb::MemoryConfigClient::bn_
protected

Notify helper.

Definition at line 809 of file MemoryConfigClient.hxx.

◆ dgClient_

DatagramClient* openlcb::MemoryConfigClient::dgClient_ {nullptr}
protected

The allocated datagram client which we hold on for the time that we are querying.

Definition at line 805 of file MemoryConfigClient.hxx.

◆ isWaitingForTimer_

uint8_t openlcb::MemoryConfigClient::isWaitingForTimer_
protected

1 if we are pending on the timer.

Definition at line 825 of file MemoryConfigClient.hxx.

◆ memoryConfigHandler_

MemoryConfigHandler* openlcb::MemoryConfigClient::memoryConfigHandler_
protected

Hook into the parent node's memory config handler service.

Definition at line 802 of file MemoryConfigClient.hxx.

◆ node_

Node* openlcb::MemoryConfigClient::node_
protected

Node from which to send the requests out.

Definition at line 800 of file MemoryConfigClient.hxx.

◆ nodeIdlookupFlow_

std::unique_ptr<openlcb::NodeIdLookupFlow> openlcb::MemoryConfigClient::nodeIdlookupFlow_
protected

Rarely used helper flow to look up full node IDs from aliases.

Definition at line 811 of file MemoryConfigClient.hxx.

◆ offset_

uint32_t openlcb::MemoryConfigClient::offset_
protected

Next byte to read from the memory space.

Definition at line 813 of file MemoryConfigClient.hxx.

◆ payloadOffset_

uint32_t openlcb::MemoryConfigClient::payloadOffset_
protected

Next byte in the payload to write.

Definition at line 815 of file MemoryConfigClient.hxx.

◆ responseCode_

int openlcb::MemoryConfigClient::responseCode_
protected

error code that came with the response. 0 for success.

Definition at line 823 of file MemoryConfigClient.hxx.

◆ responseFlow_

ResponseFlow openlcb::MemoryConfigClient::responseFlow_ {this}
protected

Handler for the incoming reply datagrams.

Definition at line 807 of file MemoryConfigClient.hxx.

◆ responsePayload_

string openlcb::MemoryConfigClient::responsePayload_
protected

The data that came back from reading.

Definition at line 821 of file MemoryConfigClient.hxx.

◆ timer_

StateFlowTimer openlcb::MemoryConfigClient::timer_ {this}
protected

timing helper

Definition at line 819 of file MemoryConfigClient.hxx.

◆ writeLength_

uint16_t openlcb::MemoryConfigClient::writeLength_
protected

How many bytes we wrote in this datagram.

Definition at line 817 of file MemoryConfigClient.hxx.


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