Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::RoutingLogic< Port, Address > Class Template Reference

Routing table for gateways and routers in OpenLCB. More...

#include <RoutingLogic.hxx>

Classes

struct  EventSet
 The per-port event information. More...
 

Public Member Functions

void remove_port (Port *port)
 Clears all entries in the routing table related to a given port, as the given port is being removed.
 
void add_node_id_to_route (Port *port, Address source)
 Declares that a given node ID is reachable via a specific port.
 
Port * lookup_port_for_address (Address dest)
 Looks up which port an addressed packet should be sent to.
 
void register_consumer (Port *port, EventId event)
 Declares that there is a consumer for the given event ID on the given port.
 
void register_consumer_range (Port *port, EventId encoded_range)
 Declares that there is a consumer for the given event ID range on the given port.
 
void register_producer (Port *port, EventId event)
 Declares that there is a producer for the given event ID on the given port.
 
void register_producer_range (Port *port, EventId encoded_range)
 Declares that there is a producer for the given event ID range on the given port.
 
bool check_pcer (Port *port, EventId event)
 Checks if a given PCER message should be forwarded to the given port.
 

Private Attributes

OSMutex lock_
 Protects all internal data structures.
 
std::unordered_map< Address, Port * > addressRoutingTable_
 Stores all known addresses and which port they route to.
 
std::map< Port *, EventSeteventRoutingTable_
 Stores per-port event information.
 

Detailed Description

template<class Port, typename Address>
class openlcb::RoutingLogic< Port, Address >

Routing table for gateways and routers in OpenLCB.

The routing table contains which direction to send addressed packets as well as filters for the event IDs that have listeners in a given port.

Definition at line 65 of file RoutingLogic.hxx.

Constructor & Destructor Documentation

◆ RoutingLogic()

template<class Port , typename Address >
openlcb::RoutingLogic< Port, Address >::RoutingLogic ( )
inline

Definition at line 68 of file RoutingLogic.hxx.

◆ ~RoutingLogic()

template<class Port , typename Address >
openlcb::RoutingLogic< Port, Address >::~RoutingLogic ( )
inline

Definition at line 71 of file RoutingLogic.hxx.

Member Function Documentation

◆ add_node_id_to_route()

template<class Port , typename Address >
void openlcb::RoutingLogic< Port, Address >::add_node_id_to_route ( Port *  port,
Address  source 
)
inline

Declares that a given node ID is reachable via a specific port.

Used with the source node IDs of all the incoming packets.

Parameters
portis where the incoming packet came from (i.e. the port on which source is reachable.
sourceis the node handle where the packet came from.

Definition at line 105 of file RoutingLogic.hxx.

◆ check_pcer()

template<class Port , typename Address >
bool openlcb::RoutingLogic< Port, Address >::check_pcer ( Port *  port,
EventId  event 
)
inline

Checks if a given PCER message should be forwarded to the given port.

Parameters
portis the port to query.
eventis the event ID from the PCER message.
Returns
true if the given event has a consumer on the given port.

Definition at line 185 of file RoutingLogic.hxx.

◆ lookup_port_for_address()

template<class Port , typename Address >
Port * openlcb::RoutingLogic< Port, Address >::lookup_port_for_address ( Address  dest)
inline

Looks up which port an addressed packet should be sent to.

Parameters
destis the address of the destination node that needs to be contacted.
Returns
a (live) port if the address is in the routing table, otherwise nullptr.

Definition at line 118 of file RoutingLogic.hxx.

◆ register_consumer()

template<class Port , typename Address >
void openlcb::RoutingLogic< Port, Address >::register_consumer ( Port *  port,
EventId  event 
)
inline

Declares that there is a consumer for the given event ID on the given port.

Parameters
portis where the consumer identified from has come from.
eventis the event ID for which there is a consumer identified on that port.

Definition at line 133 of file RoutingLogic.hxx.

◆ register_consumer_range()

template<class Port , typename Address >
void openlcb::RoutingLogic< Port, Address >::register_consumer_range ( Port *  port,
EventId  encoded_range 
)
inline

Declares that there is a consumer for the given event ID range on the given port.

Parameters
portis there the consumer range identified has come from.
encoded_rangeis the range of consumer encoded via the OpenLCB method.

Definition at line 145 of file RoutingLogic.hxx.

◆ register_producer()

template<class Port , typename Address >
void openlcb::RoutingLogic< Port, Address >::register_producer ( Port *  port,
EventId  event 
)
inline

Declares that there is a producer for the given event ID on the given port.

Parameters
portis where the producer identified from has come from.
eventis the event ID for which there is a producer identified on that port.

Definition at line 159 of file RoutingLogic.hxx.

◆ register_producer_range()

template<class Port , typename Address >
void openlcb::RoutingLogic< Port, Address >::register_producer_range ( Port *  port,
EventId  encoded_range 
)
inline

Declares that there is a producer for the given event ID range on the given port.

Parameters
portis there the producer range identified has come from.
encoded_rangeis the range of producer encoded via the OpenLCB method.

Definition at line 172 of file RoutingLogic.hxx.

◆ remove_port()

template<class Port , typename Address >
void openlcb::RoutingLogic< Port, Address >::remove_port ( Port *  port)
inline

Clears all entries in the routing table related to a given port, as the given port is being removed.

Parameters
portdescribes the target port to be removed.

Definition at line 80 of file RoutingLogic.hxx.

Member Data Documentation

◆ addressRoutingTable_

template<class Port , typename Address >
std::unordered_map<Address, Port *> openlcb::RoutingLogic< Port, Address >::addressRoutingTable_
private

Stores all known addresses and which port they route to.

Definition at line 222 of file RoutingLogic.hxx.

◆ eventRoutingTable_

template<class Port , typename Address >
std::map<Port *, EventSet> openlcb::RoutingLogic< Port, Address >::eventRoutingTable_
private

Stores per-port event information.

Definition at line 233 of file RoutingLogic.hxx.

◆ lock_

template<class Port , typename Address >
OSMutex openlcb::RoutingLogic< Port, Address >::lock_
private

Protects all internal data structures.

Definition at line 219 of file RoutingLogic.hxx.


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