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

Class for routing incoming datagram messages to the datagram handlers. More...

Inheritance diagram for openlcb::DatagramService::DatagramDispatcher:
openlcb::IncomingMessageStateFlow StateFlow< Buffer< GenMessage >, QList< 4 > > TypedStateFlow< MessageType, Base > FlowInterface< MessageType >

Public Member Functions

 DatagramDispatcher (If *iface, size_t num_registry_entries)
 
Registryregistry ()
 
- Public Member Functions inherited from openlcb::IncomingMessageStateFlow
 IncomingMessageStateFlow (If *iface)
 
Ififace ()
 
GenMessagenmsg ()
 Returns the NMRAnet message we received.
 
- Public Member Functions inherited from StateFlow< Buffer< GenMessage >, QList< 4 > >
 StateFlow (Service *service)
 Constructor.
 
- Public Member Functions inherited from TypedStateFlow< MessageType, Base >
 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 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.
 

Private Member Functions

Action entry () override
 Entry into the StateFlow activity.
 
Action incoming_datagram_allocated ()
 
Action respond_rejection ()
 

Private Attributes

Buffer< IncomingDatagram > * d_
 
uint16_t resultCode_
 
Registry registry_
 Maintains the registered datagram handlers.
 

Additional Inherited Members

- Public Types inherited from TypedStateFlow< MessageType, Base >
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.
 
- 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 Member Functions inherited from TypedStateFlow< MessageType, Base >
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.
 

Detailed Description

Class for routing incoming datagram messages to the datagram handlers.

Keeps a registry of datagram handlers. Listens to incoming MTI_DATAGRAM messages coming from the If, and routes them to the appropriate datagram handlerflow.

The dispatcher is a state flow that is using the If as the base service and not the DatagramService that owns it.

Definition at line 205 of file Datagram.hxx.

Constructor & Destructor Documentation

◆ DatagramDispatcher()

openlcb::DatagramService::DatagramDispatcher::DatagramDispatcher ( If iface,
size_t  num_registry_entries 
)
inline

Definition at line 208 of file Datagram.hxx.

◆ ~DatagramDispatcher()

openlcb::DatagramService::DatagramDispatcher::~DatagramDispatcher ( )
inline

Definition at line 214 of file Datagram.hxx.

Member Function Documentation

◆ entry()

StateFlowBase::Action openlcb::DatagramService::DatagramDispatcher::entry ( )
overrideprivatevirtual

Entry into the StateFlow activity.

Pure virtual which must be defined by derived class.

Returns
function pointer to next state

Implements TypedStateFlow< MessageType, Base >.

Definition at line 58 of file Datagram.cxx.

◆ incoming_datagram_allocated()

StateFlowBase::Action openlcb::DatagramService::DatagramDispatcher::incoming_datagram_allocated ( )
private

@TODO(balazs.racz) Implement buffer refcounting.

Definition at line 68 of file Datagram.cxx.

◆ registry()

Registry * openlcb::DatagramService::DatagramDispatcher::registry ( )
inline
Returns
the registry of datagram handlers.

Definition at line 219 of file Datagram.hxx.

◆ respond_rejection()

StateFlowBase::Action openlcb::DatagramService::DatagramDispatcher::respond_rejection ( )
private

Definition at line 116 of file Datagram.cxx.

Member Data Documentation

◆ d_

Buffer<IncomingDatagram>* openlcb::DatagramService::DatagramDispatcher::d_
private

Definition at line 230 of file Datagram.hxx.

◆ registry_

Registry openlcb::DatagramService::DatagramDispatcher::registry_
private

Maintains the registered datagram handlers.

Definition at line 234 of file Datagram.hxx.

◆ resultCode_

uint16_t openlcb::DatagramService::DatagramDispatcher::resultCode_
private

Definition at line 231 of file Datagram.hxx.


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