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

pipe member type interface More...

Inheritance diagram for RobotRaconteur::Pipe< T >:
RobotRaconteur::PipeBase

Public Member Functions

virtual boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &)> GetPipeConnectCallback ()=0
 Get the currently configured pipe endpoint connected callback function. More...
 
virtual void SetPipeConnectCallback (boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &)> function)=0
 Set the pipe endpoint connected callback function. More...
 
virtual boost::shared_ptr< PipeEndpoint< T > > Connect (int32_t index)=0
 Connect a pipe endpoint. More...
 
virtual void AsyncConnect (int32_t index, boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)=0
 Asynchronously connect a pipe endpoint. More...
 
virtual void AsyncConnect (boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &, const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=RR_TIMEOUT_INFINITE)
 Asynchronously connect a pipe endpoint. More...
 
virtual std::string GetMemberName ()=0
 Get the member name of the pipe. More...
 
MemberDefinition_Direction Direction ()
 The direction of the pipe. More...
 
bool IsUnreliable ()
 Get if pipe is declared unreliable. More...
 

Static Public Attributes

static const int32_t ANY_INDEX = -1
 Dynamically select pipe endpoint index. More...
 

Detailed Description

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

pipe member type interface

The Pipe class implements the pipe member type. Pipes are declared in service definition files using the pipe keyword within object declarations. Pipes provide reliable packet streaming between clients and services. They work by creating pipe endpoint pairs (peers), with one endpoint in the client, and one in the service. Packets are transmitted between endpoint pairs. Packets sent by one endpoint are received by the other, where they are placed in a receive queue. Received packets can then be retrieved from the receive queue.

Pipe endpoints are created by the client using the Connect() or AsyncConnect() functions. Services receive incoming connection requests through a callback function. This callback is configured using the SetPipeConnectCallback() function. Services may also use the PipeBroadcaster class to automate managing pipe endpoint lifecycles and sending packets to all connected client endpoints. If the SetPipeConnectCallback() function is used, the service is responsible for keeping track of endpoints as the connect and disconnect. See PipeEndpoint for details on sending and receiving packets.

Pipe endpoints are indexed, meaning that more than one endpoint pair can be created between the client and the service.

Pipes may be unreliable, meaning that packets may arrive out of order or be dropped. Use IsUnreliable() to check for unreliable pipes. The member modifier unreliable is used to specify that a pipe should be unreliable.

Pipes may be declared readonly or writeonly. If neither is specified, the pipe is assumed to be full duplex. readonly pipes may only send packets from service to client. writeonly pipes may only send packets from client to service. Use Direction() to determine the direction of the pipe.

The PipeBroadcaster is often used to simplify the use of Pipes. See PipeBroadcaster for more information.

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

Template Parameters
TThe packet data type

Member Function Documentation

◆ AsyncConnect() [1/2]

template<typename T >
virtual void RobotRaconteur::Pipe< T >::AsyncConnect ( boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &, const boost::shared_ptr< RobotRaconteurException > &)>  handler,
int32_t  timeout = RR_TIMEOUT_INFINITE 
)
inlinevirtual

Asynchronously connect a pipe endpoint.

Same as AsyncConnect(), but automatically selects a pipe endpoint index

Only valid on clients. Will throw InvalidOperationException on the service side.

Parameters
handlerA handler function to receive the connected endpoint, or an exception
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout

◆ AsyncConnect() [2/2]

template<typename T >
virtual void RobotRaconteur::Pipe< T >::AsyncConnect ( int32_t  index,
boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &, const boost::shared_ptr< RobotRaconteurException > &)>  handler,
int32_t  timeout = RR_TIMEOUT_INFINITE 
)
pure virtual

Asynchronously connect a pipe endpoint.

Same as Connect(), but returns asynchronously.

Only valid on clients. Will throw InvalidOperationException on the service side.

Parameters
indexThe index of the pipe endpoint, or ANY_INDEX to automatically select an index
handlerA handler function to receive the connected endpoint, or an exception
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout

◆ Connect()

template<typename T >
virtual boost::shared_ptr<PipeEndpoint<T> > RobotRaconteur::Pipe< T >::Connect ( int32_t  index)
pure virtual

Connect a pipe endpoint.

Creates a connected pipe endpoint pair, and returns the local endpoint. Use to create the streaming data connection to the service. Pipe endpoints are indexed, meaning that Connect() may be called multiple times for the same client connection to create multple pipe endpoint pairs. For most cases Pipe::ANY_INDEX (-1) can be used to automatically select an available index.

Only valid on clients. Will throw InvalidOperationException on the service side.

Parameters
indexThe index of the pipe endpoint, or ANY_INDEX to automatically select an index
Returns
RR_SHARED_PTR<PipeEndpoint<T> > The connected pipe endpoint

◆ Direction()

MemberDefinition_Direction RobotRaconteur::PipeBase::Direction ( )
inherited

The direction of the pipe.

Pipes may be declared readonly or writeonly in the service definition file. (If neither is specified, the pipe is assumed to be full duplex.) readonly pipes may only send packets from service to client. writeonly pipes may only send packets from client to service.

Returns
MemberDefinition_Direction

◆ GetMemberName()

virtual std::string RobotRaconteur::PipeBase::GetMemberName ( )
pure virtualinherited

Get the member name of the pipe.

Returns
std::string

◆ GetPipeConnectCallback()

template<typename T >
virtual boost::function<void(const boost::shared_ptr<PipeEndpoint<T> >&)> RobotRaconteur::Pipe< T >::GetPipeConnectCallback ( )
pure virtual

Get the currently configured pipe endpoint connected callback function.

Only valid for services. Will throw InvalidOperationException on client side.

Returns
boost::function<void(RR_SHARED_PTR<PipeEndpoint<T> >)> The currently configured callback function

◆ IsUnreliable()

bool RobotRaconteur::PipeBase::IsUnreliable ( )
inherited

Get if pipe is declared unreliable.

Pipe members may be declared as unreliable using member modifiers in the service definition. Pipes confirm unreliable operation when pipe endpoints are connected.

Returns
true The pipe is declared unreliable
false The pipe is declared reliable

◆ SetPipeConnectCallback()

template<typename T >
virtual void RobotRaconteur::Pipe< T >::SetPipeConnectCallback ( boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &)>  function)
pure virtual

Set the pipe endpoint connected callback function.

Callback function invoked when a client attempts to connect a pipe endpoint. The callback will receive the incoming pipe endpoint as a parameter. The service must maintain a reference to the pipe endpoint, but the pipe will retain ownership of the endpoint until it is closed. Using boost::weak_ptr to store the reference to the endpoint is recommended.

The callback may throw an exception to reject incoming connect request.

Note: Connect callback is configured automatically by PipeBroadcaster

Only valid for services. Will throw InvalidOperationException on the client side.

Parameters
functionCallback function to receive incoming pipe endpoint

Member Data Documentation

◆ ANY_INDEX

const int32_t RobotRaconteur::PipeBase::ANY_INDEX = -1
staticinherited

Dynamically select pipe endpoint index.

Pass to Connect() or AsyncConnect() to use any available endpoint index


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