Robot Raconteur Core C++ Library
Loading...
Searching...
No Matches
RobotRaconteur::WireConnection< T > Class Template Reference

Wire connection used to transmit "most recent" values. More...

#include <WireMember.h>

Inheritance diagram for RobotRaconteur::WireConnection< T >:
RobotRaconteur::WireConnectionBase

Public Member Functions

boost::function< void(boost::shared_ptr< WireConnection< T > >)> GetWireConnectionClosedCallback ()
 Get the currently configured connection closed callback function.
void SetWireConnectionClosedCallback (boost::function< void(const boost::shared_ptr< WireConnection< T > > &)> callback)
 Set the connection closed callback function.
virtual T GetInValue ()
 Get the current InValue.
virtual T GetOutValue ()
 Get the current OutValue.
virtual void SetOutValue (typename boost::call_traits< T >::param_type value)
 Set the OutValue and transmit to the peer connection.
bool TryGetInValue (T &value, TimeSpec &time)
 Try getting the InValue, returning true on success or false on failure.
bool TryGetOutValue (T &value, TimeSpec &time)
 Try getting the OutValue, returning true on success or false on failure.
RR_OVIRTUAL void Close () RR_OVERRIDE
 Close the wire connection.
RR_OVIRTUAL void AsyncClose (boost::function< void(const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=2000) RR_OVERRIDE
 Asynchronously close the wire connection.
virtual uint32_t GetEndpoint ()
 Returns the Robot Raconteur node Endpoint ID.
virtual TimeSpec GetLastValueReceivedTime ()
 Get the timestamp of the last received value.
virtual TimeSpec GetLastValueSentTime ()
 Get the timestamp of the last sent value.
virtual bool GetInValueValid ()
 Get if the InValue is valid.
virtual bool GetOutValueValid ()
 Get if the OutValue is valid.
bool WaitInValueValid (int32_t timeout=RR_TIMEOUT_INFINITE)
 Waits for InValue to be valid.
bool WaitOutValueValid (int32_t timeout=RR_TIMEOUT_INFINITE)
 Waits for OutValue to be valid.
virtual bool GetIgnoreInValue ()
 Get if wire connection is ignoring incoming values.
virtual void SetIgnoreInValue (bool ignore)
 Set whether wire connection should ignore incoming values.
MemberDefinition_Direction Direction ()
 The direction of the wire.
virtual int32_t GetInValueLifespan ()
 Get the lifespan of InValue.
virtual void SetInValueLifespan (int32_t millis)
 Set the lifespan of InValue.
virtual int32_t GetOutValueLifespan ()
 Get the lifespan of OutValue.
virtual void SetOutValueLifespan (int32_t millis)
 Set the lifespan of OutValue.

Public Attributes

boost::signals2::signal< void(const boost::shared_ptr< WireConnection< T > > &connection, T value, TimeSpec time)> WireValueChanged
 Signal invoked when the InValue is changed.

Detailed Description

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

Wire connection used to transmit "most recent" values.

Wire connections are used to transmit "most recent" values between connected wire members. See Wire for more information on wire members.

Wire connections are created by clients using the Wire::Connect() or Wire::AsyncConnect() functions. Services receive incoming wire connection requests through a callback function specified using the Wire::SetWireConnectCallback() function. Services may also use the WireBroadcaster class to automate managing wire connection lifecycles and sending values to all connected clients, or use WireUnicastReceiver to receive an incoming value from the most recently connected client.

Wire connections are used to transmit "most recent" values between clients and services. Connection the wire creates a connection pair, one in the client, and one in the service. Each wire connection object has an InValue and an OutValue. Setting the OutValue of one will cause the specified value to be transmitted to the InValue of the peer. See Wire for more information.

Values can optionally be specified to have a finite lifespan using SetInValueLifespan() and SetOutValueLifespan(). Lifespans can be used to prevent using old values that have not been recently updated.

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

Template Parameters
TThe value data type

Member Function Documentation

◆ AsyncClose()

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

Asynchronously close the wire connection.

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::WireConnectionBase.

◆ Close()

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

Close the wire connection.

Close the wire connection. Blocks until close complete. The peer wire connection is destroyed automatically.

Reimplemented from RobotRaconteur::WireConnectionBase.

◆ Direction()

MemberDefinition_Direction RobotRaconteur::WireConnectionBase::Direction ( )
inherited

The direction of the wire.

Wires may be declared readonly or writeonly in the service definition file. (If neither is specified, the wire is assumed to be full duplex.) readonly wire may only send out values from service to client. writeonly wires may only send out values from client to service.

Returns
MemberDefinition_Direction

◆ GetEndpoint()

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

Returns the Robot Raconteur node Endpoint ID.

Returns the endpoint associated with the ClientContext or ServerEndpoint associated with the wire connection.

Returns
uint32_t The Robot Raconteur node Endpoint ID

◆ GetIgnoreInValue()

virtual bool RobotRaconteur::WireConnectionBase::GetIgnoreInValue ( )
virtualinherited

Get if wire connection is ignoring incoming values.

If true, wire connection is ignoring incoming values and is not storing the value

Returns
true Wire connection is ignoring incoming values
false Wire connection is not ignoring incoming values

◆ GetInValue()

template<typename T>
virtual T RobotRaconteur::WireConnection< T >::GetInValue ( )
inlinevirtual

Get the current InValue.

Gets the current InValue that was transmitted from the peer. Throws ValueNotSetException if no value has been received, or the most recent value lifespan has expired.

Returns
T The value

◆ GetInValueLifespan()

virtual int32_t RobotRaconteur::WireConnectionBase::GetInValueLifespan ( )
virtualinherited

Get the lifespan of InValue.

InValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after reception has expired, the InValue is cleared, and becomes invalid. Attempts to access InValue will result in a ValueNotSetException.

Returns
int32_t The lifespan in milliseconds

◆ GetInValueValid()

virtual bool RobotRaconteur::WireConnectionBase::GetInValueValid ( )
virtualinherited

Get if the InValue is valid.

The InValue is valid if a value has been received and the value has not expired

Returns
true The InValue is valid
false The OutValue is invalid

◆ GetLastValueReceivedTime()

virtual TimeSpec RobotRaconteur::WireConnectionBase::GetLastValueReceivedTime ( )
virtualinherited

Get the timestamp of the last received value.

Returns the timestamp of the value in the senders clock

Returns
TimeSpec The timestamp of the last received value

◆ GetLastValueSentTime()

virtual TimeSpec RobotRaconteur::WireConnectionBase::GetLastValueSentTime ( )
virtualinherited

Get the timestamp of the last sent value.

Returns the timestamp of the last sent value in the local clock

Returns
TimeSpec The timestamp of the last sent value

◆ GetOutValue()

template<typename T>
virtual T RobotRaconteur::WireConnection< T >::GetOutValue ( )
inlinevirtual

Get the current OutValue.

Gets the current OutValue that was transmitted to the peer. Throws ValueNotSetException if no value has been received, or the most recent value lifespan has expired.

Returns
T The value

◆ GetOutValueLifespan()

virtual int32_t RobotRaconteur::WireConnectionBase::GetOutValueLifespan ( )
virtualinherited

Get the lifespan of OutValue.

OutValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after sending has expired, the OutValue is cleared, and becomes invalid. Attempts to access OutValue will result in a ValueNotSetException.

Returns
int32_t The lifespan in milliseconds

◆ GetOutValueValid()

virtual bool RobotRaconteur::WireConnectionBase::GetOutValueValid ( )
virtualinherited

Get if the OutValue is valid.

The OutValue is valid if a value has been set using SetOutValue()

Returns
true The OutValue is valid
false The OutValue is invalid

◆ GetWireConnectionClosedCallback()

template<typename T>
boost::function< void(boost::shared_ptr< WireConnection< T > >)> RobotRaconteur::WireConnection< T >::GetWireConnectionClosedCallback ( )
inline

Get the currently configured connection closed callback function.

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

◆ SetIgnoreInValue()

virtual void RobotRaconteur::WireConnectionBase::SetIgnoreInValue ( bool ignore)
virtualinherited

Set whether wire connection should ignore incoming values.

Wire connections may optionally desire to ignore incoming values. This is useful if the connection is only being used to send out values, and received values may create a potential memory . If ignore is true, incoming values will be discarded.

Parameters
ignoreIf true, incoming values are ignored. If false, the most recent value is stored.

◆ SetInValueLifespan()

virtual void RobotRaconteur::WireConnectionBase::SetInValueLifespan ( int32_t millis)
virtualinherited

Set the lifespan of InValue.

InValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after reception has expired, the InValue is cleared and becomes invalid. Attempts to access InValue will result in ValueNotSetException.

InValue lifespans may be used to avoid using a stale value received by the wire. If the lifespan is not set, the wire will continue to return the last received value, even if the value is old.

Parameters
millisThe lifespan in millisecond, or RR_VALUE_LIFESPAN_INFINITE for infinite lifespan

◆ SetOutValue()

template<typename T>
virtual void RobotRaconteur::WireConnection< T >::SetOutValue ( typename boost::call_traits< T >::param_type value)
inlinevirtual

Set the OutValue and transmit to the peer connection.

Sets the OutValue for the wire connection. The specified value will be transmitted to the peer, and will become the peers InValue. The transmission is unreliable, meaning that values may be dropped if newer values arrive.

Parameters
valueThe new out value

◆ SetOutValueLifespan()

virtual void RobotRaconteur::WireConnectionBase::SetOutValueLifespan ( int32_t millis)
virtualinherited

Set the lifespan of OutValue.

OutValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after sending has expired, the OutValue is cleared and becomes invalid. Attempts to access OutValue will result in ValueNotSetException.

OutValue lifespans may be used to avoid using a stale value sent by the wire. If the lifespan is not set, the wire will continue to return the last sent value, even if the value is old.

Parameters
millisThe lifespan in millisecond, or RR_VALUE_LIFESPAN_INFINITE for infinite lifespan

◆ SetWireConnectionClosedCallback()

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

Set the connection closed callback function.

Sets a function to invoke when the wire connection has been closed.

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

Parameters
callbackThe callback function

◆ TryGetInValue()

template<typename T>
bool RobotRaconteur::WireConnection< T >::TryGetInValue ( T & value,
TimeSpec & time )
inline

Try getting the InValue, returning true on success or false on failure.

Get the current InValue and InValue timestamp. Return true or false on success or failure instead of throwing exception.

Parameters
value[out] The current InValue
time[out] The current InValue timestamp in the senders clock
Returns
true The InValue was valid
false The InValue was invalid. value and time are undefined

◆ TryGetOutValue()

template<typename T>
bool RobotRaconteur::WireConnection< T >::TryGetOutValue ( T & value,
TimeSpec & time )
inline

Try getting the OutValue, returning true on success or false on failure.

Get the current OutValue and OutValue timestamp. Return true or false on success and failure instead of throwing exception.

Parameters
value[out] The current OutValue
time[out] The current OutValue timestamp in the local clock
Returns
true The OutValue was valid
false The OutValue was invalid. value and time are undefined

◆ WaitInValueValid()

bool RobotRaconteur::WireConnectionBase::WaitInValueValid ( int32_t timeout = RR_TIMEOUT_INFINITE)
inherited

Waits for InValue to be valid.

Blocks the current thread until InValue is valid, with an optional timeout. Returns true if InValue is valid, or false if timeout occurred.

Parameters
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout
Returns
true The InValue is valid
false The InValue is invalid

◆ WaitOutValueValid()

bool RobotRaconteur::WireConnectionBase::WaitOutValueValid ( int32_t timeout = RR_TIMEOUT_INFINITE)
inherited

Waits for OutValue to be valid.

Blocks the current thread until OutValue is valid, with an optional timeout. Returns true if OutValue is valid, or false if timeout occurred.

Parameters
timeoutTimeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout
Returns
true The InValue is valid
false The InValue is invalid

Member Data Documentation

◆ WireValueChanged

template<typename T>
boost::signals2::signal<void(const boost::shared_ptr<WireConnection<T> >& connection, T value, TimeSpec time)> RobotRaconteur::WireConnection< T >::WireValueChanged

Signal invoked when the InValue is changed.

Callback function must accept three arguments, receiving the WireConnectionPtr<T> that received a packet, the new value, and the value's TimeSpec timestamp


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