|
Open Model Railroad Network (OpenMRN)
|
Abstract class representing an OpenLCB Interface. More...
#include <If.hxx>
Public Types | |
| typedef DispatchFlow< Buffer< GenMessage >, 4 > | MessageDispatchFlow |
| Type of the dispatcher of incoming NMRAnet messages. | |
Public Member Functions | |
| If (ExecutorBase *executor, int local_nodes_count) | |
| Constructs an NMRAnet interface. | |
| virtual | ~If () |
| Destructor. | |
| MessageHandler * | global_message_write_flow () |
| MessageHandler * | addressed_message_write_flow () |
| MessageDispatchFlow * | dispatcher () |
| virtual void | add_owned_flow (Executable *e)=0 |
| Transfers ownership of a module to the interface. | |
| void | add_local_node (Node *node) |
| Registers a new local node on this interface. | |
| virtual void | delete_local_node (Node *node)=0 |
| Removes a local node from this interface. | |
| Node * | lookup_local_node (NodeID id) |
| Looks up a node ID in the local nodes' registry. | |
| virtual Node * | lookup_local_node_handle (NodeHandle handle) |
| Looks up a node ID in the local nodes' registry. | |
| Node * | first_local_node () |
| Node * | next_local_node (NodeID previous) |
| Iterator helper on the local nodes map. | |
| virtual bool | matching_node (NodeHandle expected, NodeHandle actual)=0 |
| virtual void | canonicalize_handle (NodeHandle *h) |
| Canonicalizes the node handle: fills in id and/or alias from the maps the interface holds internally. | |
| virtual NodeID | get_default_node_id ()=0 |
| void | set_tx_hook (std::function< void()> hook) |
| Sets a transmit hook. | |
| StreamTransport * | stream_transport () |
| void | set_stream_transport (StreamTransport *s) |
| Adds the necessary object for this interface to support stream transport. | |
Public Member Functions inherited from Service | |
| Service (ExecutorBase *e) | |
| Constructor. | |
| ~Service () | |
| Destructor. | |
| ExecutorBase * | executor () |
Protected Member Functions | |
| void | remove_local_node_from_map (Node *node) |
Protected Attributes | |
| MessageHandler * | globalWriteFlow_ |
| Allocator containing the global write flows. | |
| MessageHandler * | addressedWriteFlow_ |
| Allocator containing the addressed write flows. | |
Private Types | |
| typedef Map< NodeID, Node * > | VNodeMap |
Private Member Functions | |
| DISALLOW_COPY_AND_ASSIGN (If) | |
Private Attributes | |
| MessageDispatchFlow | dispatcher_ |
| Flow responsible for routing incoming messages to handlers. | |
| std::function< void()> | txHook_ |
| This function is pinged every time a message is transmitted. | |
| VNodeMap | localNodes_ |
| Local virtual nodes registered on this interface. | |
| StreamTransport * | streamTransport_ {nullptr} |
| Accessor for the objects and variables for supporting stream transport. | |
Friends | |
| class | VerifyNodeIdHandler |
Abstract class representing an OpenLCB Interface.
All interaction between the local software stack and the physical bus has to go through this class. The API that's not specific to the wire protocol appears here. The implementations of this class would be specific to the wire protocol (e.g. IfCan for CAN, and a not-yet-implemented class for TCP).
| typedef DispatchFlow<Buffer<GenMessage>, 4> openlcb::If::MessageDispatchFlow |
| openlcb::If::If | ( | ExecutorBase * | executor, |
| int | local_nodes_count | ||
| ) |
Constructs an NMRAnet interface.
@TODO(balazs.racz): make the map size parametrizable.
| executor | is the thread that will be used for all processing on this interface. |
| local_nodes_count | is the maximum number of virtual nodes that this interface will support. |
|
inline |
|
pure virtual |
Transfers ownership of a module to the interface.
It will be brought down in the destructor. The destruction order is guaranteed such that all supporting structures are still available when the flow is destryed, but incoming messages can not come in anymore.
Implemented in openlcb::IfCan, openlcb::IfTcp, and openlcb::LocalIf.
|
inline |
|
inlinevirtual |
Canonicalizes the node handle: fills in id and/or alias from the maps the interface holds internally.
Noop for TCP interface. Must be called on the interface executor.
Reimplemented in openlcb::IfCan.
|
pure virtual |
Removes a local node from this interface.
This function must be called from the interface's executor.
| node | is the node to delete. The node will not be freed, just removed from the data structures. |
Implemented in openlcb::IfCan, openlcb::IfTcp, and openlcb::LocalIf.
|
inline |
|
inline |
|
pure virtual |
Implemented in openlcb::IfCan, openlcb::IfTcp, and openlcb::LocalIf.
|
inline |
|
inlinevirtual |
Looks up a node ID in the local nodes' registry.
This function must be called from the interface's executor.
| handle | is the NodeHandle representing a target node. |
Reimplemented in openlcb::IfCan.
|
pure virtual |
Implemented in openlcb::IfCan, openlcb::IfTcp, and openlcb::LocalIf.
|
inlineprotected |
|
inline |
|
inline |
|
inline |
|
friend |
|
protected |
|
private |
|
protected |
|
private |
|
private |
|
private |