NodeHandle Class Reference

#include <NodeHandle.h>

Inheritance diagram for NodeHandle:

TransportAddress BrooseHandle GiaNode KademliaNodeHandle

List of all members.


Detailed Description

This class implements a node handle.


It covers the complete node information, like IP-Address, port, NodeKey and some additional flags for Simulation behaviour. The information can be sparse, so parts can be omited by setting the property to an unspecified value.

Author:
Markus Mauch

Sebastian Mies


Public Types

typedef hash_set
< NodeHandle,
hashFcn > 
Set
 a hash_set of NodeHandles

Public Member Functions

 NodeHandle ()
 Constructs an unspecified NodeHandle.
virtual ~NodeHandle ()
 Standard destructor.
 NodeHandle (const NodeHandle &handle)
 Copy constructor.
 NodeHandle (const OverlayKey &key, const IPvXAddress &ip, int port)
 Complete constructor.
bool operator== (const NodeHandle &rhs) const
 compares this NodeHandle to another given NodeHandle
bool operator!= (const NodeHandle &rhs) const
 compares this NodeHandle to another given NodeHandle
bool operator< (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator> (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator<= (const NodeHandle &rhs) const
 compares this to a given NodeHandle
bool operator>= (const NodeHandle &rhs) const
 compares this to a given NodeHandle
NodeHandleoperator= (const NodeHandle &rhs)
 assigns key, ip and port of rhs to this->key, this->ip and this->port
void setKey (const OverlayKey &key)
 saves given key to NodeHandle::key
const OverlayKeygetKey () const
 returns key of this NodeHandle
bool isUnspecified () const
 indicates if this NodeHandle is specified
virtual void netPack (cCommBuffer *b)
 serializes the object into a buffer
virtual void netUnpack (cCommBuffer *b)
 deserializes the object from a buffer

Public Attributes

OverlayKey key
 the OverlayKey of this NodeHandle

Static Public Attributes

static const NodeHandle UNSPECIFIED_NODE
 the unspecified NodeHandle

Private Member Functions

void assertUnspecified (const NodeHandle &handle) const
 throws an opp_error if this or handle is unspecified

Friends

std::ostream & operator<< (std::ostream &os, const NodeHandle &n)
 standard output stream for NodeHandle, gives out ip, port and key

Member Typedef Documentation

typedef hash_set<NodeHandle, hashFcn> NodeHandle::Set

a hash_set of NodeHandles

Reimplemented from TransportAddress.


Constructor & Destructor Documentation

NodeHandle::NodeHandle (  ) 

Constructs an unspecified NodeHandle.

00044 {
00045     port = -1;
00046     key = OverlayKey::UNSPECIFIED_KEY;
00047 }

virtual NodeHandle::~NodeHandle (  )  [inline, virtual]

Standard destructor.

00071 {};

NodeHandle::NodeHandle ( const NodeHandle handle  ) 

Copy constructor.

Parameters:
handle The NodeHandle to copy
00051 {
00052     key = handle.key;
00053     port = handle.port;
00054     ip = handle.ip;
00055 }

NodeHandle::NodeHandle ( const OverlayKey key,
const IPvXAddress &  ip,
int  port 
)

Complete constructor.

Parameters:
key The OverlayKey
ip The IPvXAddress
port The UDP-Port
00061 {
00062     this->ip = ip;
00063     this->port = port;
00064     this->key = key;
00065 }


Member Function Documentation

bool NodeHandle::operator== ( const NodeHandle rhs  )  const

compares this NodeHandle to another given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if OverlayKey, IPvXAddress and port is equal, false otherwise
00085 {
00086     assertUnspecified( rhs );
00087     return ( this->key == rhs.key &&
00088              this->ip == rhs.ip && this->port == rhs.port );
00089 }

bool NodeHandle::operator!= ( const NodeHandle rhs  )  const

compares this NodeHandle to another given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if OverlayKey, IPvXAddress and port is not equal, false otherwise
00093 {
00094     assertUnspecified( rhs );
00095     return !( this->key == rhs.key &&
00096               this->ip == rhs.ip && this->port == rhs.port );
00097 }

bool NodeHandle::operator< ( const NodeHandle rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is smaller than rhs->key, false otherwise
00101 {
00102     assertUnspecified(rhs);
00103     return this->key < rhs.key;
00104 }

bool NodeHandle::operator> ( const NodeHandle rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is greater than rhs->key, false otherwise
00108 {
00109     assertUnspecified(rhs);
00110     return this->key > rhs.key;
00111 }

bool NodeHandle::operator<= ( const NodeHandle rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is smaller than or equal to rhs->key, false otherwise
00115 {
00116     assertUnspecified(rhs);
00117     return this->key <= rhs.key;
00118 }

bool NodeHandle::operator>= ( const NodeHandle rhs  )  const

compares this to a given NodeHandle

Parameters:
rhs the NodeHandle this is compared to
Returns:
true if this->key is greater than or equal to rhs->key, false otherwise
00122 {
00123     assertUnspecified(rhs);
00124     return this->key >= rhs.key;
00125 }

NodeHandle & NodeHandle::operator= ( const NodeHandle rhs  ) 

assigns key, ip and port of rhs to this->key, this->ip and this->port

Parameters:
rhs the NodeHandle with the defined key, ip and port
Returns:
this NodeHandle object

Reimplemented in GiaNode.

00075 {
00076     this->key = rhs.key;
00077     this->ip = rhs.ip;
00078     this->port = rhs.port;
00079 
00080     return *this;
00081 }

void NodeHandle::setKey ( const OverlayKey key  ) 

saves given key to NodeHandle::key

Parameters:
key the given key
00129 {
00130     this->key = key;
00131 }

const OverlayKey & NodeHandle::getKey (  )  const

returns key of this NodeHandle

Returns:
the key of this NodeHandle
00135 {
00136     return key;
00137 }

bool NodeHandle::isUnspecified (  )  const

indicates if this NodeHandle is specified

Returns:
true, if NodeHandle has no ip or key specified, false otherwise

Reimplemented from TransportAddress.

00069 {
00070     return (ip.isUnspecified() || key.isUnspecified());
00071 }

void NodeHandle::assertUnspecified ( const NodeHandle handle  )  const [inline, private]

throws an opp_error if this or handle is unspecified

Parameters:
handle the NodeHandle to check
00142 {
00143     if ( this->isUnspecified() || handle.isUnspecified() )
00144         opp_error("NodeHandle: Trying to compare unspecified NodeHandle!");
00145 }

void NodeHandle::netPack ( cCommBuffer *  b  )  [virtual]

serializes the object into a buffer

Parameters:
b the buffer

Reimplemented from TransportAddress.

00189 {
00190     //cMessage::netPack(b);
00191     doPacking(b,this->ip);
00192     doPacking(b,this->key);
00193     doPacking(b,this->port);
00194 }

void NodeHandle::netUnpack ( cCommBuffer *  b  )  [virtual]

deserializes the object from a buffer

Parameters:
b the buffer

Reimplemented from TransportAddress.

00197 {
00198     //cMessage::netUnpack(b);
00199     doUnpacking(b,this->ip);
00200     doUnpacking(b,this->key);
00201     doUnpacking(b,this->port);
00202 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const NodeHandle n 
) [friend]

standard output stream for NodeHandle, gives out ip, port and key

Parameters:
os the ostream
n the NodeHandle
Returns:
the output stream
00031 {
00032     if (n.isUnspecified()) {
00033         os << "<unspec>";
00034     } else {
00035         os << n.ip << ":" << n.port << " " << n.key;
00036     }
00037 
00038     return os;
00039 };


Member Data Documentation

OverlayKey NodeHandle::key

the OverlayKey of this NodeHandle

const NodeHandle NodeHandle::UNSPECIFIED_NODE [static]

the unspecified NodeHandle

Reimplemented from TransportAddress.

Reimplemented in BrooseHandle, and GiaNode.


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:29 2008 for ITM OverSim by  doxygen 1.5.3