Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
NodeHandlerMapBase Class Reference

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

#include <NodeHandlerMap.hxx>

Inheritance diagram for NodeHandlerMapBase:
TypedNodeHandlerMap< Node, DatagramHandler > TypedNodeHandlerMap< Node, Handler >

Public Types

typedef map_type::Iterator iterator
 Iterator type.
 

Public Member Functions

 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 Public Member Functions

static pair< void *, uint32_t > read_key (key_type key)
 Decodes a compact key into a pair.
 

Private Types

typedef uint64_t key_type
 Compacted payload type.
 
typedef void * value_type
 Generic handler type that we'll keep.
 
typedef StlMap< key_type, value_typemap_type
 Type of the storage object.
 

Private Member Functions

key_type make_key (void *node, uint32_t id)
 Combines the node pointer and the message ID into a lookup key.
 

Private Attributes

map_type entries_
 The actual storage object.
 

Detailed Description

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

Regular handlers are registered for a node and messsageID pair.

The map supports registering handlers for a message ID globally by supplying nullptr as the node. These will be returned for nodes that have no specific handler for that particular message ID.

Definition at line 61 of file NodeHandlerMap.hxx.

Member Typedef Documentation

◆ iterator

Iterator type.

Definition at line 134 of file NodeHandlerMap.hxx.

◆ key_type

typedef uint64_t NodeHandlerMapBase::key_type
private

Compacted payload type.

Definition at line 69 of file NodeHandlerMap.hxx.

◆ map_type

Type of the storage object.

Definition at line 74 of file NodeHandlerMap.hxx.

◆ value_type

typedef void* NodeHandlerMapBase::value_type
private

Generic handler type that we'll keep.

Definition at line 72 of file NodeHandlerMap.hxx.

Constructor & Destructor Documentation

◆ NodeHandlerMapBase() [1/2]

NodeHandlerMapBase::NodeHandlerMapBase ( )
inline

Definition at line 77 of file NodeHandlerMap.hxx.

◆ NodeHandlerMapBase() [2/2]

NodeHandlerMapBase::NodeHandlerMapBase ( size_t  entries)
inline

Creates a map with.

Parameters
entriescapacity.

Definition at line 82 of file NodeHandlerMap.hxx.

Member Function Documentation

◆ begin()

iterator NodeHandlerMapBase::begin ( )
inline
Returns
begin iterator

Definition at line 136 of file NodeHandlerMap.hxx.

◆ end()

iterator NodeHandlerMapBase::end ( )
inline
Returns
end iterator

Definition at line 142 of file NodeHandlerMap.hxx.

◆ erase()

void NodeHandlerMapBase::erase ( void *  node,
uint32_t  id,
void *  value 
)
inline

Removes a handlerfrom this map.

Parameters
nodeis the node to unregister handler for (nullptr for all nodes)
idis the message ID for which to unregister for.
valueis the pointer to the handler.

Definition at line 102 of file NodeHandlerMap.hxx.

◆ insert()

void NodeHandlerMapBase::insert ( void *  node,
uint32_t  id,
void *  value 
)
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 91 of file NodeHandlerMap.hxx.

◆ lookup()

void * NodeHandlerMapBase::lookup ( void *  node,
uint32_t  id 
)
inline

Finds a handler for a particular node and particular messageID.

Returns
a handler or nullptr if no node-specific and no global handler for that ID is found.
Parameters
nodewhat to look up for
idis the message ID to look up

Definition at line 116 of file NodeHandlerMap.hxx.

◆ make_key()

key_type NodeHandlerMapBase::make_key ( void *  node,
uint32_t  id 
)
inlineprivate

Combines the node pointer and the message ID into a lookup key.

Definition at line 162 of file NodeHandlerMap.hxx.

◆ read_key()

static pair< void *, uint32_t > NodeHandlerMapBase::read_key ( key_type  key)
inlinestatic

Decodes a compact key into a pair.

Parameters
keyis what to decode.
Returns
decoded key (classic iterator pair value).

Definition at line 149 of file NodeHandlerMap.hxx.

Member Data Documentation

◆ entries_

map_type NodeHandlerMapBase::entries_
private

The actual storage object.

Definition at line 175 of file NodeHandlerMap.hxx.


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