WPILibC++ 2024.3.2
nt::StructArraySubscriber< T, I > Class Template Reference

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

#include <networktables/StructArrayTopic.h>

Inheritance diagram for nt::StructArraySubscriber< T, I >:
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. More...
 
ValueType Get () const
 Get the last published value. More...
 
template<typename U >
ValueType Get (U &&defaultValue) const
 Get the last published value. More...
 
ValueType Get (std::span< const T > defaultValue) const
 Get the last published value. More...
 
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. More...
 
template<typename U >
TimestampedValueType GetAtomic (U &&defaultValue) const
 Get the last published value along with its timestamp. More...
 
TimestampedValueType GetAtomic (std::span< const T > defaultValue) const
 Get the last published value along with its timestamp. More...
 
std::vector< TimestampedValueTypeReadQueue ()
 Get an array of all valid value changes since the last call to ReadQueue. More...
 
TopicType GetTopic () const
 Get the corresponding topic. More...
 
- Public Member Functions inherited from nt::Subscriber
virtual ~Subscriber ()
 
 Subscriber (const Subscriber &)=delete
 
Subscriberoperator= (const Subscriber &)=delete
 
 Subscriber (Subscriber &&)
 
Subscriberoperator= (Subscriber &&)
 
 operator bool () const
 Determines if the native handle is valid. More...
 
NT_Subscriber GetHandle () const
 Gets the native handle for the subscriber. More...
 
bool Exists () const
 Determines if the topic is currently being published. More...
 
int64_t GetLastChange () const
 Gets the last time the value was changed. More...
 
Topic GetTopic () const
 Gets the subscribed-to topic. More...
 

Additional Inherited Members

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

Detailed Description

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

NetworkTables struct-encoded value array subscriber.

Member Typedef Documentation

◆ ParamType

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

◆ TimestampedValueType

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

◆ TopicType

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

◆ ValueType

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

Constructor & Destructor Documentation

◆ StructArraySubscriber() [1/2]

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

◆ StructArraySubscriber() [2/2]

template<typename T , typename... I>
template<typename U >
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 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 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 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 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 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 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 nt::StructArraySubscriber< T, I >::GetTopic ( ) const
inline

Get the corresponding topic.

Returns
Topic

◆ ReadQueue()

template<typename T , typename... I>
std::vector< TimestampedValueType > 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: