Collage
1.7.0
High-performance C++ library for developing object-oriented distributed applications.
|
Proxy node representing a remote LocalNode. More...
#include <node.h>
Public Member Functions | |
CO_API | Node (const uint32_t type=co::NODETYPE_NODE) |
Construct a new node proxy. More... | |
CO_API int64_t | getLastReceiveTime () const |
CO_API std::string | serialize () const |
CO_API bool | deserialize (std::string &data) |
Data Access | |
CO_API const NodeID & | getNodeID () const |
Get the node's unique identifier. More... | |
CO_API uint32_t | getType () const |
bool | operator== (const Node *n) const |
CO_API bool | isReachable () const |
CO_API bool | isConnected () const |
CO_API bool | isListening () const |
CO_API bool | isClosed () const |
CO_API bool | isClosing () const |
Connectivity information | |
bool | isLocal () const |
CO_API void | addConnectionDescription (ConnectionDescriptionPtr cd) |
Add a new description how this node can be reached. More... | |
CO_API bool | removeConnectionDescription (ConnectionDescriptionPtr cd) |
Removes a connection description. More... | |
CO_API ConnectionDescriptions | getConnectionDescriptions () const |
CO_API ConnectionPtr | getConnection (const bool multicast=false) |
Get an active connection to this node. More... | |
Messaging API | |
CO_API OCommand | send (const uint32_t cmd, const bool multicast=false) |
Send a command with optional data to the node. More... | |
CO_API CustomOCommand | send (const uint128_t &commandID, const bool multicast=false) |
Send a custom command with optional data to the node. More... | |
Launch parameters | |
CO_API void | setHostname (const std::string &host) |
Set the host name for the launch command. More... | |
CO_API const std::string & | getHostname () const |
virtual CO_API std::string | getWorkDir () const |
virtual CO_API std::string | getLaunchQuote () const |
Public Member Functions inherited from co::Dispatcher | |
Dispatcher & | operator= (const Dispatcher &) |
template<typename T > | |
void | registerCommand (const uint32_t command, const CommandFunc< T > &func, CommandQueue *queue) |
Register a command member function for a command. More... | |
virtual CO_API bool | dispatchCommand (ICommand &command) |
Dispatch a command from the receiver thread to the registered queue. More... | |
Protected Member Functions | |
virtual CO_API | ~Node () |
Destruct this node. More... | |
void | _addConnectionDescription (ConnectionDescriptionPtr cd) |
bool | _removeConnectionDescription (ConnectionDescriptionPtr cd) |
ConnectionPtr | _getMulticast () const |
ConnectionPtr | getMulticast () |
Activate and return a multicast connection. More... | |
Protected Member Functions inherited from co::Dispatcher | |
CO_API | Dispatcher (const Dispatcher &from) |
CO_API bool | _cmdUnknown (ICommand &command) |
The default handler for handling commands. More... | |
Friends | |
CO_API friend std::ostream & | operator<< (std::ostream &, const Node &) |
class | LocalNode |
Additional Inherited Members | |
Public Types inherited from co::Dispatcher | |
typedef CommandFunc< Dispatcher > | Func |
The signature of the base Dispatcher callback. More... | |
Proxy node representing a remote LocalNode.
A node represents a separate entity in a peer-to-peer network, typically a process on another machine. It should have at least one Connection through which is reachable. A Node provides the basic communication facilities through message passing.
|
explicit |
Construct a new node proxy.
type | the type of the node, used during connect(). |
|
protectedvirtual |
Destruct this node.
CO_API void co::Node::addConnectionDescription | ( | ConnectionDescriptionPtr | cd | ) |
Add a new description how this node can be reached.
The node has to be closed.
cd | the connection description. |
CO_API ConnectionPtr co::Node::getConnection | ( | const bool | multicast = false | ) |
Get an active connection to this node.
multicast | if true, prefer a multicast connection. |
CO_API ConnectionDescriptions co::Node::getConnectionDescriptions | ( | ) | const |
CO_API const std::string& co::Node::getHostname | ( | ) | const |
|
virtual |
|
protected |
Activate and return a multicast connection.
Multicast connections are activated lazily on first use, since they trigger the creation of the remote local node proxies on all members of the multicast group.
CO_API const NodeID& co::Node::getNodeID | ( | ) | const |
Get the node's unique identifier.
In rare cases (two nodes initiate a two-sided LocalNode::connect()) to each other, two node instances with the same identifier might exist temporarily during the connection handshake.
CO_API uint32_t co::Node::getType | ( | ) | const |
|
virtual |
CO_API bool co::Node::isClosed | ( | ) | const |
CO_API bool co::Node::isClosing | ( | ) | const |
CO_API bool co::Node::isConnected | ( | ) | const |
CO_API bool co::Node::isListening | ( | ) | const |
|
inline |
Definition at line 94 of file node.h.
References co::deserialize(), and co::serialize().
CO_API bool co::Node::isReachable | ( | ) | const |
CO_API bool co::Node::removeConnectionDescription | ( | ConnectionDescriptionPtr | cd | ) |
Removes a connection description.
The node has to be closed.
cd | the connection description. |
CO_API OCommand co::Node::send | ( | const uint32_t | cmd, |
const bool | multicast = false |
||
) |
Send a command with optional data to the node.
The returned command can be used to pass additional data. The data will be send after the command object is destroyed, aka when it is running out of scope. Thread safe.
cmd | the node command to execute. |
multicast | prefer multicast connection for sending. |
CO_API CustomOCommand co::Node::send | ( | const uint128_t & | commandID, |
const bool | multicast = false |
||
) |
Send a custom command with optional data to the node.
The command handler for this command being send is registered with the remote LocalNode::registerCommandHandler().
The returned command can be used to pass additional data. The data will be send after the command object is destroyed, aka when it is running out of scope. Thread safe.
commandID | the ID of the registered custom command. |
multicast | prefer multicast connection for sending. |
CO_API void co::Node::setHostname | ( | const std::string & | host | ) |
Set the host name for the launch command.