59 m_defaultValue{defaultValue} {}
68 return Get(m_defaultValue);
90 return Get(buf, m_defaultValue);
125 return ::nt::GetAtomicString(
m_subHandle, defaultValue);
367 std::string_view typeString,
ParamType defaultValue,
NetworkTables publisher.
Definition Topic.h:393
NT_Publisher m_pubHandle
NetworkTables handle.
Definition Topic.h:441
NetworkTables String entry.
Definition StringTopic.h:240
void Unpublish()
Stops publishing the entry if it's published.
Definition StringTopic.h:290
TopicType GetTopic() const
Get the corresponding topic.
Definition StringTopic.h:486
StringEntry(NT_Entry handle, ParamType defaultValue)
Construct from an entry handle; recommended to use StringTopic::GetEntry() instead.
Definition StringTopic.h:262
std::string ValueType
Definition StringTopic.h:245
char SmallElemType
Definition StringTopic.h:249
StringTopic TopicType
Definition StringTopic.h:244
NT_Entry GetHandle() const
Gets the native handle for the entry.
Definition StringTopic.h:278
std::string_view ParamType
Definition StringTopic.h:246
std::string_view SmallRetType
Definition StringTopic.h:248
NetworkTables String publisher.
Definition StringTopic.h:184
void SetDefault(ParamType value)
Publish a default value.
Definition StringTopic.h:222
std::string_view SmallRetType
Definition StringTopic.h:190
StringPublisher()=default
StringTopic TopicType
Definition StringTopic.h:186
std::string_view ParamType
Definition StringTopic.h:188
StringPublisher(NT_Publisher handle)
Construct from a publisher handle; recommended to use StringTopic::Publish() instead.
Definition StringTopic.h:203
TopicType GetTopic() const
Get the corresponding topic.
Definition StringTopic.h:482
std::string ValueType
Definition StringTopic.h:187
void Set(ParamType value, int64_t time=0)
Publish a new value.
Definition StringTopic.h:211
char SmallElemType
Definition StringTopic.h:191
NetworkTables String subscriber.
Definition StringTopic.h:36
ValueType Get(ParamType defaultValue) const
Get the last published value.
Definition StringTopic.h:78
StringSubscriber()=default
TimestampedValueViewType GetAtomic(wpi::SmallVectorImpl< SmallElemType > &buf) const
Get the last published value along with its timestamp.
Definition StringTopic.h:136
SmallRetType Get(wpi::SmallVectorImpl< SmallElemType > &buf) const
Get the last published value.
Definition StringTopic.h:89
StringTopic TopicType
Definition StringTopic.h:38
TimestampedValueType GetAtomic(ParamType defaultValue) const
Get the last published value along with its timestamp.
Definition StringTopic.h:124
std::vector< TimestampedValueType > ReadQueue()
Get an array of all value changes since the last call to ReadQueue.
Definition StringTopic.h:166
StringSubscriber(NT_Subscriber handle, ParamType defaultValue)
Construct from a subscriber handle; recommended to use StringTopic::Subscribe() instead.
Definition StringTopic.h:57
char SmallElemType
Definition StringTopic.h:44
TopicType GetTopic() const
Get the corresponding topic.
Definition StringTopic.h:478
std::string_view ParamType
Definition StringTopic.h:40
std::string ValueType
Definition StringTopic.h:39
SmallRetType Get(wpi::SmallVectorImpl< SmallElemType > &buf, ParamType defaultValue) const
Get the last published value.
Definition StringTopic.h:101
TimestampedValueType GetAtomic() const
Get the last published value along with its timestamp If no value has been published,...
Definition StringTopic.h:112
TimestampedValueViewType GetAtomic(wpi::SmallVectorImpl< SmallElemType > &buf, ParamType defaultValue) const
Get the last published value along with its timestamp.
Definition StringTopic.h:150
ValueType Get() const
Get the last published value.
Definition StringTopic.h:67
std::string_view SmallRetType
Definition StringTopic.h:43
NetworkTables String topic.
Definition StringTopic.h:298
StringTopic(Topic topic)
Construct from a generic topic.
Definition StringTopic.h:324
PublisherType Publish(const PubSubOptions &options=kDefaultPubSubOptions)
Create a new publisher to the topic.
Definition StringTopic.h:390
StringTopic(NT_Topic handle)
Construct from a topic handle; recommended to use NetworkTableInstance::GetStringTopic() instead.
Definition StringTopic.h:317
static constexpr std::string_view kTypeString
The default type string for this topic type.
Definition StringTopic.h:307
SubscriberType SubscribeEx(std::string_view typeString, ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
Create a new subscriber to the topic, with specific type string.
Definition StringTopic.h:366
SubscriberType Subscribe(ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
Create a new subscriber to the topic.
Definition StringTopic.h:342
std::string_view ParamType
Definition StringTopic.h:304
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
Create a new entry for the topic, with specific type string.
Definition StringTopic.h:469
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.
Definition StringTopic.h:414
std::string ValueType
Definition StringTopic.h:303
EntryType GetEntry(ParamType defaultValue, const PubSubOptions &options=kDefaultPubSubOptions)
Create a new entry for the topic.
Definition StringTopic.h:441
NetworkTables subscriber.
Definition Topic.h:321
NT_Subscriber m_subHandle
Definition Topic.h:386
NetworkTables Topic.
Definition Topic.h:28
NT_Topic m_handle
Definition Topic.h:317
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition sha1.h:30
std::string GetString(NT_Handle subentry, std::string_view defaultValue)
Get the last published value.
bool SetDefaultString(NT_Handle pubentry, std::string_view defaultValue)
Publish a default value.
bool SetString(NT_Handle pubentry, std::string_view value, int64_t time=0)
Publish a new value.
TimestampedString GetAtomicString(NT_Handle subentry, std::string_view defaultValue)
Get the last published value along with its timestamp.
NT_Handle NT_Topic
Definition ntcore_c.h:42
NT_Handle NT_Subscriber
Definition ntcore_c.h:43
NT_Handle NT_Publisher
Definition ntcore_c.h:44
NT_Handle NT_Entry
Definition ntcore_c.h:37
@ NT_STRING
Definition ntcore_c.h:57
Timestamped< std::string_view > TimestampedStringView
Timestamped String view (for SmallVector-taking functions).
Definition ntcore_cpp_types.h:377
Timestamped< std::string > TimestampedString
Timestamped String.
Definition ntcore_cpp_types.h:371
constexpr PubSubOptions kDefaultPubSubOptions
Default publish/subscribe options.
Definition ntcore_cpp.h:390
NT_Entry GetEntry(NT_Inst inst, std::string_view name)
Get Entry Handle.
NT_Topic GetTopicFromHandle(NT_Handle pubsubentry)
Gets the topic handle from an entry/subscriber/publisher handle.
NT_Publisher PublishEx(NT_Topic topic, NT_Type type, std::string_view typeStr, const wpi::json &properties, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new publisher to a topic.
NT_Publisher Publish(NT_Topic topic, NT_Type type, std::string_view typeStr, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new publisher to a topic.
void Unpublish(NT_Handle pubentry)
Stops publisher.
NT_Subscriber Subscribe(NT_Topic topic, NT_Type type, std::string_view typeStr, const PubSubOptions &options=kDefaultPubSubOptions)
Creates a new subscriber to value changes on a topic.
NetworkTables (ntcore) namespace.
Definition ntcore_cpp.h:36
Foonathan namespace.
Definition ntcore_cpp.h:26
NetworkTables publish/subscribe options.
Definition ntcore_cpp.h:305
Timestamped value.
Definition ntcore_cpp_types.h:30