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

Receive the InValue from the most recent connection. More...

#include <WireMember.h>

Public Member Functions

void Init (const boost::shared_ptr< T > &wire)
 Initialize the WireUnicastReceiver.
GetInValue (TimeSpec &ts, uint32_t &ep)
 Get the current InValue.
bool TryGetInValue (U &value, TimeSpec &ts, uint32_t &ep)
 Try getting the current InValue, returning true on success or false on failure.
int32_t GetInValueLifespan ()
 Get the lifespan of InValue.
void SetInValueLifespan (int32_t millis)
 Set the lifespan of InValue.

Public Attributes

boost::signals2::signal< void(const U &, const TimeSpec &, const uint32_t &)> InValueChanged
 Signal invoked when the InValue has changed.

Detailed Description

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

Receive the InValue from the most recent connection.

WireUnicastReceiver is used by services to receive a value from a single client. When a client sets its OutValue, this value is transmitted to the service using packets, and becomes the service's InValue for that connection. Service wires can have multiple active clients, so the service needs to choose which connection is "active". The WireUnicastReceiver selects the "most recent" connection, and returns that connection's InValue. Any existing connections are closed. WireUnicastReceiver should only be used with wires that are declared writeonly. It is recommended that object locks be used to protect from concurrent access when unicast receivers are used.

WireUnicastReceiver is initialized by the user, or by default implementation classes generated by RobotRaconteurGen (_default_impl). Default implementation classes will automatically instantiate unicast receivers for wires marked *writeonly. If default implementation classes are not used, the unicast receiver must be instantiated manually. It is recommended this be done using the IRRServiceObject interface in the overridden IRRServiceObject::RRServiceObjectInit() function. This function is called after the wires have been instantiated by the service.

The current InValue is received using GetInValue() or TryGetInValue(). The InValueChanged signal can be used to monitor for changes to the InValue.

Clients may also use PokeOutValue() or AsyncPokeOutValue() to update the unicast receiver's value.

Template Parameters
TThe value type

Member Function Documentation

◆ GetInValue()

template<typename T, typename U>
U RobotRaconteur::WireUnicastReceiverBase< T, U >::GetInValue ( TimeSpec & ts,
uint32_t & ep )
inlineinherited

Get the current InValue.

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

Parameters
ts[out] The current InValue timestamp
ep[out] The client endpoint ID of the InValue
Returns
U The current InValue

◆ GetInValueLifespan()

template<typename T, typename U>
int32_t RobotRaconteur::WireUnicastReceiverBase< T, U >::GetInValueLifespan ( )
inlineinherited

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

◆ Init()

template<typename T, typename U>
void RobotRaconteur::WireUnicastReceiverBase< T, U >::Init ( const boost::shared_ptr< T > & wire)
inlineinherited

Initialize the WireUnicastReceiver.

Initialize the WireUnicastReceiver. Must be called after construction.

Parameters
wireThe wire to use for broadcasting. Must be a wire from a service object. Specifying a client wire will result in an exception.

◆ SetInValueLifespan()

template<typename T, typename U>
void RobotRaconteur::WireUnicastReceiverBase< T, U >::SetInValueLifespan ( int32_t millis)
inlineinherited

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

◆ TryGetInValue()

template<typename T, typename U>
bool RobotRaconteur::WireUnicastReceiverBase< T, U >::TryGetInValue ( U & value,
TimeSpec & ts,
uint32_t & ep )
inlineinherited

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

Gets the current InValue, its timestamp, and the client endpoint ID. Returns true if value is valid, or false if value is invalid. Value will be invalid if no value has been received, or the value lifespan has expired.

Parameters
value[out] The current InValue
ts[out] The current InValue timestamp
ep[out] The client endpoint ID of the InValue
Returns
true value is valid
false value is invalid

Member Data Documentation

◆ InValueChanged

template<typename T, typename U>
boost::signals2::signal<void(const U&, const TimeSpec&, const uint32_t&)> RobotRaconteur::WireUnicastReceiverBase< T, U >::InValueChanged
inherited

Signal invoked when the InValue has changed.

Callback function must accept three arguments, receiving the new value, value's TimeSpec timestamp, and the client endpoint ID.


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