Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
TypedNodeHandlerMap< Node, Handler > Class Template Reference

A type-safe map that allows registration and lookup or per-node handler of a particular message ID. More...

#include <NodeHandlerMap.hxx>

Inheritance diagram for TypedNodeHandlerMap< Node, Handler >:
NodeHandlerMapBase

Classes

class  iterator
 Type-safe iterator for NodeHandlerMap. More...
 

Public Member Functions

 TypedNodeHandlerMap (size_t entries)
 
void insert (Node *node, uint32_t id, Handler *handler)
 Inserts a handler into the map.
 
void erase (Node *node, uint32_t id, Handler *handler)
 Removes a handler from the map.
 
Handler * lookup (Node *node, uint32_t id)
 Finds a handler for a particular node and particular messageID.
 
iterator begin ()
 
iterator end ()
 

Additional Inherited Members

- Private Types inherited from NodeHandlerMapBase
typedef map_type::Iterator iterator
 Iterator type.
 
- Private Member Functions inherited from NodeHandlerMapBase
 NodeHandlerMapBase (size_t entries)
 Creates a map with.
 
void insert (void *node, uint32_t id, void *value)
 Inserts a handler into the map.
 
void erase (void *node, uint32_t id, void *value)
 Removes a handlerfrom this map.
 
void * lookup (void *node, uint32_t id)
 Finds a handler for a particular node and particular messageID.
 
iterator begin ()
 
iterator end ()
 
- Static Private Member Functions inherited from NodeHandlerMapBase
static pair< void *, uint32_t > read_key (key_type key)
 Decodes a compact key into a pair.
 

Detailed Description

template<class Node, class Handler>
class TypedNodeHandlerMap< Node, Handler >

A type-safe map that allows registration and lookup or per-node handler of a particular message ID.

see NodeHandlerMapBase for details.

Definition at line 181 of file NodeHandlerMap.hxx.

Constructor & Destructor Documentation

◆ TypedNodeHandlerMap() [1/2]

template<class Node , class Handler >
TypedNodeHandlerMap< Node, Handler >::TypedNodeHandlerMap ( )
inline

Definition at line 184 of file NodeHandlerMap.hxx.

◆ TypedNodeHandlerMap() [2/2]

template<class Node , class Handler >
TypedNodeHandlerMap< Node, Handler >::TypedNodeHandlerMap ( size_t  entries)
inline
Parameters
entriesis the number of maximum entries in this map (will statically allocate).

Definition at line 190 of file NodeHandlerMap.hxx.

Member Function Documentation

◆ begin()

template<class Node , class Handler >
iterator TypedNodeHandlerMap< Node, Handler >::begin ( )
inline
Returns
begin iterator

Definition at line 256 of file NodeHandlerMap.hxx.

◆ end()

template<class Node , class Handler >
iterator TypedNodeHandlerMap< Node, Handler >::end ( )
inline
Returns
end iterator

Definition at line 261 of file NodeHandlerMap.hxx.

◆ erase()

template<class Node , class Handler >
void TypedNodeHandlerMap< Node, Handler >::erase ( Node node,
uint32_t  id,
Handler *  handler 
)
inline

Removes a handler from the map.

If the mapping does not currently point to that handler, does nothing.

Parameters
nodeis the node for which to unregister the handler.
idis the message ID for which to unregister.
valueis the handler to unregister.

Definition at line 211 of file NodeHandlerMap.hxx.

◆ insert()

template<class Node , class Handler >
void TypedNodeHandlerMap< Node, Handler >::insert ( Node node,
uint32_t  id,
Handler *  handler 
)
inline

Inserts a handler into the map.

Parameters
nodeis the node for which to register the handler.
idis the message ID for which to register.
valueis the handler to register.

Definition at line 199 of file NodeHandlerMap.hxx.

◆ lookup()

template<class Node , class Handler >
Handler * TypedNodeHandlerMap< Node, Handler >::lookup ( Node node,
uint32_t  id 
)
inline

Finds a handler for a particular node and particular messageID.

Parameters
nodeis the node that received the message
idis the message's ID
Returns
a handler or nullptr if no node-specific and no global handler for that ID is found.

Definition at line 221 of file NodeHandlerMap.hxx.


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