nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
nros::Stream< T > Class Template Reference

#include <stream.hpp>

Public Member Functions

bool is_valid () const
 Check if the stream is connected to a valid source.
 
Streamoperator= (Stream &&other) noexcept
 
 Stream ()
 Default constructor – creates an unbound stream.
 
 Stream (Stream &&other) noexcept
 
Result try_next (T &out)
 
Result wait_next (void *executor_handle, uint32_t timeout_ms, T &out, uint32_t poll_ms=10)
 

Friends

template<typename A >
class ActionClient
 
template<typename M >
class Subscription
 

Detailed Description

template<typename T>
class nros::Stream< T >

Multi-shot message receiver for subscriptions and feedback streams.

Unlike Future<T> (single-shot, move-only), Stream<T> yields multiple values over time. It wraps a non-blocking poll function and adds wait_next() for blocking reception with executor spin.

Usage:

auto& stream = sub.stream();
NROS_TRY(stream.wait_next(executor.handle(), 5000, msg));
Definition future.hpp:40
#define NROS_TRY(expr)
Definition result.hpp:90

Constructor & Destructor Documentation

◆ Stream() [1/2]

template<typename T >
nros::Stream< T >::Stream ( Stream< T > &&  other)
inlinenoexcept

◆ Stream() [2/2]

template<typename T >
nros::Stream< T >::Stream ( )
inline

Default constructor – creates an unbound stream.

Member Function Documentation

◆ is_valid()

template<typename T >
bool nros::Stream< T >::is_valid ( ) const
inline

Check if the stream is connected to a valid source.

◆ operator=()

template<typename T >
Stream & nros::Stream< T >::operator= ( Stream< T > &&  other)
inlinenoexcept

◆ try_next()

template<typename T >
Result nros::Stream< T >::try_next ( T out)
inline

Try to receive the next value (non-blocking).

Parameters
outOutput object (filled on success).
Returns
Result::success() if a value was received and deserialized; ErrorCode::TryAgain if no data is available right now; ErrorCode::NotInitialized if the stream is unbound; ErrorCode::Error if deserialization failed; otherwise the FFI error code.

◆ wait_next()

template<typename T >
Result nros::Stream< T >::wait_next ( void executor_handle,
uint32_t  timeout_ms,
T out,
uint32_t  poll_ms = 10 
)
inline

Block until the next value arrives, spinning the executor.

Parameters
executor_handleRaw executor handle.
timeout_msMaximum wait time in milliseconds.
outOutput object (filled on success).
poll_msPer-iteration spin_once timeout in ms (default 10). See Future::wait for the trade-off between latency and wakeup frequency.
Returns
Result::success(), ErrorCode::Timeout, or error.

Friends And Related Symbol Documentation

◆ ActionClient

template<typename T >
template<typename A >
friend class ActionClient
friend

◆ Subscription

template<typename T >
template<typename M >
friend class Subscription
friend

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