35#ifndef _OPENLCB_IF_HXX_
36#define _OPENLCB_IF_HXX_
74 :
src({0, 0}),
dst({0, 0}), flagsSrc(0), flagsDst(0) {}
86 this->payload = std::move(
payload);
97 this->payload = std::move(
payload);
115 unsigned flagsSrc : 4;
116 unsigned flagsDst : 4;
117 unsigned get_flags_src() {
120 unsigned get_flags_dst() {
123 void set_flag_src(
unsigned flags) {
126 void clear_flag_src(
unsigned flags) {
131 return ((flagsSrc & flags) == flags);
133 void set_flag_dst(
unsigned flags) {
136 void clear_flag_dst(
unsigned flags) {
141 return ((flagsDst & flags) == flags);
144 typedef uint32_t id_type;
147 return static_cast<uint32_t
>(
mti);
244 NodeID id = node->node_id();
361 void remove_local_node_from_map(
Node *node)
409 return static_cast<If *
>(service());
430 msg->
data()->reset(mti, src_node->node_id(), std::forward<Args>(args)...);
DynamicPool * mainBufferPool
main buffer pool instance
Base class for all QMember types that hold data in an expandable format.
T * data()
get a pointer to the start of the data.
Type-specific implementations of the DispatchFlow methods.
An object that can be scheduled on an executor to run.
This class implements an execution of tasks pulled off an input queue.
Abstract class for message recipients.
virtual void send(MessageType *message, unsigned priority=UINT_MAX)=0
Entry point to the flow.
Though the standard template library includes std::map, commonly implemented as a Red Black tree,...
void alloc(Buffer< BufferType > **result, Executable *flow=NULL)
Get a free item out of the pool.
Collection of related state machines that pend on incoming messages.
ExecutorBase * executor()
State flow with a given typed input queue.
Abstract class representing an OpenLCB Interface.
VNodeMap localNodes_
Local virtual nodes registered on this interface.
virtual void canonicalize_handle(NodeHandle *h)
Canonicalizes the node handle: fills in id and/or alias from the maps the interface holds internally.
virtual void delete_local_node(Node *node)=0
Removes a local node from this interface.
MessageHandler * global_message_write_flow()
MessageDispatchFlow * dispatcher()
Node * first_local_node()
void add_local_node(Node *node)
Registers a new local node on this interface.
std::function< void()> txHook_
This function is pinged every time a message is transmitted.
MessageHandler * addressedWriteFlow_
Allocator containing the addressed write flows.
virtual Node * lookup_local_node_handle(NodeHandle handle)
Looks up a node ID in the local nodes' registry.
MessageDispatchFlow dispatcher_
Flow responsible for routing incoming messages to handlers.
Node * lookup_local_node(NodeID id)
Looks up a node ID in the local nodes' registry.
void set_stream_transport(StreamTransport *s)
Adds the necessary object for this interface to support stream transport.
StreamTransport * streamTransport_
Accessor for the objects and variables for supporting stream transport.
virtual void add_owned_flow(Executable *e)=0
Transfers ownership of a module to the interface.
MessageHandler * globalWriteFlow_
Allocator containing the global write flows.
DispatchFlow< Buffer< GenMessage >, 4 > MessageDispatchFlow
Type of the dispatcher of incoming NMRAnet messages.
StreamTransport * stream_transport()
void set_tx_hook(std::function< void()> hook)
Sets a transmit hook.
Node * next_local_node(NodeID previous)
Iterator helper on the local nodes map.
MessageHandler * addressed_message_write_flow()
virtual NodeID get_default_node_id()=0
virtual bool matching_node(NodeHandle expected, NodeHandle actual)=0
Base class for incoming message handler flows.
GenMessage * nmsg()
Returns the NMRAnet message we received.
Base class for NMRAnet nodes conforming to the asynchronous interface.
Collects the objects needed to support streams on an OpenLCB interface.
This handler handles VerifyNodeId messages (both addressed and global) on the interface level.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
string EMPTY_PAYLOAD
A global class / variable for empty or not-yet-initialized payloads.
StateFlow< Buffer< GenMessage >, QList< 4 > > MessageStateFlowBase
Message handlers that are implemented as state flows should derive from this class.
uint64_t NodeID
48-bit NMRAnet Node ID type
void send_event(Node *src_node, uint64_t event_id)
Helper function to send an event report to the bus.
FlowInterface< Buffer< GenMessage > > MessageHandler
Interface class for all handlers that can be registered in the dispatcher to receive incoming NMRAnet...
void send_message(Node *src_node, Defs::MTI mti, Args &&...args)
Sends an OpenLCB message to the bus.
static unsigned int mti_priority(MTI mti)
Get the MTI priority (value 0 through 3).
MTI
Known Message type indicators.
This class is used in the dispatching of incoming or outgoing NMRAnet messages to the message handler...
@ DSTFLAG_NOT_FIRST_MESSAGE
Signals to the stack that we need to set the continuation bits in the outgoing message to indicate th...
@ WAIT_FOR_LOCAL_LOOPBACK
Specifies that the stack should wait for the local loopback processing before invoking the done notif...
@ DSTFLAG_NOT_LAST_MESSAGE
Signals to the stack that we need to set the continuation bits in the outgoing message to indicate th...
unsigned priority()
Returns the NMRAnet-defined priority band, in the range of 0..3.
NodeHandle dst
Destination node.
Node * dstNode
If the destination node is local, this value is non-NULL.
bool has_flag_src(unsigned flags)
Returns true if src flags has all the specified flags set.
NodeHandle src
Source node.
Defs::MTI mti
OpenLCB MTI of the incoming message.
string payload
Data content in the message body.
bool has_flag_dst(unsigned flags)
Returns true if src flags has all the specified flags set.
Container of both a NodeID and NodeAlias.
NodeID id
48-bit NMRAnet Node ID