WPILibC++ 2024.3.2
|
#include <networktables/Topic.h>
Public Member Functions | |
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... | |
Protected Attributes | |
NT_Topic | m_handle {0} |
NetworkTables Topic.
|
default |
|
inlineexplicit |
|
inline |
Deletes a property.
Has no effect if the property does not exist.
name | property name |
|
inline |
Determines if the topic is currently being published.
GenericPublisher nt::Topic::GenericPublish | ( | std::string_view | typeString, |
const PubSubOptions & | options = kDefaultPubSubOptions |
||
) |
Create a new publisher to the topic.
The publisher is only active as long as the returned object is not destroyed.
typeString | type string |
options | publish options |
GenericPublisher nt::Topic::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.
The publisher is only active as long as the returned object is not destroyed.
typeString | type string |
properties | JSON properties |
options | publish options |
GenericSubscriber nt::Topic::GenericSubscribe | ( | const PubSubOptions & | options = kDefaultPubSubOptions | ) |
Create a new subscriber to the topic.
The subscriber is only active as long as the returned object is not destroyed.
options | subscribe options |
GenericSubscriber nt::Topic::GenericSubscribe | ( | std::string_view | typeString, |
const PubSubOptions & | options = kDefaultPubSubOptions |
||
) |
Create a new subscriber to the topic.
The subscriber is only active as long as the returned object is not destroyed.
typeString | type string |
options | subscribe options |
GenericEntry nt::Topic::GetGenericEntry | ( | const PubSubOptions & | options = kDefaultPubSubOptions | ) |
Create a new generic 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.
options | publish and/or subscribe options |
GenericEntry nt::Topic::GetGenericEntry | ( | std::string_view | typeString, |
const PubSubOptions & | options = kDefaultPubSubOptions |
||
) |
Create a new generic 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.
typeString | type string |
options | publish and/or subscribe options |
|
inline |
Gets the native handle for the topic.
|
inline |
Gets combined information about the topic.
NetworkTableInstance nt::Topic::GetInstance | ( | ) | const |
Gets the instance for the topic.
|
inline |
Gets the name of the topic.
wpi::json nt::Topic::GetProperties | ( | ) | const |
Gets all topic properties as a JSON object.
Each key in the object is the property name, and the corresponding value is the property value.
wpi::json nt::Topic::GetProperty | ( | std::string_view | name | ) | const |
Gets the current value of a property (as a JSON object).
name | property name |
|
inline |
Gets the type of the topic.
|
inline |
Gets the type string of the topic.
This may have more information than the numeric type (especially for raw values).
|
inline |
Returns whether the topic's last value is stored.
|
inline |
Returns whether the value is persistent through server restarts.
|
inline |
Returns whether the topic is retained by server when there are no publishers.
|
inlineexplicit |
Determines if the native handle is valid.
|
default |
Equality operator.
Returns true if both instances refer to the same native handle.
|
inline |
Allow storage of the topic's last value, allowing the value to be read (and not just accessed through event queues and listeners).
cached | True for cached, false for not cached. |
|
inline |
Make value persistent through server restarts.
persistent | True for persistent, false for not persistent. |
|
inline |
Updates multiple topic properties.
Each key in the passed-in object is the name of the property to add/update, and the corresponding value is the property value to set for that property. Null values result in deletion of the corresponding property.
properties | JSON object with keys to add/update/delete |
void nt::Topic::SetProperty | ( | std::string_view | name, |
const wpi::json & | value | ||
) |
Sets a property value.
name | property name |
value | property value |
|
inline |
Make the server retain the topic even when there are no publishers.
retained | True for retained, false for not retained. |
|
protected |