Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
RobotRaconteur::RobotRaconteurNode Class Reference

The central node implementation. More...

#include <RobotRaconteurNode.h>

Classes

class  ScopedMonitorLock
 Wrapper for RobotRaconteurNode::MonitorEnter() and RobotRaconteurNode::MonitorExit() to take advantage of RAII scoping. More...

Public Types

typedef boost::signals2::connection shutdown_listener_connection
 signals2 connection type for AddShutdownListener()
typedef boost::signals2::connection node_updated_listener_connection
 The boost::signals2 connection type for AddNodeServicesDetectedListener.
typedef boost::signals2::connection node_lost_listener_connection
 The boost::signals2 connection type for AddNodeDetectionLostListener.

Public Member Functions

void Init ()
 Initialize the node. Called automatically for s() and sp().
 RobotRaconteurNode ()
 Construct a new Robot Raconteur Node object.
RobotRaconteur::NodeID NodeID ()
 Get the current NodeID.
std::string NodeName ()
 Get the current NodeName.
void SetNodeID (const RobotRaconteur::NodeID &id)
 Set the NodeID.
void SetNodeName (boost::string_ref name)
 Set the NodeName.
bool TryGetNodeID (RobotRaconteur::NodeID &id)
 Tries getting the current NodeID.
bool TryGetNodeName (std::string &node_name)
 Tries getting the current NodeName.
boost::shared_ptr< ServiceFactoryGetServiceType (boost::string_ref type)
 Returns a previously registered service type.
bool IsServiceTypeRegistered (boost::string_ref servicetype)
 Check if a service type has been registered.
void RegisterServiceType (const boost::shared_ptr< ServiceFactory > &factory)
 Register a service type.
void UnregisterServiceType (boost::string_ref type)
 Unregister a previously registered service type.
std::vector< std::string > GetRegisteredServiceTypes ()
 Return names of registered service types.
virtual void Shutdown ()
 Shuts down the node. Called automatically by ClientNodeSetup and ServerNodeSetup.
template<typename Handler>
shutdown_listener_connection AddShutdownListener (BOOST_ASIO_MOVE_ARG(Handler) h)
 Adds a shutdown listener.
uint32_t RegisterTransport (const boost::shared_ptr< Transport > &transport)
 Register a transport for use by the node.
uint32_t GetRequestTimeout ()
 Get the timeout for requests in milliseconds.
void SetRequestTimeout (uint32_t timeout)
 Set the timeout for requests in milliseconds.
uint32_t GetTransportInactivityTimeout ()
 Get the timeout for transport activity in milliseconds.
void SetTransportInactivityTimeout (uint32_t timeout)
 Set the timeout for transport activity in milliseconds.
uint32_t GetEndpointInactivityTimeout ()
 Get the timeout for endpoint activity in milliseconds.
void SetEndpointInactivityTimeout (uint32_t timeout)
 Set the timeout for endpoint activity in milliseconds.
uint32_t GetMemoryMaxTransferSize ()
 Get the maximum chunk size for memory transfers in bytes.
void SetMemoryMaxTransferSize (uint32_t size)
 Set the maximum chunk size for memory transfers in bytes.
const boost::shared_ptr< RobotRaconteur::DynamicServiceFactoryGetDynamicServiceFactory ()
 Get the current DynamicServiceFactory. May be null.
void SetDynamicServiceFactory (const boost::shared_ptr< RobotRaconteur::DynamicServiceFactory > &f)
 Set the DynamicServicefactory.
boost::shared_ptr< ServerContext > RegisterService (boost::string_ref name, boost::string_ref servicetype, const boost::shared_ptr< RRObject > &obj, const boost::shared_ptr< ServiceSecurityPolicy > &securitypolicy=boost::shared_ptr< ServiceSecurityPolicy >())
 Registers a service for clients to connect.
boost::shared_ptr< ServerContext > RegisterService (const boost::shared_ptr< ServerContext > &c)
 Registers a service using a previously instantiated ServerContext.
void CloseService (boost::string_ref sname)
 Closes a previously registered service.
std::vector< std::string > GetRegisteredServiceNames ()
 Get the names of registered services.
boost::shared_ptr< ServerContext > GetService (boost::string_ref name)
 Gets a ServerContext for a service by name.
boost::shared_ptr< RRObjectConnectService (boost::string_ref url, boost::string_ref username="", const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials=(boost::intrusive_ptr< RRMap< std::string, RRValue > >()), boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener=0, boost::string_ref objecttype="")
 Create a client connection to a remote service using a URL.
void AsyncConnectService (boost::string_ref url, boost::string_ref username, const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials, boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener, boost::string_ref objecttype, boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously create a client connection to a remote service using a URL.
boost::shared_ptr< RRObjectConnectService (const std::vector< std::string > &urls, boost::string_ref username="", const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials=(boost::intrusive_ptr< RRMap< std::string, RRValue > >()), boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener=0, boost::string_ref objecttype="")
 Same as ConnectService(), but accepts a vector of candidate URLs.
void AsyncConnectService (const std::vector< std::string > &url, boost::string_ref username, const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials, boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener, boost::string_ref objecttype, boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Same as AsyncConnectService(), but accepts a vector of candidate URLs.
void DisconnectService (const boost::shared_ptr< RRObject > &obj)
 Disconnects a client connection to a service.
void AsyncDisconnectService (const boost::shared_ptr< RRObject > &obj, boost::function< void()> handler)
 Asynchronously disconnects a client connection to a service.
std::map< std::string, boost::intrusive_ptr< RRValue > > GetServiceAttributes (const boost::shared_ptr< RRObject > &obj)
 Get the service attributes of a client connection.
RobotRaconteur::NodeID GetServiceNodeID (const boost::shared_ptr< RRObject > &obj)
 Get the service NodeID of the remote node from a client connection.
std::string GetServiceNodeName (const boost::shared_ptr< RRObject > &obj)
 Get the service NodeName of the remote node from a client connection.
std::string GetServiceName (const boost::shared_ptr< RRObject > &obj)
 Get the name of a service from a client connection.
std::string GetObjectServicePath (const boost::shared_ptr< RRObject > &obj)
 Get the service path of a client object.
virtual std::string GetObjectType (const boost::shared_ptr< RRObject > &obj)
 Get the Robot Raconteur type of a connected service object obj must be returned by ConnectService(), AsyncConnectService(), or an objref.
void CheckConnection (uint32_t endpoint)
 Check that the TransportConnection associated with an endpoint is connected.
std::vector< NodeDiscoveryInfoGetDetectedNodes ()
 Get the nodes currently detected by Transports.
NodeInfo2 GetDetectedNodeCacheInfo (const RobotRaconteur::NodeID &nodeid)
 Get cached node discovery information.
bool TryGetDetectedNodeCacheInfo (const RobotRaconteur::NodeID &nodeid, NodeInfo2 &nodeinfo2)
 Try get cached node discovery information.
template<typename Handler>
node_updated_listener_connection AddNodeServicesDetectedListener (BOOST_ASIO_MOVE_ARG(Handler) h)
 Add a handler to be called when detected services are updated.
template<typename Handler>
node_lost_listener_connection AddNodeDetectionLostListener (BOOST_ASIO_MOVE_ARG(Handler) h)
 Add a handler to be called when a node is no longer detected.
void UpdateDetectedNodes (const std::vector< std::string > &schemes)
 Update the detected nodes cache.
void AsyncUpdateDetectedNodes (const std::vector< std::string > &schemes, boost::function< void()> handler, int32_t timeout=5000)
 Asynchronously update the detected nodes cache.
uint32_t GetNodeDiscoveryMaxCacheCount ()
 Get the maximum number of detected nodes that will be cached.
void SetNodeDiscoveryMaxCacheCount (uint32_t count)
 Set maximum number of detected nodes that will be cached.
boost::shared_ptr< ServiceInfo2SubscriptionSubscribeServiceInfo2 (const std::vector< std::string > &service_types, const boost::shared_ptr< ServiceSubscriptionFilter > &filter=boost::shared_ptr< ServiceSubscriptionFilter >())
 Subscribe to listen for available services information.
boost::shared_ptr< ServiceSubscriptionSubscribeServiceByType (const std::vector< std::string > &service_types, const boost::shared_ptr< ServiceSubscriptionFilter > &filter=boost::shared_ptr< ServiceSubscriptionFilter >())
 Subscribe to listen for available services and automatically connect.
boost::shared_ptr< ServiceSubscriptionSubscribeService (const std::vector< std::string > &url, boost::string_ref username="", const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials=(boost::intrusive_ptr< RRMap< std::string, RRValue > >()), boost::string_ref objecttype="")
 Subscribe to a service using one or more URL. Used to create robust connections to services.
boost::shared_ptr< ServiceSubscriptionSubscribeService (const std::string &url, boost::string_ref username="", const boost::intrusive_ptr< RRMap< std::string, RRValue > > &credentials=(boost::intrusive_ptr< RRMap< std::string, RRValue > >()), boost::string_ref objecttype="")
 Subscribe to a service using a URL. Used to create robust connections to services.
std::vector< ServiceInfo2FindServiceByType (boost::string_ref servicetype, const std::vector< std::string > &transportschemes)
 Use discovery to find available services by service type.
void AsyncFindServiceByType (boost::string_ref servicetype, const std::vector< std::string > &transportschemes, boost::function< void(const boost::shared_ptr< std::vector< ServiceInfo2 > > &)> handler, int32_t timeout=5000)
 Asynchronously use discovery to find availabe services by service type.
std::vector< NodeInfo2FindNodeByID (const RobotRaconteur::NodeID &id, const std::vector< std::string > &transportschemes)
 Finds nodes on the network with a specified NodeID.
void AsyncFindNodeByID (const RobotRaconteur::NodeID &id, const std::vector< std::string > &transportschemes, boost::function< void(const boost::shared_ptr< std::vector< NodeInfo2 > > &)> handler, int32_t timeout=5000)
 Asynchronously finds nodes on the network with the specified NodeID.
std::vector< NodeInfo2FindNodeByName (boost::string_ref name, const std::vector< std::string > &transportschemes)
 Finds nodes on the network with a specified NodeName.
void AsyncFindNodeByName (boost::string_ref name, const std::vector< std::string > &transportschemes, boost::function< void(const boost::shared_ptr< std::vector< NodeInfo2 > > &)> handler, int32_t timeout=5000)
 Asynchronously finds nodes on the network with the specified NodeName.
std::string RequestObjectLock (const boost::shared_ptr< RRObject > &obj, RobotRaconteurObjectLockFlags flags)
 Request an exclusive access lock to a service object.
void AsyncRequestObjectLock (const boost::shared_ptr< RRObject > &obj, RobotRaconteurObjectLockFlags flags, boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously request an exclusive access lock to a service object.
std::string ReleaseObjectLock (const boost::shared_ptr< RRObject > &obj)
 Release an excluse access lock previously locked with RequestObjectLock() or AsyncRequestObjectLock().
void AsyncReleaseObjectLock (const boost::shared_ptr< RRObject > &obj, boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously release an excluse access lock previously locked with RequestObjectLock() or AsyncRequestObjectLock().
void MonitorEnter (const boost::shared_ptr< RRObject > &obj, int32_t timeout=RR_TIMEOUT_INFINITE)
 Creates a monitor lock on a specified object.
void MonitorExit (const boost::shared_ptr< RRObject > &obj)
 Releases a monitor lock.
void AddPeriodicCleanupTask (const boost::shared_ptr< IPeriodicCleanupTask > &task)
 Add a periodic cleanup task.
void RemovePeriodicCleanupTask (const boost::shared_ptr< IPeriodicCleanupTask > &task)
 Remove a task previously registered with AddPeriodicCleanupTask().
boost::shared_ptr< RRObjectFindObjRefTyped (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::string_ref objecttype)
 Returns an objref as a specific type.
boost::shared_ptr< RRObjectFindObjRefTyped (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::string_ref index, boost::string_ref objecttype)
 Returns an indexed objref as a specified type.
void AsyncFindObjRefTyped (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::string_ref objecttype, boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously returns an objref as a specific type.
void AsyncFindObjRefTyped (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::string_ref index, boost::string_ref objecttype, boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously returns an objref as a specific type.
std::string FindObjectType (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref)
 Returns the type of a service object.
std::string FindObjectType (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::string_ref index)
 Returns the type of a service object.
void AsyncFindObjectType (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously returns the type of a service object.
void AsyncFindObjectType (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::string_ref index, boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously returns the type of a service object.
boost::shared_ptr< ThreadPoolGetThreadPool ()
 Get the current ThreadPool for the node.
bool TryGetThreadPool (boost::shared_ptr< ThreadPool > &pool)
 Tries to get the ThreadPool, returns false if the ThreadPool is not available.
void SetThreadPool (const boost::shared_ptr< ThreadPool > &pool)
 Sets the ThreadPool for the node.
boost::shared_ptr< ThreadPoolFactoryGetThreadPoolFactory ()
 Get the current ThreadPoolFactory for the node.
void SetThreadPoolFactory (const boost::shared_ptr< ThreadPoolFactory > &factory)
 Set the ThreadPoolFactory for the node.
int32_t GetThreadPoolCount ()
 Get the number of threads for the node ThreadPool.
void SetThreadPoolCount (int32_t count)
 Set the number of threads for the node ThreadPool.
void ReleaseThreadPool ()
 Shuts down and releases the node thread pool Do not call ReleaseThreadPool unless you really know what you are doing. In most cases it will be destroyed automatically.
std::vector< std::string > GetPulledServiceTypes (const boost::shared_ptr< RRObject > &obj)
 Get the names of service types pulled by a client.
boost::shared_ptr< ServiceFactoryGetPulledServiceType (const boost::shared_ptr< RRObject > &obj, boost::string_ref type)
 Get a ServiceFactory created from a service type pulled by a client.
void SetExceptionHandler (boost::function< void(const std::exception *)> handler)
 Set an exception handler function.
boost::function< void(const std::exception *)> GetExceptionHandler ()
 Get the node's current exception handler, or null.
void HandleException (const std::exception *exp)
 Handle exceptino by passing the current exception to the handler function.
virtual boost::posix_time::ptime NowUTC ()
 The current time in UTC time zone.
virtual TimeSpec NowTimeSpec ()
 The current node time as a TimeSpec.
virtual boost::posix_time::ptime NowNodeTime ()
 The current node time.
virtual boost::posix_time::ptime NodeSyncTimeUTC ()
 The sync time of the node.
virtual TimeSpec NodeSyncTimeSpec ()
 The sync time of the node as a TimeSpec.
virtual boost::shared_ptr< TimerCreateTimer (const boost::posix_time::time_duration &period, boost::function< void(const TimerEvent &)> handler, bool oneshot=false)
 Create a Timer object.
virtual boost::shared_ptr< RateCreateRate (double frequency)
 Create a Rate object.
virtual void Sleep (const boost::posix_time::time_duration &duration)
 Sleeps for a specified duration.
virtual boost::shared_ptr< AutoResetEventCreateAutoResetEvent ()
 Create an AutoResetEvent object.
void DownCastAndThrowException (RobotRaconteurException &exp)
 Downcasts a RobotRaconteurException and throws it.
boost::shared_ptr< RobotRaconteurExceptionDownCastException (const boost::shared_ptr< RobotRaconteurException > &exp)
 Downcasts a RobotRaconteurException.
bool IsEndpointLargeTransferAuthorized (uint32_t endpoint)
 Check if the endpoint is authorized for large message transfer.
std::string GetRobotRaconteurVersion ()
 Get the current RobotRaconteurVersion as a string.
template<typename T>
GetRandomInt (T min, T max)
 Returns a random integer using the node's random number generator.
template<typename T>
std::vector< T > GetRandomInts (size_t count, T min, T max)
 Returns a vector of random integer using the node's random number generator.
std::string GetRandomString (size_t count)
 Generates a random string with the specified character count using the node's random number generator.
bool CompareLogLevel (RobotRaconteur_LogLevel log_level)
 Test if the specified log level would be accepted.
void LogMessage (RobotRaconteur_LogLevel level, const std::string &message)
 Log a simple message using the current node.
void LogRecord (const RRLogRecord &record)
 Log a record to the node. Use the macros specified in Logging.h instead of this function directly.
RobotRaconteur_LogLevel GetLogLevel ()
 Get the current log level for the node.
void SetLogLevel (RobotRaconteur_LogLevel level)
 Set the log level for the node.
RobotRaconteur_LogLevel SetLogLevelFromString (boost::string_ref level)
 Set the log level for the node from a string.
RobotRaconteur_LogLevel SetLogLevelFromEnvVariable (const std::string &env_variable_name="ROBOTRACONTEUR_LOG_LEVEL")
 Set the log level for the node from specified environmental variable.
boost::shared_ptr< LogRecordHandlerGetLogRecordHandler ()
 Get the currently configured log record handler.
void SetLogRecordHandler (const boost::shared_ptr< LogRecordHandler > &handler)
 Set the handler for log records.
boost::shared_ptr< MessageTapGetMessageTap ()
 Get the active message tap.
void SetMessageTap (const boost::shared_ptr< MessageTap > &message_tap)
 Set the a message tap to record log records and messages.
NodeDirectories GetNodeDirectories ()
 Get the current node directories.
void SetNodeDirectories (const NodeDirectories &dir)
 Set the node directories.

Static Public Member Functions

static RobotRaconteurNodes ()
 Singleton accessor.
static boost::shared_ptr< RobotRaconteurNodesp ()
 Singleton shared_ptr accessor.
static RR_WEAK_PTR< RobotRaconteurNodeweak_sp ()
 Singleton weak_ptr accessor.
static std::string SelectRemoteNodeURL (const std::vector< std::string > &urls)
 Select the "best" URL from a std::vector of candidates.
template<typename HandlerType>
static bool TryPostToThreadPool (RR_WEAK_PTR< RobotRaconteurNode > node, BOOST_ASIO_MOVE_ARG(HandlerType) h, bool shutdown_op=false)
 Tries to post a handler function to be called by a thread in the thread pool. Returns immediately.
static bool TryHandleException (RR_WEAK_PTR< RobotRaconteurNode > node, const std::exception *exp)
 Try to pass an exception to the exception handler.

Detailed Description

The central node implementation.

RobotRaconteurNode implements the current Robot Raconteur instance and acts as the central switchpoint for the instance. The user registers types, connects clients, registers services, and registers transports through this class.

If the current program only needs one instance of RobotRaconteurNode, the singleton can be used. The singleton is accessed using:

RobotRaconteurNode::s()

or

RobotRaconteurNode::sp()

The node must be shut down before existing the program, or a memory leak/hard crash will occur. This can either be accomplished manually using the Shutdown() function, or automatically by using the ClientNodeSetup or ServerNodeSetup classes.

Constructor & Destructor Documentation

◆ RobotRaconteurNode()

RobotRaconteur::RobotRaconteurNode::RobotRaconteurNode ( )

Construct a new Robot Raconteur Node object.

Must be called using RR_MAKE_SHARED<RobotRaconteurNode>. Call Init() after construction.

Member Function Documentation

◆ AddNodeDetectionLostListener()

template<typename Handler>
node_lost_listener_connection RobotRaconteur::RobotRaconteurNode::AddNodeDetectionLostListener ( BOOST_ASIO_MOVE_ARG(Handler) h)
inline

Add a handler to be called when a node is no longer detected.

Nodes are considered no longer detected when the cached detected node information expires, usually after one minute. The cache must constantly be refreshed with new detection information to prevent expiration.

Parameters
hThe handler to call. Must have signature void my_handler(const NodeDiscoveryInfo&)
Returns
node_lost_listener_connection

◆ AddNodeServicesDetectedListener()

template<typename Handler>
node_updated_listener_connection RobotRaconteur::RobotRaconteurNode::AddNodeServicesDetectedListener ( BOOST_ASIO_MOVE_ARG(Handler) h)
inline

Add a handler to be called when detected services are updated.

The specified handler is called when the internal cache of available services is updated. The cache is only active when a subscription is in use, or is updated when FindServiceByType is called.

Subscriptions should be used instead of this function to detect and connect to services.

Parameters
hThe handler to call. Must have signature void my_handler(const NodeDiscoveryInfo& node_info , const std::vector<ServiceInfo2>& service_info)
Returns
node_updated_listener_connection boost::signals2 connection object

◆ AddPeriodicCleanupTask()

void RobotRaconteur::RobotRaconteurNode::AddPeriodicCleanupTask ( const boost::shared_ptr< IPeriodicCleanupTask > & task)

Add a periodic cleanup task.

The node will call periodic cleanup tasks every 5-15 seconds. Use these tasks instead of timers for cleanup operations.

Parameters
taskThe task to call periodically

◆ AddShutdownListener()

template<typename Handler>
shutdown_listener_connection RobotRaconteur::RobotRaconteurNode::AddShutdownListener ( BOOST_ASIO_MOVE_ARG(Handler) h)
inline

Adds a shutdown listener.

Adds a listener handler function that will be called when the node is shutting down.

Template Parameters
Handler
Returns
shutdown_listener_connection

◆ AsyncConnectService() [1/2]

void RobotRaconteur::RobotRaconteurNode::AsyncConnectService ( boost::string_ref url,
boost::string_ref username,
const boost::intrusive_ptr< RRMap< std::string, RRValue > > & credentials,
boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener,
boost::string_ref objecttype,
boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Asynchronously create a client connection to a remote service using a URL.

Same as ConnectService but returns asynchronously. See ConnectService() for more details on client connections.

handler is called after the client connection succeeds are fails. On success, the RRObject is returned and the exception is null. On failure, the RRObject is null and the exception contains a subclass of RobotRaconteurException.

Parameters
urlThe URL of the service to connect
usernameAn optional username for authentication
credentialsOptional credentials for authentication
listenerAn optional listener callback function
objecttypeThe desired root object proxy type. Optional but highly recommended.
handlerA handler function to receive the object reference or an exception
timeoutTimeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout.

◆ AsyncConnectService() [2/2]

void RobotRaconteur::RobotRaconteurNode::AsyncConnectService ( const std::vector< std::string > & url,
boost::string_ref username,
const boost::intrusive_ptr< RRMap< std::string, RRValue > > & credentials,
boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener,
boost::string_ref objecttype,
boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Same as AsyncConnectService(), but accepts a vector of candidate URLs.

Frequently during discovery, multiple candidate URLs will be discovered. This function will attempt each of the candidate URLs kind-of-the-hill style to find the best one.

Parameters
urlVector of candidate URLs to attempt
usernameAn optional username for authentication
credentialsOptional credentials for authentication
listenerAn optional listener callback function
objecttypeThe desired root object proxy type. Optional but highly recommended.
handlerA handler function to receive the object reference or an exception
timeoutTimeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout.

◆ AsyncDisconnectService()

void RobotRaconteur::RobotRaconteurNode::AsyncDisconnectService ( const boost::shared_ptr< RRObject > & obj,
boost::function< void()> handler )

Asynchronously disconnects a client connection to a service.

Same as DisconnectService() but returns asynchronously.

Parameters
objThe root object of the client to disconnect
handlerThe handler to call when complete

◆ AsyncFindNodeByID()

void RobotRaconteur::RobotRaconteurNode::AsyncFindNodeByID ( const RobotRaconteur::NodeID & id,
const std::vector< std::string > & transportschemes,
boost::function< void(const boost::shared_ptr< std::vector< NodeInfo2 > > &)> handler,
int32_t timeout = 5000 )

Asynchronously finds nodes on the network with the specified NodeID.

Same as FindNodeByID() but returns asynchronously

Parameters
idThe NodeID to find
transportschemesA list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc
handlerHandler to call on completion
timeoutTimeout in milliseconds. Using a timeout greater than 5 seconds is not recommended.

◆ AsyncFindNodeByName()

void RobotRaconteur::RobotRaconteurNode::AsyncFindNodeByName ( boost::string_ref name,
const std::vector< std::string > & transportschemes,
boost::function< void(const boost::shared_ptr< std::vector< NodeInfo2 > > &)> handler,
int32_t timeout = 5000 )

Asynchronously finds nodes on the network with the specified NodeName.

Same as FindNodeByName() but returns asynchronously

Parameters
nameThe NodeName to find
transportschemesA list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc
handlerHandler to call on completion
timeoutTimeout in milliseconds. Using a timeout greater than 5 seconds is not recommended.

◆ AsyncFindObjectType() [1/2]

void RobotRaconteur::RobotRaconteurNode::AsyncFindObjectType ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref,
boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Asynchronously returns the type of a service object.

Same as FindObjectType() but returns asynchronously

Parameters
objThe object with the desired objref
objrefThe name of the objref member
handlerA handler function to receive the object type or an exception
timeoutTimeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout

◆ AsyncFindObjectType() [2/2]

void RobotRaconteur::RobotRaconteurNode::AsyncFindObjectType ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref,
boost::string_ref index,
boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Asynchronously returns the type of a service object.

Same as FindObjectType() but returns asynchronously

Parameters
objThe object with the desired objref
objrefThe name of the objref member
indexThe index for the objref, convert int to string for int32 index type
handlerA handler function to receive the object type or an exception
timeoutTimeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout

◆ AsyncFindObjRefTyped() [1/2]

void RobotRaconteur::RobotRaconteurNode::AsyncFindObjRefTyped ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref,
boost::string_ref index,
boost::string_ref objecttype,
boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Asynchronously returns an objref as a specific type.

Same as FindObjectType() but returns asynchronously

Parameters
objThe object with the desired objref
objrefThe name of the objref member
indexThe index for the objref, convert int to string for int32 index type
objecttypeThe desired service object type
handlerA handler function to receive the object reference or an exception
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout

◆ AsyncFindObjRefTyped() [2/2]

void RobotRaconteur::RobotRaconteurNode::AsyncFindObjRefTyped ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref,
boost::string_ref objecttype,
boost::function< void(const boost::shared_ptr< RRObject > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Asynchronously returns an objref as a specific type.

Same as FindObjectType() but returns asynchronously

Parameters
objThe object with the desired objref
objrefThe name of the objref member
objecttypeThe desired service object type
handlerA handler function to receive the object reference or an exception
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout

◆ AsyncFindServiceByType()

void RobotRaconteur::RobotRaconteurNode::AsyncFindServiceByType ( boost::string_ref servicetype,
const std::vector< std::string > & transportschemes,
boost::function< void(const boost::shared_ptr< std::vector< ServiceInfo2 > > &)> handler,
int32_t timeout = 5000 )

Asynchronously use discovery to find availabe services by service type.

Same as FindServiceByType() but returns asynchronously

Parameters
servicetypeThe service type to find, ie com.robotraconteur.robotics.robot.Robot
transportschemesA list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc
handlerHandler to call on completion
timeoutTimeout in milliseconds. Using a timeout greater than 5 seconds is not recommended.

◆ AsyncReleaseObjectLock()

void RobotRaconteur::RobotRaconteurNode::AsyncReleaseObjectLock ( const boost::shared_ptr< RRObject > & obj,
boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Asynchronously release an excluse access lock previously locked with RequestObjectLock() or AsyncRequestObjectLock().

Same as ReleaseObjectLock() but returns asynchronously

Parameters
objThe object previously locked
handlerHandler to call on completion
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE

◆ AsyncRequestObjectLock()

void RobotRaconteur::RobotRaconteurNode::AsyncRequestObjectLock ( const boost::shared_ptr< RRObject > & obj,
RobotRaconteurObjectLockFlags flags,
boost::function< void(const boost::shared_ptr< std::string > &, const boost::shared_ptr< RobotRaconteurException > &)> handler,
int32_t timeout = RR_TIMEOUT_INFINITE )

Asynchronously request an exclusive access lock to a service object.

Same as RequestObjectLock() but returns asynchronously

Parameters
objThe object to lock. Must be returned by ConnectService or returned by an objref
flagsSelect either a "User" or "Session" lock
handlerHandler to call on completion
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE

◆ AsyncUpdateDetectedNodes()

void RobotRaconteur::RobotRaconteurNode::AsyncUpdateDetectedNodes ( const std::vector< std::string > & schemes,
boost::function< void()> handler,
int32_t timeout = 5000 )

Asynchronously update the detected nodes cache.

Same as UpdateDetectedNodes() but returns asynchronously

Parameters
schemesA vector of transport schemes, ie "rr+tcp", "rr+local", etc. to update.
handlerThe handler to call on completion
timeoutThe timeout for the operation in milliseconds. This function will often run for the full timeout, so values less than 5 seconds are recommended.

◆ CheckConnection()

void RobotRaconteur::RobotRaconteurNode::CheckConnection ( uint32_t endpoint)

Check that the TransportConnection associated with an endpoint is connected.

Parameters
endpointThe LocalEndpoint identifier to check

◆ CloseService()

void RobotRaconteur::RobotRaconteurNode::CloseService ( boost::string_ref sname)

Closes a previously registered service.

Services are automatically closed by Shutdown, so this function is rarely used.

Parameters
snameThe name of the service to close

◆ CompareLogLevel()

bool RobotRaconteur::RobotRaconteurNode::CompareLogLevel ( RobotRaconteur_LogLevel log_level)

Test if the specified log level would be accepted.

Parameters
log_levelLog level to test
Returns
true The log would be accepted
false The log would be ignored

◆ ConnectService() [1/2]

boost::shared_ptr< RRObject > RobotRaconteur::RobotRaconteurNode::ConnectService ( boost::string_ref url,
boost::string_ref username = "",
const boost::intrusive_ptr< RRMap< std::string, RRValue > > & credentials = (boost::intrusive_ptr< RRMap< std::string, RRValue > >()),
boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener = 0,
boost::string_ref objecttype = "" )

Create a client connection to a remote service using a URL.

Synchronously creates a connection to a remote service using a URL. URLs are either provided by the service, or are determined using discovery functions such as FindServiceByType(). This function is the primary way to create client connections.

username and credentials can be used to specify authentication information. Credentials will often contain a "password" or token entry.

The listener is a function that is called during various events. See ClientServiceListenerEventType for a description of the possible events.

ConnectService will attempt to instantiate a client object reference (proxy) based on the type information provided by the service. The type information will contain the type of the object, and all the implemented types. The client will normally want a specific one of the implement types. Specify this desired type in objecttype to avoid future compatibility issues.

Requires multithreading

Parameters
urlThe URL of the service to connect
usernameAn optional username for authentication
credentialsOptional credentials for authentication
listenerAn optional listener callback function
objecttypeThe desired root object proxy type. Optional but highly recommended.
Returns
RR_SHARED_PTR<RRObject> The client object reference (proxy). Must be cast to expected type.

◆ ConnectService() [2/2]

boost::shared_ptr< RRObject > RobotRaconteur::RobotRaconteurNode::ConnectService ( const std::vector< std::string > & urls,
boost::string_ref username = "",
const boost::intrusive_ptr< RRMap< std::string, RRValue > > & credentials = (boost::intrusive_ptr< RRMap< std::string, RRValue > >()),
boost::function< void(const boost::shared_ptr< ClientContext > &, ClientServiceListenerEventType, const boost::shared_ptr< void > &)> listener = 0,
boost::string_ref objecttype = "" )

Same as ConnectService(), but accepts a vector of candidate URLs.

Frequently during discovery, multiple candidate URLs will be discovered. This function will attempt each of the candidate URLs kind-of-the-hill style to find the best one.

Requires multithreading

Parameters
urlsVector of candidate URLs to attempt
usernameAn optional username for authentication
credentialsOptional credentials for authentication
listenerAn optional listener callback function
objecttypeThe desired root object proxy type. Optional but highly recommended.
Returns
RR_SHARED_PTR<RRObject> The client object reference (proxy). Must be cast to expected type.

◆ CreateAutoResetEvent()

virtual boost::shared_ptr< AutoResetEvent > RobotRaconteur::RobotRaconteurNode::CreateAutoResetEvent ( )
virtual

Create an AutoResetEvent object.

Normally the AutoResetEvent will use the system clock for timeouts, but in certain circumstances will use simulation time

Returns
RR_SHARED_PTR<AutoResetEvent> The new AutoResetEvent object

◆ CreateRate()

virtual boost::shared_ptr< Rate > RobotRaconteur::RobotRaconteurNode::CreateRate ( double frequency)
virtual

Create a Rate object.

Rate is used to stabilize periodic loops to a specified frequency

This function will normally return a WallRate instance

Parameters
frequencyFrequency of loop in Hz
Returns
RR_SHARED_PTR<Rate> The new Rate object

◆ CreateTimer()

virtual boost::shared_ptr< Timer > RobotRaconteur::RobotRaconteurNode::CreateTimer ( const boost::posix_time::time_duration & period,
boost::function< void(const TimerEvent &)> handler,
bool oneshot = false )
virtual

Create a Timer object.

This function will normally return a WallTimer instance

Start() must be called after timer creation

Parameters
periodThe period of the timer
handlerThe handler function to call when timer times out
oneshotTrue if timer is a one-shot timer, false for repeated timer
Returns
RR_SHARED_PTR<Timer> The new Timer object. Must call Start()

◆ DisconnectService()

void RobotRaconteur::RobotRaconteurNode::DisconnectService ( const boost::shared_ptr< RRObject > & obj)

Disconnects a client connection to a service.

Synchronously disconnects a client connection. Client connections are automatically closed by Shutdown(), so this function is optional.

Requires multithreading

Parameters
objThe root object of the service to disconnect

◆ DownCastAndThrowException()

void RobotRaconteur::RobotRaconteurNode::DownCastAndThrowException ( RobotRaconteurException & exp)

Downcasts a RobotRaconteurException and throws it.

Serialized RobotRaconteurException may not be correctly downcast when deserialized. DownCastAndThrowException will find the correct type, downcast the exception, and throw the correctly typed exception

Parameters
expThe RobotRaconteurException to downcast and throw

◆ DownCastException()

boost::shared_ptr< RobotRaconteurException > RobotRaconteur::RobotRaconteurNode::DownCastException ( const boost::shared_ptr< RobotRaconteurException > & exp)

Downcasts a RobotRaconteurException.

Serialized RobotRaconteurException may not be correctly downcast when deserialized. DownCastException will find the correct type, downcast the exception, and return the correctly typed exception

Parameters
expThe RobotRaconteurException to downcast

◆ FindNodeByID()

std::vector< NodeInfo2 > RobotRaconteur::RobotRaconteurNode::FindNodeByID ( const RobotRaconteur::NodeID & id,
const std::vector< std::string > & transportschemes )

Finds nodes on the network with a specified NodeID.

Updates the discovery cache and find nodes with the specified NodeID. This function returns unverified cache information.

Requires multithreading

Parameters
idThe NodeID to find
transportschemesA list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc
Returns
std::vector<NodeInfo2>

◆ FindNodeByName()

std::vector< NodeInfo2 > RobotRaconteur::RobotRaconteurNode::FindNodeByName ( boost::string_ref name,
const std::vector< std::string > & transportschemes )

Finds nodes on the network with a specified NodeName.

Updates the discovery cache and find nodes with the specified NodeName. This function returns unverified cache information.

Requires multithreading

Parameters
nameThe NodeName to find
transportschemesA list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc
Returns
std::vector<NodeInfo2>

◆ FindObjectType() [1/2]

std::string RobotRaconteur::RobotRaconteurNode::FindObjectType ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref )

Returns the type of a service object.

Returns the fully qualified object type that would be returned by an objref member

Requires multithreading

Parameters
objThe object with the desired objref
objrefThe name of the objref member
Returns
std::string The fully qualified object type

◆ FindObjectType() [2/2]

std::string RobotRaconteur::RobotRaconteurNode::FindObjectType ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref,
boost::string_ref index )

Returns the type of a service object.

Returns the fully qualified object type that would be returned by an indexed objref member

Requires multithreading

Parameters
objThe object with the desired objref
objrefThe name of the objref member
indexThe index for the objref, convert int to string for int32 index type
Returns
std::string The fully qualified object type

◆ FindObjRefTyped() [1/2]

boost::shared_ptr< RRObject > RobotRaconteur::RobotRaconteurNode::FindObjRefTyped ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref,
boost::string_ref index,
boost::string_ref objecttype )

Returns an indexed objref as a specified type.

Same as FindObjectTyped() but includes an objref index

Requires multithreading

Parameters
objThe object with the desired objref
objrefThe name of the objref member
indexThe index for the objref, convert int to string for int32 index type
objecttypeThe desired service object type
Returns
RR_SHARED_PTR<RRObject> The object with the specified interface type. Must be cast to the desired type

◆ FindObjRefTyped() [2/2]

boost::shared_ptr< RRObject > RobotRaconteur::RobotRaconteurNode::FindObjRefTyped ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref objref,
boost::string_ref objecttype )

Returns an objref as a specific type.

Robot Raconteur service object types are polymorphic using inheritance, meaning that an object may be represented using multiple object types. objref will attempt to return the relevant type, but it is sometimes necessary to request a specific type for an objref.

This function will return the object from an objref as the specified type, or throw an error if the type is invalid.

Requires multithreading

Parameters
objThe object with the desired objref
objrefThe name of the objref member
objecttypeThe desired service object type
Returns
RR_SHARED_PTR<RRObject> The object with the specified interface type. Must be cast to the desired type

◆ FindServiceByType()

std::vector< ServiceInfo2 > RobotRaconteur::RobotRaconteurNode::FindServiceByType ( boost::string_ref servicetype,
const std::vector< std::string > & transportschemes )

Use discovery to find available services by service type.

Uses discovery to find available services based on a service type. This service type is the type of the root object, ie com.robotraconteur.robotics.robot.Robot. This process will update the detected node cache.

Requires multithreading

Parameters
servicetypeThe service type to find, ie com.robotraconteur.robotics.robot.Robot
transportschemesA list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc
Returns
std::vector<ServiceInfo2> The detected services

◆ GetDetectedNodeCacheInfo()

NodeInfo2 RobotRaconteur::RobotRaconteurNode::GetDetectedNodeCacheInfo ( const RobotRaconteur::NodeID & nodeid)

Get cached node discovery information.

Return current node information from the discovery cache. This information is unverified and is used for the first step in the discovery process.

Parameters
nodeidThe NodeID of the requested node
Returns
NodeInfo2

◆ GetDetectedNodes()

std::vector< NodeDiscoveryInfo > RobotRaconteur::RobotRaconteurNode::GetDetectedNodes ( )

Get the nodes currently detected by Transports.

Transports configured to listen for node discovery send detected node information to the parent node, where it is stored. Normally this information will expire after one minute, and needs to be constantly refreshed.

This node information is not verified. It is the raw discovery information received by the transports. Verification is done when the node is interrogated for service information.

Returns
std::vector<NodeDiscoveryInfo>

◆ GetDynamicServiceFactory()

const boost::shared_ptr< RobotRaconteur::DynamicServiceFactory > RobotRaconteur::RobotRaconteurNode::GetDynamicServiceFactory ( )

Get the current DynamicServiceFactory. May be null.

See SetDynamicServiceFactory()

Returns
const RR_SHARED_PTR<RobotRaconteur::DynamicServiceFactory>

◆ GetEndpointInactivityTimeout()

uint32_t RobotRaconteur::RobotRaconteurNode::GetEndpointInactivityTimeout ( )

Get the timeout for endpoint activity in milliseconds.

Sets a timeout for endpoint inactivity. If no message is sent or received by the endpoint for the specified time, the endpoint is closed. Default timeout is 10 minutes.

Returns
uint32_t Timeout in milliseconds

◆ GetExceptionHandler()

boost::function< void(const std::exception *)> RobotRaconteur::RobotRaconteurNode::GetExceptionHandler ( )

Get the node's current exception handler, or null.

Returns the exception handler previously set using SetExceptionHandler()

Returns
boost::function<void (const std::exception*)> The current exception handler, or null

◆ GetLogLevel()

RobotRaconteur_LogLevel RobotRaconteur::RobotRaconteurNode::GetLogLevel ( )

Get the current log level for the node.

Default level is "info"

Returns
RobotRaconteur_LogLevel

◆ GetLogRecordHandler()

boost::shared_ptr< LogRecordHandler > RobotRaconteur::RobotRaconteurNode::GetLogRecordHandler ( )

Get the currently configured log record handler.

If NULL, records are sent to std::cerr

Returns
RR_SHARED_PTR<LogRecordHandler>

◆ GetMemoryMaxTransferSize()

uint32_t RobotRaconteur::RobotRaconteurNode::GetMemoryMaxTransferSize ( )

Get the maximum chunk size for memory transfers in bytes.

memory members break up large transfers into chunks to avoid sending messages larger than the transport maximum, which is normally approximately 10 MB. The memory max transfer size is the largest data chunk the memory will send, in bytes. Default is 100 kB.

Returns
uint32_t The max memory transfer size in bytes

◆ GetMessageTap()

boost::shared_ptr< MessageTap > RobotRaconteur::RobotRaconteurNode::GetMessageTap ( )

Get the active message tap.

Returns
RR_SHARED_PTR<MessageTap>

◆ GetNodeDirectories()

NodeDirectories RobotRaconteur::RobotRaconteurNode::GetNodeDirectories ( )

Get the current node directories.

Node directories are set to default if not configured

Returns
NodeDirectories

◆ GetNodeDiscoveryMaxCacheCount()

uint32_t RobotRaconteur::RobotRaconteurNode::GetNodeDiscoveryMaxCacheCount ( )

Get the maximum number of detected nodes that will be cached.

The node keeps a cache of detected nodes. The NodeDiscoveryMaxCacheCount sets an upper limit to how many detected nodes are cached. By default set to 4096

Returns
uint32_t

◆ GetObjectServicePath()

std::string RobotRaconteur::RobotRaconteurNode::GetObjectServicePath ( const boost::shared_ptr< RRObject > & obj)

Get the service path of a client object.

Parameters
objThe object to get the service path for
Returns
std::string The object's service path

◆ GetObjectType()

virtual std::string RobotRaconteur::RobotRaconteurNode::GetObjectType ( const boost::shared_ptr< RRObject > & obj)
virtual

Get the Robot Raconteur type of a connected service object obj must be returned by ConnectService(), AsyncConnectService(), or an objref.

Parameters
objThe object to query
Returns
std::string The Robot Raconteur type of the object

◆ GetPulledServiceType()

boost::shared_ptr< ServiceFactory > RobotRaconteur::RobotRaconteurNode::GetPulledServiceType ( const boost::shared_ptr< RRObject > & obj,
boost::string_ref type )

Get a ServiceFactory created from a service type pulled by a client.

Clients pull service definitions from services and create instances of ServiceFactory if a DynamicServiceFactory has been configured. GetPulledServiceType() returns a generated ServiceFactory. Use GetPulledServiceTypes() to return a list of available service types.

Parameters
objClient object reference returned by ConnectService() or AsyncConnectService()
typeThe name of the service type
Returns
RR_SHARED_PTR<ServiceFactory> The pulled service factory

◆ GetPulledServiceTypes()

std::vector< std::string > RobotRaconteur::RobotRaconteurNode::GetPulledServiceTypes ( const boost::shared_ptr< RRObject > & obj)

Get the names of service types pulled by a client.

Clients pull service definitions from services and create instances of ServiceFactory if a DynamicServiceFactory has been configured. GetPulledServiceTypes returns a list of the names of these pulled service types. Use GetPulledServiceType() to retrieve the ServiceFactory for a specific type.

Parameters
objClient object reference returned by ConnectService() or AsyncConnectService()
Returns
std::vector<std::string> The names of the pulled service types

◆ GetRandomInt()

template<typename T>
T RobotRaconteur::RobotRaconteurNode::GetRandomInt ( T min,
T max )
inline

Returns a random integer using the node's random number generator.

Template Parameters
TThe integer type, ie int32_t
Parameters
minThe minimum value for the returned integer
maxThe maximum value for the returned integer
Returns
T The generated random integer

◆ GetRandomInts()

template<typename T>
std::vector< T > RobotRaconteur::RobotRaconteurNode::GetRandomInts ( size_t count,
T min,
T max )
inline

Returns a vector of random integer using the node's random number generator.

Template Parameters
TThe integer type, ie int32_t
Parameters
countThe number of random integers to generate
minThe minimum value for the returned integers
maxThe maximum value for the returned integers
Returns
std::vector<T> The generated random integer vector

◆ GetRandomString()

std::string RobotRaconteur::RobotRaconteurNode::GetRandomString ( size_t count)

Generates a random string with the specified character count using the node's random number generator.

The returned string will consist of letters and numbers

Parameters
countThe number of characters to return
Returns
std::string The random string

◆ GetRegisteredServiceNames()

std::vector< std::string > RobotRaconteur::RobotRaconteurNode::GetRegisteredServiceNames ( )

Get the names of registered services.

Returns
std::vector<std::string> The registered service names

◆ GetRegisteredServiceTypes()

std::vector< std::string > RobotRaconteur::RobotRaconteurNode::GetRegisteredServiceTypes ( )

Return names of registered service types.

Returns
std::vector<std::string>

◆ GetRequestTimeout()

uint32_t RobotRaconteur::RobotRaconteurNode::GetRequestTimeout ( )

Get the timeout for requests in milliseconds.

Requests are calls to a remote node that expect a response. function, property, callback, memory, and setup calls in pipe and wire are all requests. All other Robot Raconteur functions that call the remote node and expect a response are requests. Default timeout is 15 seconds.

Returns
uint32_t Timeout in milliseconds

◆ GetRobotRaconteurVersion()

std::string RobotRaconteur::RobotRaconteurNode::GetRobotRaconteurVersion ( )

Get the current RobotRaconteurVersion as a string.

Version is three numbers separated by dots, ie "0.9.2"

Returns
std::string The current version

◆ GetService()

boost::shared_ptr< ServerContext > RobotRaconteur::RobotRaconteurNode::GetService ( boost::string_ref name)

Gets a ServerContext for a service by name.

Parameters
nameThe name of the service
Returns
RR_SHARED_PTR<ServerContext> The ServerContext for a registered service

◆ GetServiceAttributes()

std::map< std::string, boost::intrusive_ptr< RRValue > > RobotRaconteur::RobotRaconteurNode::GetServiceAttributes ( const boost::shared_ptr< RRObject > & obj)

Get the service attributes of a client connection.

Returns the service attributes of a client connected using ConnectService()

Parameters
objThe root object of the client to use to retrieve service attributes
Returns
std::map<std::string, RR_INTRUSIVE_PTR<RRValue> > The service attributes

◆ GetServiceName()

std::string RobotRaconteur::RobotRaconteurNode::GetServiceName ( const boost::shared_ptr< RRObject > & obj)

Get the name of a service from a client connection.

Returns the service name of the remote service that a client is connected

Parameters
objThe root object of the client to use to retrieve service attributes
Returns
std::string The service name

◆ GetServiceNodeID()

RobotRaconteur::NodeID RobotRaconteur::RobotRaconteurNode::GetServiceNodeID ( const boost::shared_ptr< RRObject > & obj)

Get the service NodeID of the remote node from a client connection.

Returns the NodeID of the remote node that a client is connected

Parameters
objThe root object of the client to use to retrieve service attributes
Returns
NodeID The NodeID

◆ GetServiceNodeName()

std::string RobotRaconteur::RobotRaconteurNode::GetServiceNodeName ( const boost::shared_ptr< RRObject > & obj)

Get the service NodeName of the remote node from a client connection.

Returns the NodeName of the remote node that a client is connected

Parameters
objThe root object of the client to use to retrieve service attributes
Returns
std::string The NodeName

◆ GetServiceType()

boost::shared_ptr< ServiceFactory > RobotRaconteur::RobotRaconteurNode::GetServiceType ( boost::string_ref type)

Returns a previously registered service type.

Parameters
typeThe name of the service type to retrieve
Returns
RR_SHARED_PTR<ServiceFactory>

◆ GetThreadPool()

boost::shared_ptr< ThreadPool > RobotRaconteur::RobotRaconteurNode::GetThreadPool ( )

Get the current ThreadPool for the node.

Returns the current ThreadPool in use by the node. If no ThreadPool has been configured, a ThreadPool is created using the ThreadPoolFactory. By default a ThreadPool is created with 20 threads

Returns
RR_SHARED_PTR<ThreadPool> The current thread pool

◆ GetThreadPoolCount()

int32_t RobotRaconteur::RobotRaconteurNode::GetThreadPoolCount ( )

Get the number of threads for the node ThreadPool.

Returns
int32_t

◆ GetThreadPoolFactory()

boost::shared_ptr< ThreadPoolFactory > RobotRaconteur::RobotRaconteurNode::GetThreadPoolFactory ( )

Get the current ThreadPoolFactory for the node.

ThreadPoolFactory is used to create a ThreadPool for the node if one is not already set. By default uses ThreadPoolFactory

Returns
RR_SHARED_PTR<ThreadPoolFactory>

◆ GetTransportInactivityTimeout()

uint32_t RobotRaconteur::RobotRaconteurNode::GetTransportInactivityTimeout ( )

Get the timeout for transport activity in milliseconds.

Sets a timeout for transport inactivity. If no message is sent or received on the transport for the specified time, the transport is closed. Default timeout is 10 minutes.

Returns
uint32_t Timeout in milliseconds

◆ HandleException()

void RobotRaconteur::RobotRaconteurNode::HandleException ( const std::exception * exp)

Handle exceptino by passing the current exception to the handler function.

Parameters
expThe exception to pass to the handler function

◆ Init()

void RobotRaconteur::RobotRaconteurNode::Init ( )

Initialize the node. Called automatically for s() and sp().

This function must be called to initialize background tasks before using the node. It is called automatically by the s() and sp() singleton accessors, so the user only needs to call this function when not using the singleton. If a custom thread pool is being used, the thread pool factory must be specified before calling init.

◆ IsEndpointLargeTransferAuthorized()

bool RobotRaconteur::RobotRaconteurNode::IsEndpointLargeTransferAuthorized ( uint32_t endpoint)

Check if the endpoint is authorized for large message transfer.

Saturating a transport with large messages to cause memory exhaustion is a potential attack vector for unauthorized clients. Limit transfers by unauthorized clients to small messages to prevent this

Parameters
endpointThe LocalEndpoint id
Returns
true Large transfer authorized
false Large transfer is not authorized

◆ IsServiceTypeRegistered()

bool RobotRaconteur::RobotRaconteurNode::IsServiceTypeRegistered ( boost::string_ref servicetype)

Check if a service type has been registered.

Parameters
servicetypeThe name of the service to check
Returns
true
false

◆ LogMessage()

void RobotRaconteur::RobotRaconteurNode::LogMessage ( RobotRaconteur_LogLevel level,
const std::string & message )

Log a simple message using the current node.

The record will be sent to the configured log handler, or sent to std::cerr if none is configured

If the level of the message is below the current log level for the node, the record will be ignored

Parameters
levelThe level for the log message
messageThe log message

◆ LogRecord()

void RobotRaconteur::RobotRaconteurNode::LogRecord ( const RRLogRecord & record)

Log a record to the node. Use the macros specified in Logging.h instead of this function directly.

The record will be sent to the configured log handler, or sent to std::cerr if none is configured

If the level of the message is below the current log level for the node, it will be ignored

Parameters
recordThe record to log

◆ MonitorEnter()

void RobotRaconteur::RobotRaconteurNode::MonitorEnter ( const boost::shared_ptr< RRObject > & obj,
int32_t timeout = RR_TIMEOUT_INFINITE )

Creates a monitor lock on a specified object.

Monitor locks are intendended for short operations that require guarding to prevent races, corruption, or other concurrency problems. Monitors emulate a single thread locking the service object.

Use of ScopedMonitorLock instead of this function is highly recommended to take advantage of RAII scoping

Monitor locks do not lock any sub-objects (objref)

Requires multithreading

Parameters
objThe object to lock
timeoutThe timeout in milliseconds to acquire the monitor lock, or RR_TIMEOUT_INFINITE

◆ MonitorExit()

void RobotRaconteur::RobotRaconteurNode::MonitorExit ( const boost::shared_ptr< RRObject > & obj)

Releases a monitor lock.

Use of ScopedMonitorLock instead of this function is highly recommended to take advantage of RAII scoping

Requires multithreading

Parameters
objThe object previously locked by MonitorEnter()

◆ NodeID()

RobotRaconteur::NodeID RobotRaconteur::RobotRaconteurNode::NodeID ( )

Get the current NodeID.

Gets the current NodeID. If one has not been set using SetNodeID(), one will be automatically generated.

Returns
NodeID

◆ NodeName()

std::string RobotRaconteur::RobotRaconteurNode::NodeName ( )

Get the current NodeName.

Gets the current NodeName. If one has not been set using SetNodeName(), it will be an empty string.

Returns
std::string

◆ NodeSyncTimeSpec()

virtual TimeSpec RobotRaconteur::RobotRaconteurNode::NodeSyncTimeSpec ( )
virtual

The sync time of the node as a TimeSpec.

See NodeSyncTimeUTC()

Returns
TimeSpec The node sync time as a TimeSpec

◆ NodeSyncTimeUTC()

virtual boost::posix_time::ptime RobotRaconteur::RobotRaconteurNode::NodeSyncTimeUTC ( )
virtual

The sync time of the node.

The node synchronizes it's clock with the system time in UTC when the node is initialized. After this time, a steady clock is used. This prevents the clock from jumping forward and back in time. It will no longer be updated by changes in the system time.

If an external high precision clock source like PTP is available, that clock will be used in place of the system and steady clock.

Returns
boost::posix_time::ptime The node sync time in UTC

◆ NowNodeTime()

virtual boost::posix_time::ptime RobotRaconteur::RobotRaconteurNode::NowNodeTime ( )
virtual

The current node time.

UTC time is not monotonic, due to the introduction of leap-seconds, and the possibility of the system clock being updated by the user. For a real-time systems, this is unacceptable and can lead to system instability. The "node time" used by Robot Raconteur is synchronized to UTC at startup, and is then steadily increasing from that initial time. It will ignore changes to the system clock, and will also ignore corrections like leap seconds.

Returns
boost::posix_time::ptime The current node time

◆ NowTimeSpec()

virtual TimeSpec RobotRaconteur::RobotRaconteurNode::NowTimeSpec ( )
virtual

The current node time as a TimeSpec.

The current node time as a TimeSpec. See NowNodeTime()

Returns
TimeSpec The current node time as a TimeSpec

◆ NowUTC()

virtual boost::posix_time::ptime RobotRaconteur::RobotRaconteurNode::NowUTC ( )
virtual

The current time in UTC time zone.

Uses the internal node clock to get the current time in UTC. While this will normally use the system clock, this may use simulation time in certain circumstances

Returns
boost::posix_time::ptime The current time in UTC

◆ RegisterService() [1/2]

boost::shared_ptr< ServerContext > RobotRaconteur::RobotRaconteurNode::RegisterService ( boost::string_ref name,
boost::string_ref servicetype,
const boost::shared_ptr< RRObject > & obj,
const boost::shared_ptr< ServiceSecurityPolicy > & securitypolicy = boost::shared_ptr< ServiceSecurityPolicy >() )

Registers a service for clients to connect.

The supplied object becomes the root object in the service. Other objects may be accessed by clients using objref members. The name of the service must conform to the naming rules of Robot Raconteur member names. A service is closed using either CloseService() or when Shutdown() is called.

Multiple services can be registered within the same node. Service names within a single node must be unique.

Parameters
nameThe name of the service, must follow member naming rules
servicetypeThe name of the service definition containing the object type. Do not include the object type.
objThe root object of the service
securitypolicyAn optional security policy for the service to control authentication and other security functions
Returns
RR_SHARED_PTR<ServerContext> The instantiated ServerContext. This object is owned by the node and the return can be safely ignored.

◆ RegisterService() [2/2]

boost::shared_ptr< ServerContext > RobotRaconteur::RobotRaconteurNode::RegisterService ( const boost::shared_ptr< ServerContext > & c)

Registers a service using a previously instantiated ServerContext.

The node will store a reference to the provided ServerContext and manage its lifecycle

Parameters
cThe ServerContext to register
Returns
RR_SHARED_PTR<ServerContext>

◆ RegisterServiceType()

void RobotRaconteur::RobotRaconteurNode::RegisterServiceType ( const boost::shared_ptr< ServiceFactory > & factory)

Register a service type.

Parameters
factoryThe service factory implementing the type to register

◆ RegisterTransport()

uint32_t RobotRaconteur::RobotRaconteurNode::RegisterTransport ( const boost::shared_ptr< Transport > & transport)

Register a transport for use by the node.

Parameters
transport
Returns
uint32_t The transport internal id

◆ ReleaseObjectLock()

std::string RobotRaconteur::RobotRaconteurNode::ReleaseObjectLock ( const boost::shared_ptr< RRObject > & obj)

Release an excluse access lock previously locked with RequestObjectLock() or AsyncRequestObjectLock().

Object must have previously been locked using RequestObjectLock() or AsyncRequestObjectLock()

Requires multithreading

Parameters
objThe object previously locked
Returns
std::string "OK" on success

◆ RemovePeriodicCleanupTask()

void RobotRaconteur::RobotRaconteurNode::RemovePeriodicCleanupTask ( const boost::shared_ptr< IPeriodicCleanupTask > & task)

Remove a task previously registered with AddPeriodicCleanupTask().

Parameters
taskThe task to remove

◆ RequestObjectLock()

std::string RobotRaconteur::RobotRaconteurNode::RequestObjectLock ( const boost::shared_ptr< RRObject > & obj,
RobotRaconteurObjectLockFlags flags )

Request an exclusive access lock to a service object.

Called by clients to request an exclusive lock on a service object and all subobjects (objrefs) in the service. The exclusive access lock will prevent other users ("User" lock) or client connections ("Session" lock) from interacting with the objects.

Requires multithreading

Parameters
objThe object to lock. Must be returned by ConnectService or returned by an objref
flagsSelect either a "User" or "Session" lock
Returns
std::string "OK" on success

◆ s()

RobotRaconteurNode * RobotRaconteur::RobotRaconteurNode::s ( )
static

Singleton accessor.

The RobotRaconteurNode singleton can be used when only one instance of Robot Raconteur is required in a program. The singleton must be shut down when the program exits.

This function returns a pointer to the singleton node. Using sp() if a shared_ptr is required.

Returns
RobotRaconteurNode*

◆ SelectRemoteNodeURL()

std::string RobotRaconteur::RobotRaconteurNode::SelectRemoteNodeURL ( const std::vector< std::string > & urls)
static

Select the "best" URL from a std::vector of candidates.

Service discovery will often return a list of candidate URLs to use to connect to a node. This function uses heuristics to select the "best" URL to use. The selection criteria ranks URLs in roughly the following order, lower number being better:

  1. "rr+intra" for IntraTransport
  2. "rr+local" for LocalTransport
  3. "rr+pci" or "rr+usb" for HardwareTransport
  4. "rrs+tcp://127.0.0.1" for secure TcpTransport loopback
  5. "rrs+tcp://[::1]" for secure TcpTransport IPv6 loopback
  6. "rrs+tcp://localhost" for secure TcpTransport loopback
  7. "rrs+tcp://[fe80" for secure TcpTransport link-local IPv6
  8. "rrs+tcp://" for any secure TcpTransport
  9. "rr+tcp://127.0.0.1" for TcpTransport loopback
  10. "rr+tcp://[::1]" for TcpTransport IPv6 loopback
  11. "rr+tcp://localhost" for TcpTransport loopback
  12. "rr+tcp://[fe80" for TcpTransport link-local IPv6
  13. "rr+tcp://" for any TcpTransport

TODO: "rr+quic" QuicTransport

Parameters
urlsThe candidate URLs
Returns
std::string The "best" URL out of the candidates

◆ SetDynamicServiceFactory()

void RobotRaconteur::RobotRaconteurNode::SetDynamicServiceFactory ( const boost::shared_ptr< RobotRaconteur::DynamicServiceFactory > & f)

Set the DynamicServicefactory.

DynamicServiceFactory is used by language wrappers to dynamically generate ServiceFactories based on ServiceDefinitions. DynamicServiceFactories allow Robot Raconteur to provide dynamic type handling at runtime.

Parameters
fThe DynamicServiceFactory instance

◆ SetEndpointInactivityTimeout()

void RobotRaconteur::RobotRaconteurNode::SetEndpointInactivityTimeout ( uint32_t timeout)

Set the timeout for endpoint activity in milliseconds.

See GetEndpointInactivityTimeout() for explanation of endpoint inactivity timeouts. Default value is 10 minutes.

Parameters
timeoutThe timeout in milliseconds

◆ SetExceptionHandler()

void RobotRaconteur::RobotRaconteurNode::SetExceptionHandler ( boost::function< void(const std::exception *)> handler)

Set an exception handler function.

The ThreadPool will catch exceptions that are uncaught by other logic and pass the exception to the specified exception handler. User handler functions that throw exceptions will also be caught and passed to the specified handler function

Parameters
handlerThe handler function for uncaught exceptions

◆ SetLogLevel()

void RobotRaconteur::RobotRaconteurNode::SetLogLevel ( RobotRaconteur_LogLevel level)

Set the log level for the node.

Set RobotRaconteur_LogLevel_Disable to disable logging

Parameters
levelThe desired log level

◆ SetLogLevelFromEnvVariable()

RobotRaconteur_LogLevel RobotRaconteur::RobotRaconteurNode::SetLogLevelFromEnvVariable ( const std::string & env_variable_name = "ROBOTRACONTEUR_LOG_LEVEL")

Set the log level for the node from specified environmental variable.

Retrieves the specified environmental variable and sets the log level based on one of the following values: DISABLE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE

If an invalid value or the variable does not exist, the log level is left unchanged.

Parameters
env_variable_nameThe environmental variable to use. Defaults to ROBOTRACONTEUR_LOG_LEVEL
Returns
RobotRaconteur_LogLevel The log level

◆ SetLogLevelFromString()

RobotRaconteur_LogLevel RobotRaconteur::RobotRaconteurNode::SetLogLevelFromString ( boost::string_ref level)

Set the log level for the node from a string.

Must be one of the following values: DISABLE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE

Defaults to WARNING

Parameters
levelThe desired log level
Returns
RobotRaconteur_LogLevel The log level

◆ SetLogRecordHandler()

void RobotRaconteur::RobotRaconteurNode::SetLogRecordHandler ( const boost::shared_ptr< LogRecordHandler > & handler)

Set the handler for log records.

If handler is NULL, records are sent to std::cerr

Parameters
handlerThe log record handler function

◆ SetMemoryMaxTransferSize()

void RobotRaconteur::RobotRaconteurNode::SetMemoryMaxTransferSize ( uint32_t size)

Set the maximum chunk size for memory transfers in bytes.

See GetMemoryMaxTransferSize() for an explanation of memory transfer sizes. Be careful not to exceed the message size limitation of the transports in use.

Parameters
sizeThe max memory transfer size in bytes.

◆ SetMessageTap()

void RobotRaconteur::RobotRaconteurNode::SetMessageTap ( const boost::shared_ptr< MessageTap > & message_tap)

Set the a message tap to record log records and messages.

Parameters
message_tapThe message tap to use

◆ SetNodeDirectories()

void RobotRaconteur::RobotRaconteurNode::SetNodeDirectories ( const NodeDirectories & dir)

Set the node directories.

Sets the node directories. Cannot be set after GetNodeDirectories() is called

Parameters
dirThe new node directories

◆ SetNodeDiscoveryMaxCacheCount()

void RobotRaconteur::RobotRaconteurNode::SetNodeDiscoveryMaxCacheCount ( uint32_t count)

Set maximum number of detected nodes that will be cached.

See GetNodeDiscoveryMaxCacheCount() for more information

Parameters
countThe maximum number of detected nodes to cache

◆ SetNodeID()

void RobotRaconteur::RobotRaconteurNode::SetNodeID ( const RobotRaconteur::NodeID & id)

Set the NodeID.

The NodeID must be set before NodeID() is called. If an attempt to set the NodeID after NodeID() has been called, an InvalidOperationException will be thrown.

The NodeID must not be all zeros.

Parameters
id

◆ SetNodeName()

void RobotRaconteur::RobotRaconteurNode::SetNodeName ( boost::string_ref name)

Set the NodeName.

The NodeName must be set before calling NodeName() If an attempt to set the NodeName after NodeName() has been called, an InvalidOperationException will be thrown.

The NodeName must not be empty, and must conform to the following regex:

^[a-zA-Z][a-zA-Z0-9_\\.\\-]*$

Parameters
name

◆ SetRequestTimeout()

void RobotRaconteur::RobotRaconteurNode::SetRequestTimeout ( uint32_t timeout)

Set the timeout for requests in milliseconds.

See GetRequestTimeout() for explanation of request timeouts. Default timeout is 15 seconds.

Parameters
timeoutTimeout in milliseconds

◆ SetThreadPool()

void RobotRaconteur::RobotRaconteurNode::SetThreadPool ( const boost::shared_ptr< ThreadPool > & pool)

Sets the ThreadPool for the node.

This function must be called before a ThreadPool has been set, either through this fuction, or a ThreadPool is created by GetThreadPool()

Parameters
poolThe ThreadPool for the node

◆ SetThreadPoolCount()

void RobotRaconteur::RobotRaconteurNode::SetThreadPoolCount ( int32_t count)

Set the number of threads for the node ThreadPool.

The ThreadPool will use a maximum of count threads. If this number is lower than the current ThreadPool count, the ThreadPool will attempt to release threads beyond count as they return to idle

Parameters
countThe number of threads for the ThreadPool

◆ SetThreadPoolFactory()

void RobotRaconteur::RobotRaconteurNode::SetThreadPoolFactory ( const boost::shared_ptr< ThreadPoolFactory > & factory)

Set the ThreadPoolFactory for the node.

ThreadPoolFactory is used to create a ThreadPool for the node if one is not already set

Parameters
factoryThe ThreadPoolFactory for the node

◆ SetTransportInactivityTimeout()

void RobotRaconteur::RobotRaconteurNode::SetTransportInactivityTimeout ( uint32_t timeout)

Set the timeout for transport activity in milliseconds.

See GetTransportInactivityTimeout() for explanation of tranport inactivity timeouts. Default value is 10 minutes.

Parameters
timeoutThe timeout in milliseconds

◆ Shutdown()

virtual void RobotRaconteur::RobotRaconteurNode::Shutdown ( )
virtual

Shuts down the node. Called automatically by ClientNodeSetup and ServerNodeSetup.

Shutdown must be called before program exit to avoid segfaults and other undefined behavior. The use of ClientNodeSetup and ServerNodeSetup is recommended to automate the node lifecycle. Calling this function does the following:

  1. Closes all services and releases all service objects
  2. Closes all client connections
  3. Shuts down discovery
  4. Shuts down all transports
  5. Notifies all shutdown listeners
  6. Releases all periodic cleanup task listeners
  7. Shuts down and releases the thread pool

Requires Multithreading

◆ Sleep()

virtual void RobotRaconteur::RobotRaconteurNode::Sleep ( const boost::posix_time::time_duration & duration)
virtual

Sleeps for a specified duration.

Normally will sleep based on the system clock, but in certain circumstances will use simulation time

Requires multithreading

Parameters
durationThe duration to sleep

◆ sp()

boost::shared_ptr< RobotRaconteurNode > RobotRaconteur::RobotRaconteurNode::sp ( )
static

Singleton shared_ptr accessor.

Same as s(), but returns a shared_ptr instead of a plain pointer.

Returns
RR_SHARED_PTR<RobotRaconteurNode>

◆ SubscribeService() [1/2]

boost::shared_ptr< ServiceSubscription > RobotRaconteur::RobotRaconteurNode::SubscribeService ( const std::string & url,
boost::string_ref username = "",
const boost::intrusive_ptr< RRMap< std::string, RRValue > > & credentials = (boost::intrusive_ptr< RRMap< std::string, RRValue > >()),
boost::string_ref objecttype = "" )

Subscribe to a service using a URL. Used to create robust connections to services.

Creates a ServiceSubscription assigned to a service with a URL. The subscription will attempt to maintain a peristent connection, reconnecting if the connection is lost.

Parameters
urlThe connection URL
usernameAn optional username for authentication
credentialsOptional credentials for authentication
objecttypeThe desired root object proxy type. Optional but highly recommended.
Returns
RR_SHARED_PTR<ServiceSubscription> The subscription object

◆ SubscribeService() [2/2]

boost::shared_ptr< ServiceSubscription > RobotRaconteur::RobotRaconteurNode::SubscribeService ( const std::vector< std::string > & url,
boost::string_ref username = "",
const boost::intrusive_ptr< RRMap< std::string, RRValue > > & credentials = (boost::intrusive_ptr< RRMap< std::string, RRValue > >()),
boost::string_ref objecttype = "" )

Subscribe to a service using one or more URL. Used to create robust connections to services.

Creates a ServiceSubscription assigned to a service with one or more candidate connection URLs. The subscription will attempt to maintain a peristent connection, reconnecting if the connection is lost.

Parameters
urlOne or more candidate connection urls
usernameAn optional username for authentication
credentialsOptional credentials for authentication
objecttypeThe desired root object proxy type. Optional but highly recommended.
Returns
RR_SHARED_PTR<ServiceSubscription> The subscription object

◆ SubscribeServiceByType()

boost::shared_ptr< ServiceSubscription > RobotRaconteur::RobotRaconteurNode::SubscribeServiceByType ( const std::vector< std::string > & service_types,
const boost::shared_ptr< ServiceSubscriptionFilter > & filter = boost::shared_ptr< ServiceSubscriptionFilter >() )

Subscribe to listen for available services and automatically connect.

A ServiceSubscription will track the availability of service types and create connections when available.

Parameters
service_typesA std::vector of service types to listen for, ie com.robotraconteur.robotics.robot.Robot
filterA filter to select individual services based on specified criteria
Returns
RR_SHARED_PTR<ServiceSubscription> The active subscription

◆ SubscribeServiceInfo2()

boost::shared_ptr< ServiceInfo2Subscription > RobotRaconteur::RobotRaconteurNode::SubscribeServiceInfo2 ( const std::vector< std::string > & service_types,
const boost::shared_ptr< ServiceSubscriptionFilter > & filter = boost::shared_ptr< ServiceSubscriptionFilter >() )

Subscribe to listen for available services information.

A ServiceInfo2Subscription will track the availability of service types and inform when services become available or are lost. If connections to available services are also required, ServiceSubscription should be used.

Parameters
service_typesA std::vector of service types to listen for, ie com.robotraconteur.robotics.robot.Robot
filterA filter to select individual services based on specified criteria
Returns
RR_SHARED_PTR<ServiceInfo2Subscription> The active subscription

◆ TryGetDetectedNodeCacheInfo()

bool RobotRaconteur::RobotRaconteurNode::TryGetDetectedNodeCacheInfo ( const RobotRaconteur::NodeID & nodeid,
NodeInfo2 & nodeinfo2 )

Try get cached node discovery information.

Same as GetDetectedNodeCacheInfo, but returns bool for success or failure instead of throwing an exception

Parameters
nodeidThe NodeID of the requested node
nodeinfo2Out parameter for the node info
Returns
bool true on success, false on failure

◆ TryGetNodeID()

bool RobotRaconteur::RobotRaconteurNode::TryGetNodeID ( RobotRaconteur::NodeID & id)

Tries getting the current NodeID.

Tries to get the NodeID. Returns false if no NodeID has been configured

Parameters
idthe NodeID if set
Returns
bool

◆ TryGetNodeName()

bool RobotRaconteur::RobotRaconteurNode::TryGetNodeName ( std::string & node_name)

Tries getting the current NodeName.

Gets the current NodeName. Returns false if NodeName is empty

Parameters
node_namethe NodeName if not empty
Returns
bool

◆ TryGetThreadPool()

bool RobotRaconteur::RobotRaconteurNode::TryGetThreadPool ( boost::shared_ptr< ThreadPool > & pool)

Tries to get the ThreadPool, returns false if the ThreadPool is not available.

This function will normally only return false if the node has been shut down

Parameters
poolOut parameter to receive ThreadPool shared_ptr
Returns
true pool contains shared_ptr to the ThreadPool
false Threadpool is not available

◆ TryHandleException()

bool RobotRaconteur::RobotRaconteurNode::TryHandleException ( RR_WEAK_PTR< RobotRaconteurNode > node,
const std::exception * exp )
static

Try to pass an exception to the exception handler.

Attempts to pass an exception to the handler function. Will fail and return false if node is null or the exception handler has not been set

Parameters
nodeThe node to handle the exception
expThe exception to pass to the handler function
Returns
true The handler function was called
false The handler function was not called

◆ TryPostToThreadPool()

template<typename HandlerType>
bool RobotRaconteur::RobotRaconteurNode::TryPostToThreadPool ( RR_WEAK_PTR< RobotRaconteurNode > node,
BOOST_ASIO_MOVE_ARG(HandlerType) h,
bool shutdown_op = false )
inlinestatic

Tries to post a handler function to be called by a thread in the thread pool. Returns immediately.

This function will not wait for the handler function to complete.

If node is null or ThreadPool is not available, the handler is not called and false is returned

Template Parameters
HandlerType
Parameters
nodeThe node
hThe handler to post
shutdown_opTrue if handler should be called during node shutdown
Returns
true The function was post to the ThreadPool
false The handler could not be post to the ThreadPool

◆ UnregisterServiceType()

void RobotRaconteur::RobotRaconteurNode::UnregisterServiceType ( boost::string_ref type)

Unregister a previously registered service type.

This function is not recommended as the results can be unpredictable

Parameters
type

◆ UpdateDetectedNodes()

void RobotRaconteur::RobotRaconteurNode::UpdateDetectedNodes ( const std::vector< std::string > & schemes)

Update the detected nodes cache.

The node keeps a cache of detected nodes, but this may become stale if nodes are rapidly added and removed from the network. Call this function to update the detected nodes.

Requires multithreading

Parameters
schemesA vector of transport schemes, ie "rr+tcp", "rr+local", etc. to update.

◆ weak_sp()

RR_WEAK_PTR< RobotRaconteurNode > RobotRaconteur::RobotRaconteurNode::weak_sp ( )
static

Singleton weak_ptr accessor.

Same as sp(), but returns a weak_ptr instead of a shared_ptr.

Returns
RR_SHARED_PTR<RobotRaconteurNode>

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