|
Robot Raconteur Core C++ Library
|
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< ServiceFactory > | GetServiceType (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::DynamicServiceFactory > | GetDynamicServiceFactory () |
| 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< RRObject > | 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. | |
| 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< RRObject > | 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. | |
| 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< NodeDiscoveryInfo > | GetDetectedNodes () |
| 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< ServiceInfo2Subscription > | 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. | |
| boost::shared_ptr< ServiceSubscription > | 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. | |
| boost::shared_ptr< ServiceSubscription > | 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. | |
| boost::shared_ptr< ServiceSubscription > | 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. | |
| std::vector< ServiceInfo2 > | FindServiceByType (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< NodeInfo2 > | FindNodeByID (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< NodeInfo2 > | FindNodeByName (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< RRObject > | FindObjRefTyped (const boost::shared_ptr< RRObject > &obj, boost::string_ref objref, boost::string_ref objecttype) |
| Returns an objref as a specific type. | |
| boost::shared_ptr< RRObject > | 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. | |
| 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< ThreadPool > | GetThreadPool () |
| 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< ThreadPoolFactory > | GetThreadPoolFactory () |
| 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< ServiceFactory > | GetPulledServiceType (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< Timer > | CreateTimer (const boost::posix_time::time_duration &period, boost::function< void(const TimerEvent &)> handler, bool oneshot=false) |
| Create a Timer object. | |
| virtual boost::shared_ptr< Rate > | CreateRate (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< AutoResetEvent > | CreateAutoResetEvent () |
| Create an AutoResetEvent object. | |
| void | DownCastAndThrowException (RobotRaconteurException &exp) |
| Downcasts a RobotRaconteurException and throws it. | |
| boost::shared_ptr< RobotRaconteurException > | DownCastException (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> | |
| 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< LogRecordHandler > | GetLogRecordHandler () |
| Get the currently configured log record handler. | |
| void | SetLogRecordHandler (const boost::shared_ptr< LogRecordHandler > &handler) |
| Set the handler for log records. | |
| boost::shared_ptr< MessageTap > | GetMessageTap () |
| 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 RobotRaconteurNode * | s () |
| Singleton accessor. | |
| static boost::shared_ptr< RobotRaconteurNode > | sp () |
| Singleton shared_ptr accessor. | |
| static RR_WEAK_PTR< RobotRaconteurNode > | weak_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. | |
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:
or
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.
| RobotRaconteur::RobotRaconteurNode::RobotRaconteurNode | ( | ) |
Construct a new Robot Raconteur Node object.
Must be called using RR_MAKE_SHARED<RobotRaconteurNode>. Call Init() after construction.
|
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.
| h | The handler to call. Must have signature void my_handler(const NodeDiscoveryInfo&) |
|
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.
| h | The handler to call. Must have signature void my_handler(const NodeDiscoveryInfo& node_info , const std::vector<ServiceInfo2>& service_info) |
| 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.
| task | The task to call periodically |
|
inline |
Adds a shutdown listener.
Adds a listener handler function that will be called when the node is shutting down.
| Handler |
| 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.
| url | The URL of the service to connect |
| username | An optional username for authentication |
| credentials | Optional credentials for authentication |
| listener | An optional listener callback function |
| objecttype | The desired root object proxy type. Optional but highly recommended. |
| handler | A handler function to receive the object reference or an exception |
| timeout | Timeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout. |
| 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.
| url | Vector of candidate URLs to attempt |
| username | An optional username for authentication |
| credentials | Optional credentials for authentication |
| listener | An optional listener callback function |
| objecttype | The desired root object proxy type. Optional but highly recommended. |
| handler | A handler function to receive the object reference or an exception |
| timeout | Timeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout. |
| 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.
| obj | The root object of the client to disconnect |
| handler | The handler to call when complete |
| 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
| id | The NodeID to find |
| transportschemes | A list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc |
| handler | Handler to call on completion |
| timeout | Timeout in milliseconds. Using a timeout greater than 5 seconds is not recommended. |
| 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
| name | The NodeName to find |
| transportschemes | A list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc |
| handler | Handler to call on completion |
| timeout | Timeout in milliseconds. Using a timeout greater than 5 seconds is not recommended. |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| handler | A handler function to receive the object type or an exception |
| timeout | Timeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| index | The index for the objref, convert int to string for int32 index type |
| handler | A handler function to receive the object type or an exception |
| timeout | Timeout is milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| index | The index for the objref, convert int to string for int32 index type |
| objecttype | The desired service object type |
| handler | A handler function to receive the object reference or an exception |
| timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| objecttype | The desired service object type |
| handler | A handler function to receive the object reference or an exception |
| timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
| 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
| servicetype | The service type to find, ie com.robotraconteur.robotics.robot.Robot |
| transportschemes | A list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc |
| handler | Handler to call on completion |
| timeout | Timeout in milliseconds. Using a timeout greater than 5 seconds is not recommended. |
| 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
| obj | The object previously locked |
| handler | Handler to call on completion |
| timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE |
| 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
| obj | The object to lock. Must be returned by ConnectService or returned by an objref |
| flags | Select either a "User" or "Session" lock |
| handler | Handler to call on completion |
| timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE |
| 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
| schemes | A vector of transport schemes, ie "rr+tcp", "rr+local", etc. to update. |
| handler | The handler to call on completion |
| timeout | The timeout for the operation in milliseconds. This function will often run for the full timeout, so values less than 5 seconds are recommended. |
| void RobotRaconteur::RobotRaconteurNode::CheckConnection | ( | uint32_t | endpoint | ) |
Check that the TransportConnection associated with an endpoint is connected.
| endpoint | The LocalEndpoint identifier to check |
| 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.
| sname | The name of the service to close |
| bool RobotRaconteur::RobotRaconteurNode::CompareLogLevel | ( | RobotRaconteur_LogLevel | log_level | ) |
Test if the specified log level would be accepted.
| log_level | Log level to test |
| 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
| url | The URL of the service to connect |
| username | An optional username for authentication |
| credentials | Optional credentials for authentication |
| listener | An optional listener callback function |
| objecttype | The desired root object proxy type. Optional but highly recommended. |
| 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
| urls | Vector of candidate URLs to attempt |
| username | An optional username for authentication |
| credentials | Optional credentials for authentication |
| listener | An optional listener callback function |
| objecttype | The desired root object proxy type. Optional but highly recommended. |
|
virtual |
Create an AutoResetEvent object.
Normally the AutoResetEvent will use the system clock for timeouts, but in certain circumstances will use simulation time
|
virtual |
|
virtual |
Create a Timer object.
This function will normally return a WallTimer instance
Start() must be called after timer creation
| period | The period of the timer |
| handler | The handler function to call when timer times out |
| oneshot | True if timer is a one-shot timer, false for repeated timer |
| 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
| obj | The root object of the service to disconnect |
| 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
| exp | The RobotRaconteurException to downcast and throw |
| 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
| exp | The RobotRaconteurException to downcast |
| 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
| id | The NodeID to find |
| transportschemes | A list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc |
| 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
| name | The NodeName to find |
| transportschemes | A list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| index | The index for the objref, convert int to string for int32 index type |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| index | The index for the objref, convert int to string for int32 index type |
| objecttype | The desired service object type |
| 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
| obj | The object with the desired objref |
| objref | The name of the objref member |
| objecttype | The desired service object type |
| 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
| servicetype | The service type to find, ie com.robotraconteur.robotics.robot.Robot |
| transportschemes | A list of transport types to search, ie rr+tcp, rr+local, rrs+tcp, etc |
| NodeInfo2 RobotRaconteur::RobotRaconteurNode::GetDetectedNodeCacheInfo | ( | const RobotRaconteur::NodeID & | nodeid | ) |
| 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.
| const boost::shared_ptr< RobotRaconteur::DynamicServiceFactory > RobotRaconteur::RobotRaconteurNode::GetDynamicServiceFactory | ( | ) |
Get the current DynamicServiceFactory. May be null.
See SetDynamicServiceFactory()
| 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.
| 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()
| RobotRaconteur_LogLevel RobotRaconteur::RobotRaconteurNode::GetLogLevel | ( | ) |
| boost::shared_ptr< LogRecordHandler > RobotRaconteur::RobotRaconteurNode::GetLogRecordHandler | ( | ) |
Get the currently configured log record handler.
If NULL, records are sent to std::cerr
| 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.
| boost::shared_ptr< MessageTap > RobotRaconteur::RobotRaconteurNode::GetMessageTap | ( | ) |
Get the active message tap.
| NodeDirectories RobotRaconteur::RobotRaconteurNode::GetNodeDirectories | ( | ) |
Get the current node directories.
Node directories are set to default if not configured
| 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
| std::string RobotRaconteur::RobotRaconteurNode::GetObjectServicePath | ( | const boost::shared_ptr< RRObject > & | obj | ) |
Get the service path of a client object.
| obj | The object to get the service path for |
|
virtual |
Get the Robot Raconteur type of a connected service object obj must be returned by ConnectService(), AsyncConnectService(), or an objref.
| obj | The object to query |
| 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.
| obj | Client object reference returned by ConnectService() or AsyncConnectService() |
| type | The name of the service type |
| 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.
| obj | Client object reference returned by ConnectService() or AsyncConnectService() |
|
inline |
Returns a random integer using the node's random number generator.
| T | The integer type, ie int32_t |
| min | The minimum value for the returned integer |
| max | The maximum value for the returned integer |
|
inline |
Returns a vector of random integer using the node's random number generator.
| T | The integer type, ie int32_t |
| count | The number of random integers to generate |
| min | The minimum value for the returned integers |
| max | The maximum value for the returned integers |
| 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
| count | The number of characters to return |
| std::vector< std::string > RobotRaconteur::RobotRaconteurNode::GetRegisteredServiceNames | ( | ) |
Get the names of registered services.
| std::vector< std::string > RobotRaconteur::RobotRaconteurNode::GetRegisteredServiceTypes | ( | ) |
Return names of registered service types.
| 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.
| std::string RobotRaconteur::RobotRaconteurNode::GetRobotRaconteurVersion | ( | ) |
Get the current RobotRaconteurVersion as a string.
Version is three numbers separated by dots, ie "0.9.2"
| boost::shared_ptr< ServerContext > RobotRaconteur::RobotRaconteurNode::GetService | ( | boost::string_ref | name | ) |
Gets a ServerContext for a service by name.
| name | The name of the service |
| 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()
| obj | The root object of the client to use to retrieve service attributes |
| 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
| obj | The root object of the client to use to retrieve service attributes |
| RobotRaconteur::NodeID RobotRaconteur::RobotRaconteurNode::GetServiceNodeID | ( | const boost::shared_ptr< RRObject > & | obj | ) |
| 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
| obj | The root object of the client to use to retrieve service attributes |
| boost::shared_ptr< ServiceFactory > RobotRaconteur::RobotRaconteurNode::GetServiceType | ( | boost::string_ref | type | ) |
Returns a previously registered service type.
| type | The name of the service type to retrieve |
| 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
| int32_t RobotRaconteur::RobotRaconteurNode::GetThreadPoolCount | ( | ) |
Get the number of threads for the node ThreadPool.
| 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
| 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.
| void RobotRaconteur::RobotRaconteurNode::HandleException | ( | const std::exception * | exp | ) |
Handle exceptino by passing the current exception to the handler function.
| exp | The exception to pass to the handler function |
| 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.
| 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
| endpoint | The LocalEndpoint id |
| bool RobotRaconteur::RobotRaconteurNode::IsServiceTypeRegistered | ( | boost::string_ref | servicetype | ) |
Check if a service type has been registered.
| servicetype | The name of the service to check |
| 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
| level | The level for the log message |
| message | The log message |
| 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
| record | The record to log |
| 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
| obj | The object to lock |
| timeout | The timeout in milliseconds to acquire the monitor lock, or RR_TIMEOUT_INFINITE |
| 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
| obj | The object previously locked by MonitorEnter() |
| 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.
| 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.
|
virtual |
The sync time of the node as a TimeSpec.
|
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.
|
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.
|
virtual |
The current node time as a TimeSpec.
The current node time as a TimeSpec. See NowNodeTime()
|
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
| 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.
| name | The name of the service, must follow member naming rules |
| servicetype | The name of the service definition containing the object type. Do not include the object type. |
| obj | The root object of the service |
| securitypolicy | An optional security policy for the service to control authentication and other security functions |
| 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
| c | The ServerContext to register |
| void RobotRaconteur::RobotRaconteurNode::RegisterServiceType | ( | const boost::shared_ptr< ServiceFactory > & | factory | ) |
Register a service type.
| factory | The service factory implementing the type to register |
| uint32_t RobotRaconteur::RobotRaconteurNode::RegisterTransport | ( | const boost::shared_ptr< Transport > & | transport | ) |
Register a transport for use by the node.
| transport |
| 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
| obj | The object previously locked |
| void RobotRaconteur::RobotRaconteurNode::RemovePeriodicCleanupTask | ( | const boost::shared_ptr< IPeriodicCleanupTask > & | task | ) |
Remove a task previously registered with AddPeriodicCleanupTask().
| task | The task to remove |
| 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
| obj | The object to lock. Must be returned by ConnectService or returned by an objref |
| flags | Select either a "User" or "Session" lock |
|
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.
|
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:
TODO: "rr+quic" QuicTransport
| urls | The candidate URLs |
| 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.
| f | The DynamicServiceFactory instance |
| 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.
| timeout | The timeout in milliseconds |
| 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
| handler | The handler function for uncaught exceptions |
| void RobotRaconteur::RobotRaconteurNode::SetLogLevel | ( | RobotRaconteur_LogLevel | level | ) |
Set the log level for the node.
Set RobotRaconteur_LogLevel_Disable to disable logging
| level | The desired log level |
| 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.
| env_variable_name | The environmental variable to use. Defaults to ROBOTRACONTEUR_LOG_LEVEL |
| 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
| level | The desired log level |
| 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
| handler | The log record handler function |
| 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.
| size | The max memory transfer size in bytes. |
| void RobotRaconteur::RobotRaconteurNode::SetMessageTap | ( | const boost::shared_ptr< MessageTap > & | message_tap | ) |
Set the a message tap to record log records and messages.
| message_tap | The message tap to use |
| void RobotRaconteur::RobotRaconteurNode::SetNodeDirectories | ( | const NodeDirectories & | dir | ) |
Set the node directories.
Sets the node directories. Cannot be set after GetNodeDirectories() is called
| dir | The new node directories |
| void RobotRaconteur::RobotRaconteurNode::SetNodeDiscoveryMaxCacheCount | ( | uint32_t | count | ) |
Set maximum number of detected nodes that will be cached.
See GetNodeDiscoveryMaxCacheCount() for more information
| count | The maximum number of detected nodes to cache |
| void RobotRaconteur::RobotRaconteurNode::SetNodeID | ( | const RobotRaconteur::NodeID & | id | ) |
| 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_\\.\\-]*$
| name |
| 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.
| timeout | Timeout in milliseconds |
| 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()
| pool | The ThreadPool for the node |
| 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
| count | The number of threads for the ThreadPool |
| 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
| factory | The ThreadPoolFactory for the node |
| 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.
| timeout | The timeout in milliseconds |
|
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:
Requires Multithreading
|
virtual |
Sleeps for a specified duration.
Normally will sleep based on the system clock, but in certain circumstances will use simulation time
Requires multithreading
| duration | The duration to sleep |
|
static |
Singleton shared_ptr accessor.
Same as s(), but returns a shared_ptr instead of a plain pointer.
| 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.
| url | The connection URL |
| username | An optional username for authentication |
| credentials | Optional credentials for authentication |
| objecttype | The desired root object proxy type. Optional but highly recommended. |
| 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.
| url | One or more candidate connection urls |
| username | An optional username for authentication |
| credentials | Optional credentials for authentication |
| objecttype | The desired root object proxy type. Optional but highly recommended. |
| 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.
| service_types | A std::vector of service types to listen for, ie com.robotraconteur.robotics.robot.Robot |
| filter | A filter to select individual services based on specified criteria |
| 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.
| service_types | A std::vector of service types to listen for, ie com.robotraconteur.robotics.robot.Robot |
| filter | A filter to select individual services based on specified criteria |
| 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
| nodeid | The NodeID of the requested node |
| nodeinfo2 | Out parameter for the node info |
| bool RobotRaconteur::RobotRaconteurNode::TryGetNodeID | ( | RobotRaconteur::NodeID & | id | ) |
| bool RobotRaconteur::RobotRaconteurNode::TryGetNodeName | ( | std::string & | node_name | ) |
Tries getting the current NodeName.
Gets the current NodeName. Returns false if NodeName is empty
| node_name | the NodeName if not empty |
| 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
| pool | Out parameter to receive ThreadPool shared_ptr |
|
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
| node | The node to handle the exception |
| exp | The exception to pass to the handler function |
|
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
| HandlerType |
| node | The node |
| h | The handler to post |
| shutdown_op | True if handler should be called during node shutdown |
| 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
| type |
| 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
| schemes | A vector of transport schemes, ie "rr+tcp", "rr+local", etc. to update. |
|
static |
Singleton weak_ptr accessor.
Same as sp(), but returns a weak_ptr instead of a shared_ptr.