WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::nt::GenericPublisher Class Reference

NetworkTables generic publisher. More...

#include <wpi/nt/GenericEntry.hpp>

Inheritance diagram for wpi::nt::GenericPublisher:
wpi::nt::Publisher wpi::nt::GenericEntry

Public Types

using TopicType = Topic
using ValueType = Value
using ParamType = const Value&
using TimestampedValueType = Value

Public Member Functions

 GenericPublisher ()=default
 GenericPublisher (NT_Publisher handle)
 Construct from a publisher handle; recommended to use Topic::GenericPublish() instead.
void Set (ParamType value)
 Publish a new value.
bool SetBoolean (bool value, int64_t time=0)
 Sets the entry's value.
bool SetInteger (int64_t value, int64_t time=0)
 Sets the entry's value.
bool SetFloat (float value, int64_t time=0)
 Sets the entry's value.
bool SetDouble (double value, int64_t time=0)
 Sets the entry's value.
bool SetString (std::string_view value, int64_t time=0)
 Sets the entry's value.
bool SetRaw (std::span< const uint8_t > value, int64_t time=0)
 Sets the entry's value.
bool SetBooleanArray (std::span< const bool > value, int64_t time=0)
 Sets the entry's value.
bool SetBooleanArray (std::span< const int > value, int64_t time=0)
 Sets the entry's value.
bool SetIntegerArray (std::span< const int64_t > value, int64_t time=0)
 Sets the entry's value.
bool SetFloatArray (std::span< const float > value, int64_t time=0)
 Sets the entry's value.
bool SetDoubleArray (std::span< const double > value, int64_t time=0)
 Sets the entry's value.
bool SetStringArray (std::span< const std::string > value, int64_t time=0)
 Sets the entry's value.
void SetDefault (ParamType value)
 Publish a default value.
bool SetDefaultBoolean (bool defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultInteger (int64_t defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultFloat (float defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultDouble (double defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultString (std::string_view defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultRaw (std::span< const uint8_t > defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultBooleanArray (std::span< const int > defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultIntegerArray (std::span< const int64_t > defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultFloatArray (std::span< const float > defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultDoubleArray (std::span< const double > defaultValue)
 Sets the entry's value if it does not exist.
bool SetDefaultStringArray (std::span< const std::string > defaultValue)
 Sets the entry's value if it does not exist.
TopicType GetTopic () const
 Get the corresponding topic.
Public Member Functions inherited from wpi::nt::Publisher
virtual ~Publisher ()
 Publisher (const Publisher &)=delete
Publisheroperator= (const Publisher &)=delete
 Publisher (Publisher &&rhs)
Publisheroperator= (Publisher &&rhs)
 operator bool () const
 Determines if the native handle is valid.
NT_Publisher GetHandle () const
 Gets the native handle for the publisher.
Topic GetTopic () const
 Gets the published-to topic.

Additional Inherited Members

Protected Member Functions inherited from wpi::nt::Publisher
 Publisher ()=default
 Publisher (NT_Publisher handle)
Protected Attributes inherited from wpi::nt::Publisher
NT_Publisher m_pubHandle {0}
 NetworkTables handle.

Detailed Description

NetworkTables generic publisher.

Member Typedef Documentation

◆ ParamType

◆ TimestampedValueType

◆ TopicType

◆ ValueType

Constructor & Destructor Documentation

◆ GenericPublisher() [1/2]

wpi::nt::GenericPublisher::GenericPublisher ( )
default

◆ GenericPublisher() [2/2]

wpi::nt::GenericPublisher::GenericPublisher ( NT_Publisher handle)
inlineexplicit

Construct from a publisher handle; recommended to use Topic::GenericPublish() instead.

Parameters
handleNative handle

Member Function Documentation

◆ GetTopic()

TopicType wpi::nt::GenericPublisher::GetTopic ( ) const
inline

Get the corresponding topic.

Returns
Topic

◆ Set()

void wpi::nt::GenericPublisher::Set ( ParamType value)
inline

Publish a new value.

Parameters
valuevalue to publish

◆ SetBoolean()

bool wpi::nt::GenericPublisher::SetBoolean ( bool value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetBooleanArray() [1/2]

bool wpi::nt::GenericPublisher::SetBooleanArray ( std::span< const bool > value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetBooleanArray() [2/2]

bool wpi::nt::GenericPublisher::SetBooleanArray ( std::span< const int > value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetDefault()

void wpi::nt::GenericPublisher::SetDefault ( ParamType value)
inline

Publish a default value.

On reconnect, a default value will never be used in preference to a published value.

Parameters
valuevalue

◆ SetDefaultBoolean()

bool wpi::nt::GenericPublisher::SetDefaultBoolean ( bool defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultBooleanArray()

bool wpi::nt::GenericPublisher::SetDefaultBooleanArray ( std::span< const int > defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultDouble()

bool wpi::nt::GenericPublisher::SetDefaultDouble ( double defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultDoubleArray()

bool wpi::nt::GenericPublisher::SetDefaultDoubleArray ( std::span< const double > defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultFloat()

bool wpi::nt::GenericPublisher::SetDefaultFloat ( float defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultFloatArray()

bool wpi::nt::GenericPublisher::SetDefaultFloatArray ( std::span< const float > defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultInteger()

bool wpi::nt::GenericPublisher::SetDefaultInteger ( int64_t defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultIntegerArray()

bool wpi::nt::GenericPublisher::SetDefaultIntegerArray ( std::span< const int64_t > defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultRaw()

bool wpi::nt::GenericPublisher::SetDefaultRaw ( std::span< const uint8_t > defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultString()

bool wpi::nt::GenericPublisher::SetDefaultString ( std::string_view defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDefaultStringArray()

bool wpi::nt::GenericPublisher::SetDefaultStringArray ( std::span< const std::string > defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
True if the entry did not already have a value, otherwise False

◆ SetDouble()

bool wpi::nt::GenericPublisher::SetDouble ( double value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetDoubleArray()

bool wpi::nt::GenericPublisher::SetDoubleArray ( std::span< const double > value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetFloat()

bool wpi::nt::GenericPublisher::SetFloat ( float value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetFloatArray()

bool wpi::nt::GenericPublisher::SetFloatArray ( std::span< const float > value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetInteger()

bool wpi::nt::GenericPublisher::SetInteger ( int64_t value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetIntegerArray()

bool wpi::nt::GenericPublisher::SetIntegerArray ( std::span< const int64_t > value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetRaw()

bool wpi::nt::GenericPublisher::SetRaw ( std::span< const uint8_t > value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetString()

bool wpi::nt::GenericPublisher::SetString ( std::string_view value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

◆ SetStringArray()

bool wpi::nt::GenericPublisher::SetStringArray ( std::span< const std::string > value,
int64_t time = 0 )
inline

Sets the entry's value.

Parameters
valuethe value to set
timethe timestamp to set (0 = wpi::nt::Now())
Returns
False if the entry exists with a different type

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