|
Robot Raconteur Core C++ Library
|
Subscription for wire members that aggregates the values from client wire connections. More...
#include <Subscription.h>
Public Member Functions | |
| T | GetInValue (TimeSpec *time=NULL, typename boost::shared_ptr< WireConnection< T > > *connection=NULL) |
| Get the current InValue and metadata. | |
| bool | TryGetInValue (T &val, TimeSpec *time=NULL, typename boost::shared_ptr< WireConnection< T > > *connection=NULL) |
| Try getting the current InValue and metadata. | |
| void | SetOutValueAll (const T &val) |
| Set the OutValue for all active wire connections. | |
| event_connection | AddWireValueChangedListener (boost::function< void(const boost::shared_ptr< WireSubscription< T > > &, const T &, const TimeSpec &)> f) |
| Adds a wire value changed event listener function. | |
| bool | WaitInValueValid (int32_t timeout=RR_TIMEOUT_INFINITE) |
| Wait for a valid InValue to be received from a client. | |
| size_t | GetActiveWireConnectionCount () |
| Get the number of wire connections currently connected. | |
| bool | GetIgnoreInValue () |
| Get if InValue is currently being ignored. | |
| void | SetIgnoreInValue (bool ignore) |
| Set if InValue should be ignored. | |
| int32_t | GetInValueLifespan () |
| Get the InValue lifespan in milliseconds. | |
| void | SetInValueLifespan (int32_t millis) |
| Set the InValue lifespan in milliseconds. | |
| void | Close () |
| Closes the wire subscription. | |
Subscription for wire members that aggregates the values from client wire connections.
Wire subscriptions are created using the ServiceSubscription::SubscribeWire() function. This function takes the type of the wire value, the name of the wire member, and an optional service path of the service object that owns the wire member.
Wire subscriptions aggregate the InValue from all active wire connections. When a client connects, the wire subscriptions will automatically create wire connections to the wire member specified when the WireSubscription was created using ServiceSubscription::SubscribeWire(). The InValue of all the active wire connections are collected, and the most recent one is used as the current InValue of the wire subscription. The current value, the timespec, and the wire connection can be accessed using GetInValue() or TryGetInValue().
The lifespan of the InValue can be configured using SetInValueLifespan(). It is recommended that the lifespan be configured, so that the value will expire if the subscription stops receiving fresh in values.
The wire subscription can also be used to set the OutValue of all active wire connections. This behaves similar to a "reverse broadcaster", sending the same value to all connected services.
| T | The value type used by the wire |
|
inline |
Adds a wire value changed event listener function.
Add a listener function that is called when the InValue changes. The callback should have the signature:
void cb(WireSubscriptionPtr<T> wire_connection, const T& val, const TimeSpec& ts)
| f | The callback function |
|
inherited |
Closes the wire subscription.
Wire subscriptions are automatically closed when the parent ServiceSubscription is closed or when the node is shut down.
|
inherited |
Get the number of wire connections currently connected.
|
inherited |
Get if InValue is currently being ignored.
|
inline |
Get the current InValue and metadata.
Throws ValueNotSetException if no valid value is available
| time | [out] the LastValueReceivedTime of the InValue |
| connection | [out] the wire connection that received the InValue |
|
inherited |
Get the InValue lifespan in milliseconds.
Get the lifespan of InValue in milliseconds. The value will expire after the specified lifespan, becoming invalid. Use -1 for infinite lifespan.
|
inherited |
Set if InValue should be ignored.
See WireConnection::SetIgnoreInValue()
If true, InValue will be ignored for all wire connections.
| ignore |
|
inherited |
Set the InValue lifespan in milliseconds.
Set the lifespan of InValue in milliseconds. The value will expire after the specified lifespan, becoming invalid. Use -1 for infinite lifespan.
See also WireConnection::SetInValueLifespan()
| millis | The lifespan in milliseconds. -1 for infinite |
|
inline |
Set the OutValue for all active wire connections.
Behaves like a "reverse broadcaster". Calls WireConnection::SetOutValue() for all connected wire connections.
| T | The type of the value |
| val | The new OutValue |
|
inline |
Try getting the current InValue and metadata.
Same as GetInValue(), but returns a bool for success or failure instead of throwing an exception.
| val | [out] the current InValue |
| time | [out] the LastValueReceivedTime of the InValue |
| connection | [out] the wire connection that received the InValue |
|
inherited |
Wait for a valid InValue to be received from a client.
Blocks the current thread until value is received or timeout
| timeout | The timeout in milliseconds |