Robot Raconteur Core C++ Library
Public Member Functions | List of all members
RobotRaconteur::Callback< T > Class Template Referenceabstract

callback member type interface More...

Inherits boost::noncopyable.

Inherited by RobotRaconteur::CallbackClient< T >, and RobotRaconteur::CallbackServer< T >.

Public Member Functions

virtual T GetFunction ()=0
 Get the currently configured callback function on client side. More...
 
virtual void SetFunction (T value)=0
 Set the callback function reference on the client side. More...
 
virtual T GetClientFunction (const boost::shared_ptr< Endpoint > &endpoint)=0
 Get the proxy function to call the callback for the specified client on the service side. More...
 
virtual T GetClientFunction (uint32_t endpoint)=0
 Get the proxy function to call the callback for the specified client on the service side. More...
 
virtual std::string GetMemberName ()
 Get the member name of the callback. More...
 

Detailed Description

template<typename T>
class RobotRaconteur::Callback< T >

callback member type interface

The Callback class implements the callback member type. Callbacks are declared in service definition files using the callback keyword within object declarations. They provide functionality similar to the function member, but the direction is reversed, allowing the service to call a function on a specified client. The desired client is specified using the Robot Raconteur endpoint identifier. Clients must configure the callback to use using SetFunction().

On the client side, the client specifies a function for the callback using the SetFunction() function. On the service side, the function GetFunction(const RR_SHARED_PTR<Endpoint>& endpoint) is used to retrieve the proxy function to call a client callback.

This class is instantiated by the node. It should not be instantiated by the user.

Template Parameters
TThe type of the callback function. This is determined by the thunk source generator.

Member Function Documentation

◆ GetClientFunction() [1/2]

template<typename T >
virtual T RobotRaconteur::Callback< T >::GetClientFunction ( const boost::shared_ptr< Endpoint > &  endpoint)
pure virtual

Get the proxy function to call the callback for the specified client on the service side.

This function returns a proxy to the callback on a specified client. The proxy operates as a reverse function, sending parameters, executing the callback, and receiving the results.

Because services can have multiple clients, it is necessary to specify which client to call. This is done by passing the endpoint of the client connection to the endpoint parameter.

The endpoint of a client can be determined using the ServerEndpoint::CurrentEndpoint() function during a function or property member call. The service can store this value, and use it to retrieve the callback proxy.

Parameters
endpointThe endpoint of the client connection
Returns
T The callback proxy function

◆ GetClientFunction() [2/2]

template<typename T >
virtual T RobotRaconteur::Callback< T >::GetClientFunction ( uint32_t  endpoint)
pure virtual

Get the proxy function to call the callback for the specified client on the service side.

Same as GetClientFunction(const RR_SHARED_PTR<Endpoint>& endpoint), except the endpoint is specified using the uint32_t LocalEndpoint id instead of the Endpoint object.

Parameters
endpointThe uint32_t LocalEndpoint id
Returns
T The callback proxy function

◆ GetFunction()

template<typename T >
virtual T RobotRaconteur::Callback< T >::GetFunction ( )
pure virtual

Get the currently configured callback function on client side.

Returns
T The currently configured function

◆ GetMemberName()

template<typename T >
virtual std::string RobotRaconteur::Callback< T >::GetMemberName ( )
inlinevirtual

Get the member name of the callback.

Returns
std::string

◆ SetFunction()

template<typename T >
virtual void RobotRaconteur::Callback< T >::SetFunction ( value)
pure virtual

Set the callback function reference on the client side.

The callback function set will be made available to be called by the service using a function proxy.

Use lambda function or boost::bind to create the callback function reference

Parameters
valueThe callback function.

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