xorp

ConfigNodeId Class Reference

Class for encoding and decoding configuration-related node IDs. More...

#include <config_node_id.hh>

List of all members.

Public Types

typedef uint64_t UniqueNodeId
typedef uint64_t Position
typedef uint32_t InstanceId

Public Member Functions

 ConfigNodeId (const string &s) throw (InvalidString)
 Constructor from a string.
 ConfigNodeId (const UniqueNodeId &unique_node_id, const Position &position)
 Constructor for a given unique node ID and position.
virtual ~ConfigNodeId ()
 Destructor.
size_t copy_in (const string &from_string) throw (InvalidString)
 Copy an unique node ID from a string into ConfigNodeId structure.
bool operator== (const ConfigNodeId &other) const
 Equality Operator.
const UniqueNodeId & unique_node_id () const
 Return the unique node ID.
const Position & position () const
 Return the position of the node.
void set_instance_id (const InstanceId &v)
 Set the instance ID.
void set_position (const Position &v)
 Set the node position.
const ConfigNodeIdgenerate_unique_node_id ()
 Generate a new unique node ID.
string str () const
 Convert this node ID from binary form to presentation format.
bool is_empty () const
 Test if the node ID is empty.

Static Public Member Functions

static ConfigNodeId ZERO ()
 Pre-defined constants.

Private Attributes

UniqueNodeId _unique_node_id
Position _position

Detailed Description

Class for encoding and decoding configuration-related node IDs.

The node ID is composed of two uint64_t integers. The first integer is the unique node ID. The second integer is the node positiion and is set to the unique node ID of the previous node. If it is the first node, then the position is set to 0. The upper half of the unique node ID (the most significant 32 bits) is the instance ID. The lower half of the unique node ID (the least significant 32 bits) is the unique part of the node ID for that instance.


Constructor & Destructor Documentation

ConfigNodeId::ConfigNodeId ( const string &  s) throw (InvalidString) [inline, explicit]

Constructor from a string.

The string format is two uint64_t integers separated by space. The first integer is the unique node ID. The second integer is the node positiion and is set to the unique node ID of the previous node. If it is the first node, then the position is set to 0.

Parameters:
sthe initialization string.
ConfigNodeId::ConfigNodeId ( const UniqueNodeId &  unique_node_id,
const Position &  position 
) [inline]

Constructor for a given unique node ID and position.

Parameters:
unique_node_idthe unique node ID.
positionthe position of the node.

Member Function Documentation

size_t ConfigNodeId::copy_in ( const string &  from_string) throw (InvalidString) [inline]

Copy an unique node ID from a string into ConfigNodeId structure.

Parameters:
from_stringthe string to copy the node ID from.
Returns:
the number of copied octets.
const ConfigNodeId & ConfigNodeId::generate_unique_node_id ( ) [inline]

Generate a new unique node ID.

Note that this instance is modified to the value of the new unique node ID.

Returns:
a new unique node ID.
bool ConfigNodeId::is_empty ( ) const [inline]

Test if the node ID is empty.

Returns:
true if the node ID is empty, otherwise false.
bool ConfigNodeId::operator== ( const ConfigNodeId other) const [inline]

Equality Operator.

Parameters:
otherthe right-hand operand to compare against.
Returns:
true if the left-hand operand is numerically same as the right-hand operand.
const Position& ConfigNodeId::position ( ) const [inline]

Return the position of the node.

Returns:
the position of the node.
void ConfigNodeId::set_instance_id ( const InstanceId &  v) [inline]

Set the instance ID.

Parameters:
vthe instance ID.
void ConfigNodeId::set_position ( const Position &  v) [inline]

Set the node position.

The node position is equal to the unique node ID of the previous node.

Parameters:
vthe node position.
string ConfigNodeId::str ( ) const [inline]

Convert this node ID from binary form to presentation format.

Returns:
C++ string with the human-readable ASCII representation of the node ID.
const UniqueNodeId& ConfigNodeId::unique_node_id ( ) const [inline]

Return the unique node ID.

Returns:
the unique node ID.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations