Equalizer 1.0
|
Manages a node. More...
#include <node.h>
Classes | |
struct | MCData |
Public Member Functions | |
CO_API | Node () |
Construct a new Node. | |
const NodeID & | getNodeID () 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. | |
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 | getMulticast () |
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 uint32_t | getType () const |
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) |
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 include/co/node.h.
CO_API co::Node::Node | ( | ) |
Construct a new Node.
virtual CO_API co::Node::~Node | ( | ) | [protected, virtual] |
Destructs this node.
CO_API void co::Node::addConnectionDescription | ( | ConnectionDescriptionPtr | cd | ) |
Adds a new description how this node can be reached.
cd | the connection description. |
virtual CO_API NodePtr co::Node::createNode | ( | const uint32_t | type | ) | [protected, virtual] |
Factory method to create a new node.
type | the type the node type |
CO_API bool co::Node::deserialize | ( | std::string & | data | ) |
Deserialize the node information, consumes given data.
ConnectionPtr co::Node::getConnection | ( | ) | const [inline] |
Definition at line 84 of file include/co/node.h.
CO_API ConnectionDescriptions co::Node::getConnectionDescriptions | ( | ) | const |
ConnectionPtr co::Node::getMulticast | ( | ) |
Referenced by multicast().
virtual uint32_t co::Node::getType | ( | ) | const [inline, protected, virtual] |
Definition at line 202 of file include/co/node.h.
References co::NODETYPE_CO_NODE.
bool co::Node::isLocal | ( | ) | const [inline] |
Definition at line 62 of file include/co/node.h.
bool co::Node::multicast | ( | const Packet & | packet | ) | [inline] |
Multicasts a packet to the multicast group of this node.
packet | the packet. |
Definition at line 181 of file include/co/node.h.
References getMulticast().
CO_API bool co::Node::removeConnectionDescription | ( | ConnectionDescriptionPtr | cd | ) |
Removes a connection description.
cd | the connection description. |
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.
packet | the packet. |
data | the vector containing the data. |
Definition at line 143 of file include/co/node.h.
bool co::Node::send | ( | const Packet & | packet | ) | [inline] |
Sends a packet to this node.
packet | the packet. |
Definition at line 98 of file include/co/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.
packet | the packet. |
string | the string. |
Definition at line 121 of file include/co/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.
packet | the packet. |
data | the data. |
size | the size of the data in bytes. |
Definition at line 167 of file include/co/node.h.
CO_API std::string co::Node::serialize | ( | ) | const |
Serialize the node's information.