Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
RobotRaconteur::NodeID Class Reference

NodeID UUID storage and generation. More...

#include <NodeID.h>

Inheritance diagram for RobotRaconteur::NodeID:
RobotRaconteur::RRObject

Public Member Functions

 NodeID ()
 Construct a new NodeID with "any" node UUID.
 NodeID (boost::array< uint8_t, 16 > id)
 Construct a new NodeID with the specified UUID bytes.
 NodeID (boost::uuids::uuid id)
 Construct a new NodeID with the specified boost::uuids::uuid.
 NodeID (const NodeID &id)
 Copy construct a new NodeID.
 NodeID (boost::string_ref id)
 Construct a new NodeID parsing a string UUID.
const boost::array< uint8_t, 16 > ToByteArray () const
 Convert the NodeID UUID to bytes.
virtual std::string ToString () const
 Convert the NodeID UUID to string with "B" format.
virtual std::string ToString (boost::string_ref format) const
 Convert the NodeID UUID to specified format.
bool operator== (const NodeID &id2) const
 Test if NodeID is equal.
bool operator!= (const NodeID &id2) const
 Test if NodeID is not equal.
NodeIDoperator= (const NodeID &id)
 Assignment operator.
bool IsAnyNode () const
 Is the NodeID UUID all zeros.
RR_OVIRTUAL std::string RRType () RR_OVERRIDE
 Gets the type of the object as a string. This string is in C++ format, using two colons to separate namespaces instead of dots.

Static Public Member Functions

static NodeID NewUniqueID ()
 Generate a new random NodeID UUID.
static NodeID GetAny ()
 Get the "any" NodeId.

Detailed Description

NodeID UUID storage and generation.

Robot Raconteur uses NodeID and NodeName to uniquely identify a node. NodeID is a UUID (Universally Unique ID), while NodeName is a string. The NodeID is expected to be unique, while the NodeName is set by the user and may not be unique. The NodeID class represents the UUID NodeID.

A UUID is a 128-bit randomly generated number that is statistically guaranteed to be unique to a very high probability. NodeID uses the Boost.UUID library to generate, manage, and store the UUID.

The UUID can be loaded from a string, bytes, or generated randomly at runtime. It can be converted to a string.

The LocalTransport and ServerNodeSetup classes will automatically assign a NodeID to a node when the local transport is started with a specified node name. The generated NodeID is stored on the local system, and is associated with the node name. It will be loaded when a node is started with the same NodeName.

NodeID with all zeros is considered "any" node.

Constructor & Destructor Documentation

◆ NodeID() [1/4]

RobotRaconteur::NodeID::NodeID ( boost::array< uint8_t, 16 > id)

Construct a new NodeID with the specified UUID bytes.

Parameters
idThe UUID bytes

◆ NodeID() [2/4]

RobotRaconteur::NodeID::NodeID ( boost::uuids::uuid id)

Construct a new NodeID with the specified boost::uuids::uuid.

Parameters
idThe UUID

◆ NodeID() [3/4]

RobotRaconteur::NodeID::NodeID ( const NodeID & id)

Copy construct a new NodeID.

Parameters
id

◆ NodeID() [4/4]

RobotRaconteur::NodeID::NodeID ( boost::string_ref id)

Construct a new NodeID parsing a string UUID.

Parameters
idThe UUID as a string

Member Function Documentation

◆ GetAny()

NodeID RobotRaconteur::NodeID::GetAny ( )
static

Get the "any" NodeId.

Returns
NodeID The "any" NodeID

◆ IsAnyNode()

bool RobotRaconteur::NodeID::IsAnyNode ( ) const

Is the NodeID UUID all zeros.

The all zero UUID respresents "any" node, or an unset NodeID

Returns
true The NodeID UUID is all zeros, representing any node
false The NodeID UUID is not all zeros

◆ NewUniqueID()

NodeID RobotRaconteur::NodeID::NewUniqueID ( )
static

Generate a new random NodeID UUID.

Returned UUID is statistically guaranteed to be unique

Returns
NodeID The newly generated UUID

◆ RRType()

RR_OVIRTUAL std::string RobotRaconteur::NodeID::RRType ( )
inlinevirtual

Gets the type of the object as a string. This string is in C++ format, using two colons to separate namespaces instead of dots.

Returns
std::string

Implements RobotRaconteur::RRObject.

◆ ToByteArray()

const boost::array< uint8_t, 16 > RobotRaconteur::NodeID::ToByteArray ( ) const

Convert the NodeID UUID to bytes.

Returns
const boost::array<uint8_t,16> The UUID as bytes

◆ ToString() [1/2]

virtual std::string RobotRaconteur::NodeID::ToString ( ) const
virtual

Convert the NodeID UUID to string with "B" format.

Convert the UUID string to 8-4-4-4-12 "B" format (with brackets)

{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
Returns
std::string

◆ ToString() [2/2]

virtual std::string RobotRaconteur::NodeID::ToString ( boost::string_ref format) const
virtual

Convert the NodeID UUID to specified format.

Format may either be "B" for the 8-4-4-4-12 UUID with brackets, "D" for the 8-4-4-4-12 UUID without brackets, or "N" for 32 UUID format with no dashes or brackets

"B" format:

{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

"D" format:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

"N" format:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Parameters
format"B", "D", or "N" for the format
Returns
std::string

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