XSocket API  2.0
XIA Socket Library
Data Structures | Public Member Functions | Static Public Attributes
Node Class Reference

Class defining XIDs that are used by the Graph class.

#include <dagaddr.hpp>

Public Member Functions

 Node ()
 Create a new empty node. More...
 
 Node (const Node &r)
 Create a copy of a node. More...
 
 Node (uint32_t type, const void *id, int dummy)
 
 Node (int type, const std::string id_string)
 Create a new node from a type and an XID string. More...
 
 Node (const std::string type_string, const std::string id_string)
 Create a new node from a type string and an XID string. More...
 
 Node (const std::string node_string)
 Create a new node from a single string. More...
 
 ~Node ()
 
const uint32_t & type () const
 
const unsigned char * id () const
 
std::string type_string () const
 Return the node's type as a string. More...
 
std::string id_string () const
 Get the node's XID as a string. More...
 
std::string to_string () const
 Return a string representing the node. More...
 
bool has_valid_xid () const
 Check if the XID represented by this node is valid. More...
 
Nodeoperator= (const Node &r)
 
bool operator== (const Node &r) const
 
bool operator!= (const Node &r) const
 
Graph operator* (const Node &r) const
 Make a graph by appending a node. More...
 
Graph operator* (const Graph &r) const
 Make a graph by appending a graph. More...
 
Graph operator+ (const Node &r) const
 Make a graph by merging with a node. More...
 
Graph operator+ (const Graph &r) const
 Make a graph by merging with a graph. More...
 
bool equal_to (const Node &r) const
 

Static Public Attributes

static const std::size_t ID_LEN = 20
 
static const std::string XID_TYPE_UNKNOWN_STRING = "UNKNOWN"
 
static const std::string XID_TYPE_DUMMY_SOURCE_STRING = "SOURCE"
 
static const std::string XID_TYPE_AD_STRING = "AD"
 
static const std::string XID_TYPE_HID_STRING = "HID"
 
static const std::string XID_TYPE_CID_STRING = "CID"
 
static const std::string XID_TYPE_SID_STRING = "SID"
 
static const std::string XID_TYPE_FID_STRING = "FID"
 
static const std::string XID_TYPE_IP_STRING = "IP"
 

Constructor & Destructor Documentation

Node::Node ( )

Create a new empty node with type XID_TYPE_DUMMY_SOURCE and id 0. This is commonly used to create the "dummy" source node.

Node::Node ( const Node r)

Create a new node that is a copy of the supplied node.

Parameters
rThe node to be copied.
Node::Node ( uint32_t  type,
const void *  id,
int  dummy 
)
Node::Node ( int  type,
const std::string  id_str 
)

Create a new DAG node from a principal type and an XID (as a string).

Parameters
typeThe node's principal type. Must be one of:
Node::XID_TYPE_AD (Administrative Domain)
Node::XID_TYPE_HID (Host)
Node::XID_TYPE_CID (Content)
Node::XID_TYPE_SID (Service)
Node::XID_TYPE_FID (Flood)
Node::XID_TYPE_IP (IPv4 / 4ID)
id_strThe node's XID as a string. This should be 20 pairs of two characters; each pair of characters is the ASCII representation of one byte of the XID in hex.
Node::Node ( const std::string  type_str,
const std::string  id_str 
)

Create a new DAG node from a principal type (as a string) and an XID (as a string).

Parameters
type_strThe node's prinicipal type (as a string). Must be one of:
Node::XID_TYPE_AD_STRING
Node::XID_TYPE_HID_STRING
Node::XID_TYPE_CID_STRING
Node::XID_TYPE_SID_STRING
Node::XID_TYPE_FID_STRING
Node::XID_TYPE_IP_STRING
id_strThe node's XID as a string. This should be 20 pairs of two characters; each pair of characters is the ASCII representation of one byte of the XID in hex.
Node::Node ( const std::string  node_string)

Create a new node from a single string with the format <type>:<id>. Examples:
AD:1234567890123456789012345678901234567890
CID:0000011111222223333344444555556666677777

Parameters
node_string
Node::~Node ( )

Member Function Documentation

bool Node::equal_to ( const Node r) const
bool Node::has_valid_xid ( ) const
Returns
true if node has a valid XID, false otherwise
const unsigned char* Node::id ( ) const
inline
std::string Node::id_string ( ) const

Get the node's XID as a std::string. This string will be 40 characters long (representing 20 bytes in hex). The string does not include the principal type prefix (e.g., "HID:").

Returns
The node's XID as a string
bool Node::operator!= ( const Node r) const
inline
Graph Node::operator* ( const Node r) const
inline

Make a graph by appending a node to this node. The resulting graph will have one edge from this node to the supplied node.

Parameters
rThe node to append
Returns
The resulting graph
Graph Node::operator* ( const Graph r) const
inline

Make a graph by appending an existing graph to this node. The resulting graph will have an edge from this node to the source node of the supplied one. The edges of the supplied graph will not be affected.

Parameters
rThe graph to append
Returns
The resulting graph
Graph Node::operator+ ( const Node r) const
inline

Make a graph by merging this node with another node. If the nodes are equal, the resulting graph will contain one node and no edges. Otherwise, the resulting graph will contain two nodes and no edges. Each node will be both a source and a sink.

Parameters
rThe node with which to merge
Returns
The resulting graph
Graph Node::operator+ ( const Graph r) const
inline

Make a graph by merging this node with the supplied graph. If the node is already present in this graph, the resulting graph will be the same as the supplied graph. If the node is different, this node will be added to the graph but will not be connected by any edges.

Parameters
rThe graph with which to merge
Returns
The resulting graph
Node & Node::operator= ( const Node r)
bool Node::operator== ( const Node r) const
inline
std::string Node::to_string ( ) const
Returns
A string of the form <type>:<id>
const uint32_t& Node::type ( ) const
inline
std::string Node::type_string ( ) const

The type string will either be one of the following built-in XID types or will match one of the entries in etc/xids.
Node::XID_TYPE_AD_STRING
Node::XID_TYPE_HID_STRING
Node::XID_TYPE_CID_STRING
Node::XID_TYPE_SID_STRING
Node::XID_TYPE_FID_STRING
Node::XID_TYPE_IP_STRING
Node::XID_TYPE_DUMMY_SOURCE
Node:: ID_TYPE_UNKNOWN_STRING

Returns
the node's type as a string

Field Documentation

const std::size_t Node::ID_LEN = 20
static
const std::string Node::XID_TYPE_AD_STRING = "AD"
static
const std::string Node::XID_TYPE_CID_STRING = "CID"
static
const std::string Node::XID_TYPE_DUMMY_SOURCE_STRING = "SOURCE"
static
const std::string Node::XID_TYPE_FID_STRING = "FID"
static
const std::string Node::XID_TYPE_HID_STRING = "HID"
static
const std::string Node::XID_TYPE_IP_STRING = "IP"
static
const std::string Node::XID_TYPE_SID_STRING = "SID"
static
const std::string Node::XID_TYPE_UNKNOWN_STRING = "UNKNOWN"
static

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