NetworkTables Topic.
More...
#include <networktables/Topic.h>
◆ Topic() [1/2]
◆ Topic() [2/2]
◆ DeleteProperty()
Deletes a property.
Has no effect if the property does not exist.
- Parameters
-
◆ Exists()
bool nt::Topic::Exists |
( |
| ) |
const |
|
inline |
Determines if the topic is currently being published.
- Returns
- True if the topic exists, false otherwise.
◆ GenericPublish()
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
-
typeString | type string |
options | publish options |
- Returns
- publisher
◆ GenericPublishEx()
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
-
typeString | type string |
properties | JSON properties |
options | publish options |
- Returns
- publisher
◆ GenericSubscribe() [1/2]
Create a new subscriber to the topic.
The subscriber is only active as long as the returned object is not destroyed.
- Parameters
-
- Returns
- subscriber
◆ GenericSubscribe() [2/2]
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
-
typeString | type string |
options | subscribe options |
- Returns
- subscriber
◆ GetGenericEntry() [1/2]
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.
- 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
-
options | publish and/or subscribe options |
- Returns
- entry
◆ GetGenericEntry() [2/2]
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.
- 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
-
typeString | type string |
options | publish and/or subscribe options |
- Returns
- entry
◆ GetHandle()
Gets the native handle for the topic.
- Returns
- Native handle
◆ GetInfo()
Gets combined information about the topic.
- Returns
- Topic information
◆ GetInstance()
Gets the instance for the topic.
- Returns
- Instance
◆ GetName()
std::string nt::Topic::GetName |
( |
| ) |
const |
|
inline |
Gets the name of the topic.
- Returns
- the topic's name
◆ GetProperties()
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.
- Returns
- JSON object
◆ GetProperty()
Gets the current value of a property (as a JSON object).
- Parameters
-
- Returns
- JSON object; null object if the property does not exist.
◆ GetType()
Gets the type of the topic.
- Returns
- the topic's type
◆ GetTypeString()
std::string nt::Topic::GetTypeString |
( |
| ) |
const |
|
inline |
Gets the type string of the topic.
This may have more information than the numeric type (especially for raw values).
- Returns
- the topic's type
◆ IsPersistent()
bool nt::Topic::IsPersistent |
( |
| ) |
const |
|
inline |
Returns whether the value is persistent through server restarts.
- Returns
- True if the value is persistent.
◆ IsRetained()
bool nt::Topic::IsRetained |
( |
| ) |
const |
|
inline |
Returns whether the topic is retained by server when there are no publishers.
- Returns
- True if the topic is retained.
◆ operator bool()
nt::Topic::operator bool |
( |
| ) |
const |
|
inlineexplicit |
Determines if the native handle is valid.
- Returns
- True if the native handle is valid, false otherwise.
◆ operator==()
bool nt::Topic::operator== |
( |
const Topic & |
| ) |
const |
|
default |
Equality operator.
Returns true if both instances refer to the same native handle.
◆ SetPersistent()
void nt::Topic::SetPersistent |
( |
bool |
persistent | ) |
|
|
inline |
Make value persistent through server restarts.
- Parameters
-
persistent | True for persistent, false for not persistent. |
◆ SetProperties()
bool nt::Topic::SetProperties |
( |
const wpi::json & |
properties | ) |
|
|
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.
- Parameters
-
properties | JSON object with keys to add/update/delete |
- Returns
- False if properties is not an object
◆ SetProperty()
Sets a property value.
- Parameters
-
name | property name |
value | property value |
◆ SetRetained()
void nt::Topic::SetRetained |
( |
bool |
retained | ) |
|
|
inline |
Make the server retain the topic even when there are no publishers.
- Parameters
-
retained | True for retained, false for not retained. |
◆ m_handle
The documentation for this class was generated from the following files: