WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::nt::StructArraySubscriber< T, I > Class Template Reference

NetworkTables struct-encoded value array subscriber. More...

#include <wpi/nt/StructArrayTopic.hpp>

Inheritance diagram for wpi::nt::StructArraySubscriber< T, I >:
wpi::nt::Subscriber

Public Types

using TopicType = StructArrayTopic<T, I...>
using ValueType = std::vector<T>
using ParamType = std::span<const T>
using TimestampedValueType = Timestamped<ValueType>

Public Member Functions

 StructArraySubscriber ()=default
template<typename U>
 StructArraySubscriber (NT_Subscriber handle, U &&defaultValue, I... info)
 Construct from a subscriber handle; recommended to use StructTopic::Subscribe() instead.
ValueType Get () const
 Get the last published value.
template<typename U>
ValueType Get (U &&defaultValue) const
 Get the last published value.
ValueType Get (std::span< const T > defaultValue) const
 Get the last published value.
TimestampedValueType GetAtomic () const
 Get the last published value along with its timestamp If no value has been published or the value cannot be unpacked, returns the stored default value and a timestamp of 0.
template<typename U>
TimestampedValueType GetAtomic (U &&defaultValue) const
 Get the last published value along with its timestamp.
TimestampedValueType GetAtomic (std::span< const T > defaultValue) const
 Get the last published value along with its timestamp.
std::vector< TimestampedValueTypeReadQueue ()
 Get an array of all valid value changes since the last call to ReadQueue.
TopicType GetTopic () const
 Get the corresponding topic.
Public Member Functions inherited from wpi::nt::Subscriber
virtual ~Subscriber ()
 Subscriber (const Subscriber &)=delete
Subscriberoperator= (const Subscriber &)=delete
 Subscriber (Subscriber &&rhs)
Subscriberoperator= (Subscriber &&rhs)
 operator bool () const
 Determines if the native handle is valid.
NT_Subscriber GetHandle () const
 Gets the native handle for the subscriber.
bool Exists () const
 Determines if the topic is currently being published.
int64_t GetLastChange () const
 Gets the last time the value was changed.
Topic GetTopic () const
 Gets the subscribed-to topic.

Additional Inherited Members

Protected Member Functions inherited from wpi::nt::Subscriber
 Subscriber ()=default
 Subscriber (NT_Subscriber handle)
Protected Attributes inherited from wpi::nt::Subscriber
NT_Subscriber m_subHandle {0}

Detailed Description

template<typename T, typename... I>
requires wpi::util::StructSerializable<T, I...>
class wpi::nt::StructArraySubscriber< T, I >

NetworkTables struct-encoded value array subscriber.

Member Typedef Documentation

◆ ParamType

template<typename T, typename... I>
using wpi::nt::StructArraySubscriber< T, I >::ParamType = std::span<const T>

◆ TimestampedValueType

template<typename T, typename... I>
using wpi::nt::StructArraySubscriber< T, I >::TimestampedValueType = Timestamped<ValueType>

◆ TopicType

template<typename T, typename... I>
using wpi::nt::StructArraySubscriber< T, I >::TopicType = StructArrayTopic<T, I...>

◆ ValueType

template<typename T, typename... I>
using wpi::nt::StructArraySubscriber< T, I >::ValueType = std::vector<T>

Constructor & Destructor Documentation

◆ StructArraySubscriber() [1/2]

template<typename T, typename... I>
wpi::nt::StructArraySubscriber< T, I >::StructArraySubscriber ( )
default

◆ StructArraySubscriber() [2/2]

template<typename T, typename... I>
template<typename U>
wpi::nt::StructArraySubscriber< T, I >::StructArraySubscriber ( NT_Subscriber handle,
U && defaultValue,
I... info )
inline

Construct from a subscriber handle; recommended to use StructTopic::Subscribe() instead.

Parameters
handleNative handle
defaultValueDefault value
infooptional struct type info

Member Function Documentation

◆ Get() [1/3]

template<typename T, typename... I>
ValueType wpi::nt::StructArraySubscriber< T, I >::Get ( ) const
inline

Get the last published value.

If no value has been published or the value cannot be unpacked, returns the stored default value.

Returns
value

◆ Get() [2/3]

template<typename T, typename... I>
ValueType wpi::nt::StructArraySubscriber< T, I >::Get ( std::span< const T > defaultValue) const
inline

Get the last published value.

If no value has been published or the value cannot be unpacked, returns the passed defaultValue.

Parameters
defaultValuedefault value to return if no value has been published
Returns
value

◆ Get() [3/3]

template<typename T, typename... I>
template<typename U>
ValueType wpi::nt::StructArraySubscriber< T, I >::Get ( U && defaultValue) const
inline

Get the last published value.

If no value has been published or the value cannot be unpacked, returns the passed defaultValue.

Parameters
defaultValuedefault value to return if no value has been published
Returns
value

◆ GetAtomic() [1/3]

template<typename T, typename... I>
TimestampedValueType wpi::nt::StructArraySubscriber< T, I >::GetAtomic ( ) const
inline

Get the last published value along with its timestamp If no value has been published or the value cannot be unpacked, returns the stored default value and a timestamp of 0.

Returns
timestamped value

◆ GetAtomic() [2/3]

template<typename T, typename... I>
TimestampedValueType wpi::nt::StructArraySubscriber< T, I >::GetAtomic ( std::span< const T > defaultValue) const
inline

Get the last published value along with its timestamp.

If no value has been published or the value cannot be unpacked, returns the passed defaultValue and a timestamp of 0.

Parameters
defaultValuedefault value to return if no value has been published
Returns
timestamped value

◆ GetAtomic() [3/3]

template<typename T, typename... I>
template<typename U>
TimestampedValueType wpi::nt::StructArraySubscriber< T, I >::GetAtomic ( U && defaultValue) const
inline

Get the last published value along with its timestamp.

If no value has been published or the value cannot be unpacked, returns the passed defaultValue and a timestamp of 0.

Parameters
defaultValuedefault value to return if no value has been published
Returns
timestamped value

◆ GetTopic()

template<typename T, typename... I>
TopicType wpi::nt::StructArraySubscriber< T, I >::GetTopic ( ) const
inline

Get the corresponding topic.

Returns
Topic

◆ ReadQueue()

template<typename T, typename... I>
std::vector< TimestampedValueType > wpi::nt::StructArraySubscriber< T, I >::ReadQueue ( )
inline

Get an array of all valid value changes since the last call to ReadQueue.

Also provides a timestamp for each value. Values that cannot be unpacked are dropped.

Note
The "poll storage" subscribe option can be used to set the queue depth.
Returns
Array of timestamped values; empty array if no valid new changes have been published since the previous call.

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