WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
ntcore_cpp.hpp File Reference
#include <stdint.h>
#include <cassert>
#include <functional>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <variant>
#include <vector>
#include "wpi/nt/NetworkTableValue.hpp"
#include "wpi/nt/ntcore_c.h"
#include "wpi/nt/ntcore_cpp_types.hpp"
#include "wpi/util/json_fwd.hpp"

Go to the source code of this file.

Classes

struct  wpi::nt::EventFlags
 Event notification flags. More...
struct  wpi::nt::TopicInfo
 NetworkTables Topic Information. More...
struct  wpi::nt::ConnectionInfo
 NetworkTables Connection Information. More...
class  wpi::nt::ValueEventData
 NetworkTables Value Event Data. More...
class  wpi::nt::LogMessage
 NetworkTables log message. More...
class  wpi::nt::TimeSyncEventData
 NetworkTables time sync event data. More...
class  wpi::nt::Event
 NetworkTables event. More...
struct  wpi::nt::PubSubOptions
 NetworkTables publish/subscribe options. More...
struct  wpi::nt::meta::SubscriberOptions
 Subscriber options. More...
struct  wpi::nt::meta::TopicPublisher
 Topic publisher (as published via $pub$<topic>). More...
struct  wpi::nt::meta::TopicSubscriber
 Topic subscriber (as published via $sub$<topic>). More...
struct  wpi::nt::meta::ClientPublisher
 Client publisher (as published via $clientpub$<client> or $serverpub). More...
struct  wpi::nt::meta::ClientSubscriber
 Client subscriber (as published via $clientsub$<client> or $serversub). More...
struct  wpi::nt::meta::Client
 Client (as published via $clients). More...

Namespaces

namespace  wpi
namespace  wpi::util
namespace  wpi::log
namespace  wpi::nt
 NetworkTables (ntcore) namespace.
namespace  wpi::nt::meta
 NetworkTables meta-topic decoding functions.

Typedefs

using wpi::nt::ListenerCallback = std::function<void(const Event&)>

Functions

NT_Inst wpi::nt::GetDefaultInstance ()
 Get default instance.
NT_Inst wpi::nt::CreateInstance ()
 Create an instance.
void wpi::nt::ResetInstance (NT_Inst inst)
 Reset the internals of an instance.
void wpi::nt::DestroyInstance (NT_Inst inst)
 Destroy an instance.
NT_Inst wpi::nt::GetInstanceFromHandle (NT_Handle handle)
 Get instance handle from another handle.
NT_Entry wpi::nt::GetEntry (NT_Inst inst, std::string_view name)
 Get Entry Handle.
std::string wpi::nt::GetEntryName (NT_Entry entry)
 Gets the name of the specified entry.
NT_Type wpi::nt::GetEntryType (NT_Entry entry)
 Gets the type for the specified entry, or unassigned if non existent.
int64_t wpi::nt::GetEntryLastChange (NT_Handle subentry)
 Gets the last time the entry was changed.
Value wpi::nt::GetEntryValue (NT_Handle subentry)
 Get Entry Value.
bool wpi::nt::SetDefaultEntryValue (NT_Entry entry, const Value &value)
 Set Default Entry Value.
bool wpi::nt::SetEntryValue (NT_Entry entry, const Value &value)
 Set Entry Value.
void wpi::nt::SetEntryFlags (NT_Entry entry, unsigned int flags)
 Set Entry Flags.
unsigned int wpi::nt::GetEntryFlags (NT_Entry entry)
 Get Entry Flags.
std::vector< Valuewpi::nt::ReadQueueValue (NT_Handle subentry)
 Read Entry Queue.
std::vector< Valuewpi::nt::ReadQueueValue (NT_Handle subentry, unsigned int types)
 Read Entry Queue.
std::vector< NT_Topicwpi::nt::GetTopics (NT_Inst inst, std::string_view prefix, unsigned int types)
 Get Published Topics.
std::vector< NT_Topicwpi::nt::GetTopics (NT_Inst inst, std::string_view prefix, std::span< const std::string_view > types)
 Get Published Topics.
std::vector< TopicInfowpi::nt::GetTopicInfo (NT_Inst inst, std::string_view prefix, unsigned int types)
 Get Topic Information about multiple topics.
std::vector< TopicInfowpi::nt::GetTopicInfo (NT_Inst inst, std::string_view prefix, std::span< const std::string_view > types)
 Get Topic Information about multiple topics.
TopicInfo wpi::nt::GetTopicInfo (NT_Topic topic)
 Gets Topic Information.
NT_Topic wpi::nt::GetTopic (NT_Inst inst, std::string_view name)
 Gets Topic Handle.
std::string wpi::nt::GetTopicName (NT_Topic topic)
 Gets the name of the specified topic.
NT_Type wpi::nt::GetTopicType (NT_Topic topic)
 Gets the type for the specified topic, or unassigned if non existent.
std::string wpi::nt::GetTopicTypeString (NT_Topic topic)
 Gets the type string for the specified topic, or empty string if non existent.
void wpi::nt::SetTopicPersistent (NT_Topic topic, bool value)
 Sets the persistent property of a topic.
bool wpi::nt::GetTopicPersistent (NT_Topic topic)
 Gets the persistent property of a topic.
void wpi::nt::SetTopicRetained (NT_Topic topic, bool value)
 Sets the retained property of a topic.
bool wpi::nt::GetTopicRetained (NT_Topic topic)
 Gets the retained property of a topic.
void wpi::nt::SetTopicCached (NT_Topic topic, bool value)
 Sets the cached property of a topic.
bool wpi::nt::GetTopicCached (NT_Topic topic)
 Gets the cached property of a topic.
bool wpi::nt::GetTopicExists (NT_Handle handle)
 Determine if topic exists (e.g.
wpi::util::json wpi::nt::GetTopicProperty (NT_Topic topic, std::string_view name)
 Gets the current value of a property (as a JSON object).
void wpi::nt::SetTopicProperty (NT_Topic topic, std::string_view name, const wpi::util::json &value)
 Sets a property value.
void wpi::nt::DeleteTopicProperty (NT_Topic topic, std::string_view name)
 Deletes a property.
wpi::util::json wpi::nt::GetTopicProperties (NT_Topic topic)
 Gets all topic properties as a JSON object.
bool wpi::nt::SetTopicProperties (NT_Topic topic, const wpi::util::json &update)
 Updates multiple topic properties.
NT_Subscriber wpi::nt::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.
void wpi::nt::Unsubscribe (NT_Subscriber sub)
 Stops subscriber.
NT_Publisher wpi::nt::Publish (NT_Topic topic, NT_Type type, std::string_view typeStr, const PubSubOptions &options=kDefaultPubSubOptions)
 Creates a new publisher to a topic.
NT_Publisher wpi::nt::PublishEx (NT_Topic topic, NT_Type type, std::string_view typeStr, const wpi::util::json &properties, const PubSubOptions &options=kDefaultPubSubOptions)
 Creates a new publisher to a topic.
void wpi::nt::Unpublish (NT_Handle pubentry)
 Stops publisher.
NT_Entry wpi::nt::GetEntry (NT_Topic topic, NT_Type type, std::string_view typeStr, const PubSubOptions &options=kDefaultPubSubOptions)
 Creates a new entry (subscriber and weak publisher) to a topic.
void wpi::nt::ReleaseEntry (NT_Entry entry)
 Stops entry subscriber/publisher.
void wpi::nt::Release (NT_Handle pubsubentry)
 Stops entry/subscriber/publisher.
NT_Topic wpi::nt::GetTopicFromHandle (NT_Handle pubsubentry)
 Gets the topic handle from an entry/subscriber/publisher handle.
NT_MultiSubscriber wpi::nt::SubscribeMultiple (NT_Inst inst, std::span< const std::string_view > prefixes, const PubSubOptions &options=kDefaultPubSubOptions)
 Subscribes to multiple topics based on one or more topic name prefixes.
void wpi::nt::UnsubscribeMultiple (NT_MultiSubscriber sub)
 Unsubscribes a multi-subscriber.
NT_ListenerPoller wpi::nt::CreateListenerPoller (NT_Inst inst)
 Creates a listener poller.
void wpi::nt::DestroyListenerPoller (NT_ListenerPoller poller)
 Destroys a listener poller.
std::vector< Eventwpi::nt::ReadListenerQueue (NT_ListenerPoller poller)
 Read notifications.
void wpi::nt::RemoveListener (NT_Listener listener)
 Removes a listener.
bool wpi::nt::WaitForListenerQueue (NT_Handle handle, double timeout)
 Wait for the listener queue to be empty.
NT_Listener wpi::nt::AddListener (NT_Inst inst, std::span< const std::string_view > prefixes, unsigned int mask, ListenerCallback callback)
 Create a listener for changes to topics with names that start with any of the given prefixes.
NT_Listener wpi::nt::AddListener (NT_Handle handle, unsigned int mask, ListenerCallback callback)
 Create a listener.
NT_Listener wpi::nt::AddPolledListener (NT_ListenerPoller poller, std::span< const std::string_view > prefixes, unsigned int mask)
 Creates a polled listener.
NT_Listener wpi::nt::AddPolledListener (NT_ListenerPoller poller, NT_Handle handle, unsigned int mask)
 Creates a polled listener.
unsigned int wpi::nt::GetNetworkMode (NT_Inst inst)
 Get the current network mode.
void wpi::nt::StartLocal (NT_Inst inst)
 Starts local-only operation.
void wpi::nt::StopLocal (NT_Inst inst)
 Stops local-only operation.
void wpi::nt::StartServer (NT_Inst inst, std::string_view persist_filename, std::string_view listen_address, std::string_view mdns_service, unsigned int port)
 Starts a server using the specified filename, listening address, and port.
void wpi::nt::StopServer (NT_Inst inst)
 Stops the server if it is running.
void wpi::nt::StartClient (NT_Inst inst, std::string_view identity)
 Starts a client.
void wpi::nt::StopClient (NT_Inst inst)
 Stops the client if it is running.
void wpi::nt::SetServer (NT_Inst inst, std::string_view server_name, unsigned int port)
 Sets server address and port for client (without restarting client).
void wpi::nt::SetServer (NT_Inst inst, std::span< const std::pair< std::string_view, unsigned int > > servers)
 Sets server addresses for client (without restarting client).
void wpi::nt::SetServerTeam (NT_Inst inst, unsigned int team, unsigned int port)
 Sets server addresses and port for client (without restarting client).
void wpi::nt::Disconnect (NT_Inst inst)
 Disconnects the client if it's running and connected.
void wpi::nt::StartDSClient (NT_Inst inst, unsigned int port)
 Starts requesting server address from Driver Station.
void wpi::nt::StopDSClient (NT_Inst inst)
 Stops requesting server address from Driver Station.
void wpi::nt::FlushLocal (NT_Inst inst)
 Flush local updates.
void wpi::nt::Flush (NT_Inst inst)
 Flush to network.
std::vector< ConnectionInfowpi::nt::GetConnections (NT_Inst inst)
 Get information on the currently established network connections.
bool wpi::nt::IsConnected (NT_Inst inst)
 Return whether or not the instance is connected to another node.
std::optional< int64_t > wpi::nt::GetServerTimeOffset (NT_Inst inst)
 Get the time offset between server time and local time.
int64_t wpi::nt::Now ()
 Returns monotonic current time in 1 us increments.
void wpi::nt::SetNow (int64_t timestamp)
 Sets the current timestamp used for timestamping values that do not provide a timestamp (e.g.
NT_Type wpi::nt::GetTypeFromString (std::string_view typeString)
 Turns a type string into a type enum value.
std::string_view wpi::nt::GetStringFromType (NT_Type type)
 Turns a type enum value into a type string.
NT_DataLogger wpi::nt::StartEntryDataLog (NT_Inst inst, wpi::log::DataLog &log, std::string_view prefix, std::string_view logPrefix)
 Starts logging entry changes to a DataLog.
void wpi::nt::StopEntryDataLog (NT_DataLogger logger)
 Stops logging entry changes to a DataLog.
NT_ConnectionDataLogger wpi::nt::StartConnectionDataLog (NT_Inst inst, wpi::log::DataLog &log, std::string_view name)
 Starts logging connection changes to a DataLog.
void wpi::nt::StopConnectionDataLog (NT_ConnectionDataLogger logger)
 Stops logging connection changes to a DataLog.
NT_Listener wpi::nt::AddLogger (NT_Inst inst, unsigned int min_level, unsigned int max_level, ListenerCallback func)
 Add logger callback function.
NT_Listener wpi::nt::AddPolledLogger (NT_ListenerPoller poller, unsigned int min_level, unsigned int max_level)
 Set the log level for a log poller.
bool wpi::nt::HasSchema (NT_Inst inst, std::string_view name)
 Returns whether there is a data schema already registered with the given name.
void wpi::nt::AddSchema (NT_Inst inst, std::string_view name, std::string_view type, std::span< const uint8_t > schema)
 Registers a data schema.
void wpi::nt::AddSchema (NT_Inst inst, std::string_view name, std::string_view type, std::string_view schema)
 Registers a data schema.
std::optional< std::vector< TopicPublisher > > wpi::nt::meta::DecodeTopicPublishers (std::span< const uint8_t > data)
 Decodes $pub$<topic> meta-topic data.
std::optional< std::vector< TopicSubscriber > > wpi::nt::meta::DecodeTopicSubscribers (std::span< const uint8_t > data)
 Decodes $sub$<topic> meta-topic data.
std::optional< std::vector< ClientPublisher > > wpi::nt::meta::DecodeClientPublishers (std::span< const uint8_t > data)
 Decodes $clientpub$<topic> meta-topic data.
std::optional< std::vector< ClientSubscriber > > wpi::nt::meta::DecodeClientSubscribers (std::span< const uint8_t > data)
 Decodes $clientsub$<topic> meta-topic data.
std::optional< std::vector< Client > > wpi::nt::meta::DecodeClients (std::span< const uint8_t > data)
 Decodes $clients meta-topic data.

Variables

constexpr PubSubOptions wpi::nt::kDefaultPubSubOptions
 Default publish/subscribe options.