WPILibC++ 2024.3.2
nt::GenericPublisher Class Reference

NetworkTables generic publisher. More...

#include <networktables/GenericEntry.h>

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

Additional Inherited Members

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

Detailed Description

NetworkTables generic publisher.

Member Typedef Documentation

◆ ParamType

◆ TimestampedValueType

◆ TopicType

◆ ValueType

Constructor & Destructor Documentation

◆ GenericPublisher() [1/2]

nt::GenericPublisher::GenericPublisher ( )
default

◆ GenericPublisher() [2/2]

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()

Topic nt::GenericPublisher::GetTopic ( ) const
inline

Get the corresponding topic.

Returns
Topic

◆ Set()

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

Publish a new value.

Parameters
valuevalue to publish

◆ SetBoolean()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetBooleanArray() [1/2]

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetBooleanArray() [2/2]

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetDefault()

void 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 nt::GenericPublisher::SetDefaultBoolean ( bool  defaultValue)
inline

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

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type

◆ SetDefaultBooleanArray()

bool 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
False if the entry exists with a different type

◆ SetDefaultDouble()

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

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

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type

◆ SetDefaultDoubleArray()

bool 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
False if the entry exists with a different type

◆ SetDefaultFloat()

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

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

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type

◆ SetDefaultFloatArray()

bool 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
False if the entry exists with a different type

◆ SetDefaultInteger()

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

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

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type

◆ SetDefaultIntegerArray()

bool 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
False if the entry exists with a different type

◆ SetDefaultRaw()

bool 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
False if the entry exists with a different type

◆ SetDefaultString()

bool 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
False if the entry exists with a different type

◆ SetDefaultStringArray()

bool 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
False if the entry exists with a different type

◆ SetDouble()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetDoubleArray()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetFloat()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetFloatArray()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetInteger()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetIntegerArray()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetRaw()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetString()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

◆ SetStringArray()

bool 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 = nt::Now())
Returns
False if the entry exists with a different type

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