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

Pipe endpoint used to transmit reliable or unreliable data streams. More...

Inheritance diagram for RobotRaconteur::PipeEndpoint< T >:
RobotRaconteur::PipeEndpointBase

Public Member Functions

boost::function< void(boost::shared_ptr< PipeEndpoint< T > >)> GetPipeEndpointClosedCallback ()
 Get the currently configured endpoint closed callback function. More...
 
void SetPipeEndpointClosedCallback (boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &)> callback)
 Set the endpoint closed callback function. More...
 
virtual uint32_t SendPacket (typename boost::call_traits< T >::param_type packet)
 Sends a packet to the peer endpoint. More...
 
virtual void AsyncSendPacket (typename boost::call_traits< T >::param_type packet, boost::function< void(uint32_t, const boost::shared_ptr< RobotRaconteurException > &)> handler)
 Send a packet to the peer endpoint asynchronously. More...
 
virtual T ReceivePacket ()
 Receive the next packet in the receive queue. More...
 
virtual T PeekNextPacket ()
 Peeks the next packet in the receive queue. More...
 
virtual T ReceivePacketWait (int32_t timeout=RR_TIMEOUT_INFINITE)
 Receive the next packet in the receive queue, block if queue is empty. More...
 
virtual T PeekNextPacketWait (int32_t timeout=RR_TIMEOUT_INFINITE)
 Peek the next packet in the receive queue, block if queue is empty. More...
 
virtual bool TryReceivePacketWait (T &val, int32_t timeout=RR_TIMEOUT_INFINITE, bool peek=false)
 Try receiving a packet, optionally blocking if the queue is empty. More...
 
RR_OVIRTUAL void Close () RR_OVERRIDE
 Close the pipe endpoint. More...
 
RR_OVIRTUAL void AsyncClose (boost::function< void(const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=2000) RR_OVERRIDE
 Asynchronously close the pipe endpoint. More...
 
virtual int32_t GetIndex ()
 Returns the pipe endpoint index used when endpoint connected. More...
 
virtual uint32_t GetEndpoint ()
 Returns the Robot Raconteur node Endpoint ID. More...
 
bool GetRequestPacketAck ()
 Get if pipe endpoint is requesting acks. More...
 
void SetRequestPacketAck (bool ack)
 Set if pipe endpoint should request packet acks. More...
 
virtual size_t Available ()
 Return number of packets in the receive queue. More...
 
bool IsUnreliable ()
 Get if pipe endpoint is unreliable. More...
 
MemberDefinition_Direction Direction ()
 The direction of the pipe. More...
 
bool GetIgnoreReceived ()
 Get if pipe endpoint is ignoring incoming packets. More...
 
void SetIgnoreReceived (bool ignore)
 Set whether pipe endpoint should ignore incoming packets. More...
 

Public Attributes

boost::signals2::signal< void(const boost::shared_ptr< PipeEndpoint< T > > &)> PacketReceivedEvent
 Signal called when a packet has been received. More...
 
boost::signals2::signal< void(const boost::shared_ptr< PipeEndpoint< T > > &, uint32_t)> PacketAckReceivedEvent
 Signal called when a packet ack has been received. More...
 

Detailed Description

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

Pipe endpoint used to transmit reliable or unreliable data streams.

Pipe endpoints are used to communicate data between connected pipe members. See Pipe for more information on pipe members.

Pipe endpoints are created by clients using the Pipe::Connect() or Pipe::AsyncConnect() functions. Services receive incoming pipe endpoint connection requests through a callback function specified using the Pipe::SetPipeConnectCallback() function. Services may also use the PipeBroadcaster class to automate managing pipe endpoint lifecycles and sending packets to all connected client endpoints.

Pipe endpoints are indexed, meaning that more than one pipe endpoint pair can be created using the same member. This means that multiple data streams can be created independent of each other between the client and service using the same member.

Pipes send reliable packet streams between connected client/service endpoint pairs. Packets are sent using the SendPacket() or AsyncSendPacket() functions. Packets are read from the receive queue using the ReceivePacket(), ReceivePacketWait(), TryReceivePacketWait(), TryReceivePacketWait(), or PeekNextPacket(). The endpoint is closed using the Close() or AsyncClose() function.

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

Template Parameters
TThe packet data type

Member Function Documentation

◆ AsyncClose()

template<typename T >
RR_OVIRTUAL void RobotRaconteur::PipeEndpoint< T >::AsyncClose ( boost::function< void(const boost::shared_ptr< RobotRaconteurException > &)>  handler,
int32_t  timeout = 2000 
)
inlinevirtual

Asynchronously close the pipe endpoint.

Same as Close() but returns asynchronously

Parameters
handlerA handler function to call on completion, possibly with an exception
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout

Reimplemented from RobotRaconteur::PipeEndpointBase.

◆ AsyncSendPacket()

template<typename T >
virtual void RobotRaconteur::PipeEndpoint< T >::AsyncSendPacket ( typename boost::call_traits< T >::param_type  packet,
boost::function< void(uint32_t, const boost::shared_ptr< RobotRaconteurException > &)>  handler 
)
inlinevirtual

Send a packet to the peer endpoint asynchronously.

Same as SendPacket(), but returns asynchronously.

Parameters
packetThe packet to send
handlerA handler function to receive the sent packet number or an exception

◆ Available()

virtual size_t RobotRaconteur::PipeEndpointBase::Available ( )
virtualinherited

Return number of packets in the receive queue.

Invalid for writeonly pipes.

Returns
size_t The number of packets in the receive queue

◆ Close()

template<typename T >
RR_OVIRTUAL void RobotRaconteur::PipeEndpoint< T >::Close ( )
inlinevirtual

Close the pipe endpoint.

Close the pipe endpoint. Blocks until close complete. The peer endpoint is destroyed automatically.

Reimplemented from RobotRaconteur::PipeEndpointBase.

◆ Direction()

MemberDefinition_Direction RobotRaconteur::PipeEndpointBase::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

◆ GetEndpoint()

virtual uint32_t RobotRaconteur::PipeEndpointBase::GetEndpoint ( )
virtualinherited

Returns the Robot Raconteur node Endpoint ID.

Returns the endpoint associated with the ClientContext or ServerEndpoint associated with the pipe endpoint.

Returns
uint32_t The Robot Raconteur node Endpoint ID

◆ GetIgnoreReceived()

bool RobotRaconteur::PipeEndpointBase::GetIgnoreReceived ( )
inherited

Get if pipe endpoint is ignoring incoming packets.

If true, pipe endpoint is ignoring incoming packets and is not adding incoming packets to the receive queue.

Returns
true Pipe endpoint is ignoring incoming packets
false Pipe endpoint is not ignoring incoming packets

◆ GetIndex()

virtual int32_t RobotRaconteur::PipeEndpointBase::GetIndex ( )
virtualinherited

Returns the pipe endpoint index used when endpoint connected.

Returns
int32_t The pipe endpoint index

◆ GetPipeEndpointClosedCallback()

template<typename T >
boost::function<void(boost::shared_ptr<PipeEndpoint<T> >)> RobotRaconteur::PipeEndpoint< T >::GetPipeEndpointClosedCallback ( )
inline

Get the currently configured endpoint closed callback function.

Returns
boost::function<void (RR_SHARED_PTR<PipeEndpoint<T> >)>

◆ GetRequestPacketAck()

bool RobotRaconteur::PipeEndpointBase::GetRequestPacketAck ( )
inherited

Get if pipe endpoint is requesting acks.

Returns
true The pipe endpoint is requesting acks
false The pipe endpoint is not requesting acks

◆ IsUnreliable()

bool RobotRaconteur::PipeEndpointBase::IsUnreliable ( )
inherited

Get if pipe endpoint is 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 endpoint is unreliable
false The pipe endpoint is reliable

◆ PeekNextPacket()

template<typename T >
virtual T RobotRaconteur::PipeEndpoint< T >::PeekNextPacket ( )
inlinevirtual

Peeks the next packet in the receive queue.

Returns the first packet in the receive queue, but does not remove it from the queue. Throws an InvalidOperationException if there are no packets in the receive queue.

Returns
T The next packet in the receive queue

◆ PeekNextPacketWait()

template<typename T >
virtual T RobotRaconteur::PipeEndpoint< T >::PeekNextPacketWait ( int32_t  timeout = RR_TIMEOUT_INFINITE)
inlinevirtual

Peek the next packet in the receive queue, block if queue is empty.

Same as PeekPacket(), but blocks if queue is empty

Parameters
timeoutTimeout in milliseconds to wait for a packet, or RR_TIMEOUT_INFINITE for no timeout
Returns
T The received packet

◆ ReceivePacket()

template<typename T >
virtual T RobotRaconteur::PipeEndpoint< T >::ReceivePacket ( )
inlinevirtual

Receive the next packet in the receive queue.

Receive the next packet from the receive queue. This function will throw an InvalidOperationException if there are no packets in the receive queue. Use ReceivePacketWait() to block until a packet has been received.

Returns
T The received packet

◆ ReceivePacketWait()

template<typename T >
virtual T RobotRaconteur::PipeEndpoint< T >::ReceivePacketWait ( int32_t  timeout = RR_TIMEOUT_INFINITE)
inlinevirtual

Receive the next packet in the receive queue, block if queue is empty.

Same as ReceivePacket(), but blocks if queue is empty

Parameters
timeoutTimeout in milliseconds to wait for a packet, or RR_TIMEOUT_INFINITE for no timeout
Returns
T The received packet

◆ SendPacket()

template<typename T >
virtual uint32_t RobotRaconteur::PipeEndpoint< T >::SendPacket ( typename boost::call_traits< T >::param_type  packet)
inlinevirtual

Sends a packet to the peer endpoint.

Sends a packet to the peer endpoint. If the pipe is reliable, the packetsare guaranteed to arrive in order. If the pipe is set to unreliable, "best effort" is made to deliver packets, and they are not guaranteed to arrive in order. This function will block until the packet has been transmitted by the transport. It will return before the peer endpoint has received the packet.

Parameters
packetThe packet to send
Returns
uint32_t The packet number of the sent packet

◆ SetIgnoreReceived()

void RobotRaconteur::PipeEndpointBase::SetIgnoreReceived ( bool  ignore)
inherited

Set whether pipe endpoint should ignore incoming packets.

Pipe endpoints may optionally desire to ignore incoming data. This is useful if the endpoint is only being used to send packets, and received packets may create a potential memory leak if they are not being removed from the queue. If ignore is true, incoming packets will be discarded and will not be added to the receive queue.

Parameters
ignoreIf true, incoming packets are ignored. If false, the packets are added to the receive queue.

◆ SetPipeEndpointClosedCallback()

template<typename T >
void RobotRaconteur::PipeEndpoint< T >::SetPipeEndpointClosedCallback ( boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &)>  callback)
inline

Set the endpoint closed callback function.

Sets a function to invoke when the pipe endpoint has been closed.

Callback function must accept one argument, receiving the PipeEndpointPtr<T> that was closed.

Parameters
callbackThe callback function

◆ SetRequestPacketAck()

void RobotRaconteur::PipeEndpointBase::SetRequestPacketAck ( bool  ack)
inherited

Set if pipe endpoint should request packet acks.

Packet acks are generated by receiving endpoints to inform the sender that a packet has been received. The ack contains the packet index, the sequence number of the packet. Packet acks are used for flow control by PipeBroadcaster.

Parameters
acktrue to request packet acks, otherwise false

◆ TryReceivePacketWait()

template<typename T >
virtual bool RobotRaconteur::PipeEndpoint< T >::TryReceivePacketWait ( T &  val,
int32_t  timeout = RR_TIMEOUT_INFINITE,
bool  peek = false 
)
inlinevirtual

Try receiving a packet, optionally blocking if the queue is empty.

Try receiving a packet with various options. Returns true if a packet has been received, or false if no packet is available instead of throwing an exception on failure. The timeout and peek parameters can be used to modify behavior to provide functionality similar to the various Receive and Peek functions.

Parameters
val[out] The received packet
timeoutThe timeout in milliseconds. Set to zero for non-blocking operation, an arbitrary value in milliseconds for a finite duration timeout, or RR_TIMEOUT_INFINITE for no timeout
peekIf true, the packet is not removed from the receive queue
Returns
true A packet has been successfully received
false No packet has been received. The content of val is undefined.

Member Data Documentation

◆ PacketAckReceivedEvent

template<typename T >
boost::signals2::signal<void(const boost::shared_ptr<PipeEndpoint<T> >&, uint32_t)> RobotRaconteur::PipeEndpoint< T >::PacketAckReceivedEvent

Signal called when a packet ack has been received.

Packet acks are generated if SetRequestPacketAck() is set to true. The receiving endpoint generates acks to inform the sender that the packet has been received.

Callback function must accept two arguments, receiving the PipeEndpointPtr<T> that received the packet ack and the packet number that is being acked.

◆ PacketReceivedEvent

template<typename T >
boost::signals2::signal<void(const boost::shared_ptr<PipeEndpoint<T> >&)> RobotRaconteur::PipeEndpoint< T >::PacketReceivedEvent

Signal called when a packet has been received.

Callback function must accept one argument, receiving the PipeEndpointPtr<T> that received a packet


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