WPILibC++ 2024.3.2
nt::StringArrayTopic Class Referencefinal

NetworkTables StringArray topic. More...

#include </home/runner/work/allwpilib/allwpilib/ntcore/src/generated/main/native/include/networktables/StringArrayTopic.h>

Inheritance diagram for nt::StringArrayTopic:
nt::Topic

Public Types

using SubscriberType = StringArraySubscriber
 
using PublisherType = StringArrayPublisher
 
using EntryType = StringArrayEntry
 
using ValueType = std::vector< std::string >
 
using ParamType = std::span< const std::string >
 
using TimestampedValueType = TimestampedStringArray
 

Public Member Functions

 StringArrayTopic ()=default
 
 StringArrayTopic (NT_Topic handle)
 Construct from a topic handle; recommended to use NetworkTableInstance::GetStringArrayTopic() instead. More...
 
 StringArrayTopic (Topic topic)
 Construct from a generic topic. More...
 
SubscriberType Subscribe (ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new subscriber to the topic. More...
 
SubscriberType SubscribeEx (std::string_view typeString, ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new subscriber to the topic, with specific type string. More...
 
PublisherType Publish (const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new publisher to the topic. More...
 
PublisherType PublishEx (std::string_view typeString, const wpi::json &properties, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new publisher to the topic, with type string and initial properties. More...
 
EntryType GetEntry (ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new entry for the topic. More...
 
EntryType GetEntryEx (std::string_view typeString, ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new entry for the topic, with specific type string. More...
 
- Public Member Functions inherited from nt::Topic
 Topic ()=default
 
 Topic (NT_Topic handle)
 
 operator bool () const
 Determines if the native handle is valid. More...
 
NT_Topic GetHandle () const
 Gets the native handle for the topic. More...
 
NetworkTableInstance GetInstance () const
 Gets the instance for the topic. More...
 
std::string GetName () const
 Gets the name of the topic. More...
 
NetworkTableType GetType () const
 Gets the type of the topic. More...
 
std::string GetTypeString () const
 Gets the type string of the topic. More...
 
void SetPersistent (bool persistent)
 Make value persistent through server restarts. More...
 
bool IsPersistent () const
 Returns whether the value is persistent through server restarts. More...
 
void SetRetained (bool retained)
 Make the server retain the topic even when there are no publishers. More...
 
bool IsRetained () const
 Returns whether the topic is retained by server when there are no publishers. More...
 
void SetCached (bool cached)
 Allow storage of the topic's last value, allowing the value to be read (and not just accessed through event queues and listeners). More...
 
bool IsCached () const
 Returns whether the topic's last value is stored. More...
 
bool Exists () const
 Determines if the topic is currently being published. More...
 
wpi::json GetProperty (std::string_view name) const
 Gets the current value of a property (as a JSON object). More...
 
void SetProperty (std::string_view name, const wpi::json &value)
 Sets a property value. More...
 
void DeleteProperty (std::string_view name)
 Deletes a property. More...
 
wpi::json GetProperties () const
 Gets all topic properties as a JSON object. More...
 
bool SetProperties (const wpi::json &properties)
 Updates multiple topic properties. More...
 
TopicInfo GetInfo () const
 Gets combined information about the topic. More...
 
GenericSubscriber GenericSubscribe (const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new subscriber to the topic. More...
 
GenericSubscriber GenericSubscribe (std::string_view typeString, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new subscriber to the topic. More...
 
GenericPublisher GenericPublish (std::string_view typeString, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new publisher to the topic. More...
 
GenericPublisher GenericPublishEx (std::string_view typeString, const wpi::json &properties, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new publisher to the topic, with type string and initial properties. More...
 
GenericEntry GetGenericEntry (const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new generic entry for the topic. More...
 
GenericEntry GetGenericEntry (std::string_view typeString, const PubSubOptions &options=kDefaultPubSubOptions)
 Create a new generic entry for the topic. More...
 
bool operator== (const Topic &) const =default
 Equality operator. More...
 

Static Public Attributes

static constexpr std::string_view kTypeString = "string[]"
 The default type string for this topic type. More...
 

Additional Inherited Members

- Protected Attributes inherited from nt::Topic
NT_Topic m_handle {0}
 

Detailed Description

NetworkTables StringArray topic.

Member Typedef Documentation

◆ EntryType

◆ ParamType

using nt::StringArrayTopic::ParamType = std::span<const std::string>

◆ PublisherType

◆ SubscriberType

◆ TimestampedValueType

◆ ValueType

using nt::StringArrayTopic::ValueType = std::vector<std::string>

Constructor & Destructor Documentation

◆ StringArrayTopic() [1/3]

nt::StringArrayTopic::StringArrayTopic ( )
default

◆ StringArrayTopic() [2/3]

nt::StringArrayTopic::StringArrayTopic ( NT_Topic  handle)
inlineexplicit

Construct from a topic handle; recommended to use NetworkTableInstance::GetStringArrayTopic() instead.

Parameters
handleNative handle

◆ StringArrayTopic() [3/3]

nt::StringArrayTopic::StringArrayTopic ( Topic  topic)
inlineexplicit

Construct from a generic topic.

Parameters
topicTopic

Member Function Documentation

◆ GetEntry()

StringArrayEntry nt::StringArrayTopic::GetEntry ( ParamType  defaultValue,
const PubSubOptions options = kDefaultPubSubOptions 
)
inline

Create a new entry for the topic.

Entries act as a combination of a subscriber and a weak publisher. The subscriber is active as long as the entry is not destroyed. The publisher is created when the entry is first written to, and remains active until either Unpublish() is called or the entry is destroyed.

Note
It is not possible to use two different data types with the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic's data type are dropped (ignored), and the entry will show no new values if the data type does not match. To determine if the data type matches, use the appropriate Topic functions.
Parameters
defaultValuedefault value used when a default is not provided to a getter function
optionspublish and/or subscribe options
Returns
entry

◆ GetEntryEx()

StringArrayEntry nt::StringArrayTopic::GetEntryEx ( std::string_view  typeString,
ParamType  defaultValue,
const PubSubOptions options = kDefaultPubSubOptions 
)
inline

Create a new entry for the topic, with specific type string.

Entries act as a combination of a subscriber and a weak publisher. The subscriber is active as long as the entry is not destroyed. The publisher is created when the entry is first written to, and remains active until either Unpublish() is called or the entry is destroyed.

Note
It is not possible to use two different data types with the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic's data type are dropped (ignored), and the entry will show no new values if the data type does not match. To determine if the data type matches, use the appropriate Topic functions.
Parameters
typeStringtype string
defaultValuedefault value used when a default is not provided to a getter function
optionspublish and/or subscribe options
Returns
entry

◆ Publish()

StringArrayPublisher nt::StringArrayTopic::Publish ( const PubSubOptions options = kDefaultPubSubOptions)
inline

Create a new publisher to the topic.

The publisher is only active as long as the returned object is not destroyed.

Note
It is not possible to publish two different data types to the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic's data type are dropped (ignored). To determine if the data type matches, use the appropriate Topic functions.
Parameters
optionspublish options
Returns
publisher

◆ PublishEx()

StringArrayPublisher nt::StringArrayTopic::PublishEx ( std::string_view  typeString,
const wpi::json &  properties,
const PubSubOptions options = kDefaultPubSubOptions 
)
inline

Create a new publisher to the topic, with type string and initial properties.

The publisher is only active as long as the returned object is not destroyed.

Note
It is not possible to publish two different data types to the same topic. Conflicts between publishers are typically resolved by the server on a first-come, first-served basis. Any published values that do not match the topic's data type are dropped (ignored). To determine if the data type matches, use the appropriate Topic functions.
Parameters
typeStringtype string
propertiesJSON properties
optionspublish options
Returns
publisher

◆ Subscribe()

StringArraySubscriber nt::StringArrayTopic::Subscribe ( ParamType  defaultValue,
const PubSubOptions options = kDefaultPubSubOptions 
)
inline

Create a new subscriber to the topic.

The subscriber is only active as long as the returned object is not destroyed.

Note
Subscribers that do not match the published data type do not return any values. To determine if the data type matches, use the appropriate Topic functions.
Parameters
defaultValuedefault value used when a default is not provided to a getter function
optionssubscribe options
Returns
subscriber

◆ SubscribeEx()

StringArraySubscriber nt::StringArrayTopic::SubscribeEx ( std::string_view  typeString,
ParamType  defaultValue,
const PubSubOptions options = kDefaultPubSubOptions 
)
inline

Create a new subscriber to the topic, with specific type string.

The subscriber is only active as long as the returned object is not destroyed.

Note
Subscribers that do not match the published data type do not return any values. To determine if the data type matches, use the appropriate Topic functions.
Parameters
typeStringtype string
defaultValuedefault value used when a default is not provided to a getter function
optionssubscribe options
Returns
subscriber

Member Data Documentation

◆ kTypeString

constexpr std::string_view nt::StringArrayTopic::kTypeString = "string[]"
staticconstexpr

The default type string for this topic type.


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