Collage  0.6.1
Classes | Public Member Functions | Protected Member Functions | Friends
co::Node Class Reference

Manages a node. More...

#include <node.h>

+ Inheritance diagram for co::Node:
+ Collaboration diagram for co::Node:

List of all members.

Classes

struct  MCData

Public Member Functions

CO_API Node ()
 Construct a new Node.
const NodeIDgetNodeID () const
CO_API std::string serialize () const
 Serialize the node's information.
CO_API bool deserialize (std::string &data)
 Deserialize the node information, consumes given data.
int64_t getLastReceiveTime () const
virtual uint32_t getType () const
Data Access.
bool operator== (const Node *n) const
bool isConnected () const
bool isClosed () const
bool isListening () const
Connectivity information.
bool isLocal () const
CO_API void addConnectionDescription (ConnectionDescriptionPtr cd)
 Adds a new description how this node can be reached.
CO_API bool removeConnectionDescription (ConnectionDescriptionPtr cd)
 Removes a connection description.
CO_API ConnectionDescriptions getConnectionDescriptions () const
ConnectionPtr getConnection () const
ConnectionPtr useMulticast ()
Messaging API
bool send (const Packet &packet)
 Sends a packet to this node.
bool send (Packet &packet, const std::string &string)
 Sends a packet with a string to the node.
template<class T >
bool send (Packet &packet, const std::vector< T > &data)
 Sends a packet with additional data to the node.
bool send (Packet &packet, const void *data, const uint64_t size)
 Sends a packet with additional data to the node.
bool multicast (const Packet &packet)
 Multicasts a packet to the multicast group of this node.

Protected Member Functions

virtual CO_API ~Node ()
 Destructs this node.
virtual CO_API NodePtr createNode (const uint32_t type)
 Factory method to create a new node.

Friends

class LocalNode
CO_API std::ostream & operator<< (std::ostream &os, const Node &node)
CO_API std::ostream & operator<< (std::ostream &, const State)

Detailed Description

Manages a node.

A node represents a separate entity in a peer-to-peer network, typically a process on a cluster node or on a shared-memory system. It should have at least one Connection through which is reachable. A Node provides the basic communication facilities through message passing.

Definition at line 40 of file node.h.


Constructor & Destructor Documentation

CO_API co::Node::Node ( )

Construct a new Node.

virtual CO_API co::Node::~Node ( ) [protected, virtual]

Destructs this node.


Member Function Documentation

Adds a new description how this node can be reached.

Parameters:
cdthe connection description.
virtual CO_API NodePtr co::Node::createNode ( const uint32_t  type) [protected, virtual]

Factory method to create a new node.

Parameters:
typethe type the node type
Returns:
the node.
See also:
getType()
CO_API bool co::Node::deserialize ( std::string &  data)

Deserialize the node information, consumes given data.

Returns:
the connection to this node.

Definition at line 81 of file node.h.

Returns:
the number of stored connection descriptions.
int64_t co::Node::getLastReceiveTime ( ) const [inline]
Returns:
last receive time.

Definition at line 195 of file node.h.

virtual uint32_t co::Node::getType ( ) const [inline, virtual]
Returns:
the type of the node, used during connect().

Definition at line 198 of file node.h.

References co::NODETYPE_CO_NODE.

bool co::Node::isLocal ( ) const [inline]
Returns:
true if the node is local (listening), false otherwise.

Definition at line 59 of file node.h.

bool co::Node::multicast ( const Packet packet) [inline]

Multicasts a packet to the multicast group of this node.

Parameters:
packetthe packet.
Returns:
the success status of the transaction.

Definition at line 178 of file node.h.

References useMulticast().

+ Here is the call graph for this function:

Removes a connection description.

Parameters:
cdthe connection description.
Returns:
true if the connection description was removed, false otherwise.
bool co::Node::send ( const Packet packet) [inline]

Sends a packet to this node.

Parameters:
packetthe packet.
Returns:
the success status of the transaction.

Definition at line 95 of file node.h.

bool co::Node::send ( Packet packet,
const std::string &  string 
) [inline]

Sends a packet with a string to the node.

The data is send as a new packet containing the original packet and the string, so that it is received as one packet by the node.

It is assumed that the last 8 bytes in the packet are usable for the string. This is used for optimising the send of short strings and on the receiver side to access the string. The node implementation gives examples of this usage.

Parameters:
packetthe packet.
stringthe string.
Returns:
the success status of the transaction.

Definition at line 118 of file node.h.

template<class T >
bool co::Node::send ( Packet packet,
const std::vector< T > &  data 
) [inline]

Sends a packet with additional data to the node.

The data is send as a new packet containing the original packet and the string, so that it is received as one packet by the node.

It is assumed that the last item in the packet is of sizeof(T) and usable for the data.

Parameters:
packetthe packet.
datathe vector containing the data.
Returns:
the success status of the transaction.

Definition at line 140 of file node.h.

bool co::Node::send ( Packet packet,
const void *  data,
const uint64_t  size 
) [inline]

Sends a packet with additional data to the node.

The data is send as a new packet containing the original packet and the data, so that it is received as one packet by the node.

It is assumed that the last 8 bytes in the packet are usable for the data. This is used for optimising the send of short data and on the receiver side to access the data. The node implementation gives examples of this usage.

Parameters:
packetthe packet.
datathe data.
sizethe size of the data in bytes.
Returns:
the success status of the transaction.

Definition at line 164 of file node.h.

CO_API std::string co::Node::serialize ( ) const

Serialize the node's information.

Returns:
the multicast connection to this node, or 0.

Referenced by multicast().

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file:
Generated on Mon Nov 26 2012 14:41:44 for Collage 0.6.1 by  doxygen 1.7.6.1