[ntcore] Commit generated files (#5962)

This commit is contained in:
PJ Reiniger
2023-12-01 18:31:06 -05:00
committed by GitHub
parent 7ed900ae3a
commit 54ab65a63a
127 changed files with 21230 additions and 329 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,495 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#include "ntcore_c_types.h"
#include "Value_internal.h"
#include "ntcore_cpp.h"
using namespace nt;
template <typename T>
static inline std::span<const T> ConvertFromC(const T* arr, size_t size) {
return {arr, size};
}
static inline std::string_view ConvertFromC(const char* arr, size_t size) {
return {arr, size};
}
static std::vector<std::string> ConvertFromC(const NT_String* arr, size_t size) {
std::vector<std::string> v;
v.reserve(size);
for (size_t i = 0; i < size; ++i) {
v.emplace_back(ConvertFromC(arr[i]));
}
return v;
}
static void ConvertToC(const nt::TimestampedBoolean& in, NT_TimestampedBoolean* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = in.value;
}
static void ConvertToC(const nt::TimestampedInteger& in, NT_TimestampedInteger* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = in.value;
}
static void ConvertToC(const nt::TimestampedFloat& in, NT_TimestampedFloat* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = in.value;
}
static void ConvertToC(const nt::TimestampedDouble& in, NT_TimestampedDouble* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = in.value;
}
static void ConvertToC(const nt::TimestampedString& in, NT_TimestampedString* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = ConvertToC<char>(in.value, &out->len);
}
static void ConvertToC(const nt::TimestampedRaw& in, NT_TimestampedRaw* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = ConvertToC<uint8_t>(in.value, &out->len);
}
static void ConvertToC(const nt::TimestampedBooleanArray& in, NT_TimestampedBooleanArray* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = ConvertToC<NT_Bool>(in.value, &out->len);
}
static void ConvertToC(const nt::TimestampedIntegerArray& in, NT_TimestampedIntegerArray* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = ConvertToC<int64_t>(in.value, &out->len);
}
static void ConvertToC(const nt::TimestampedFloatArray& in, NT_TimestampedFloatArray* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = ConvertToC<float>(in.value, &out->len);
}
static void ConvertToC(const nt::TimestampedDoubleArray& in, NT_TimestampedDoubleArray* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = ConvertToC<double>(in.value, &out->len);
}
static void ConvertToC(const nt::TimestampedStringArray& in, NT_TimestampedStringArray* out) {
out->time = in.time;
out->serverTime = in.serverTime;
out->value = ConvertToC<struct NT_String>(in.value, &out->len);
}
extern "C" {
NT_Bool NT_SetBoolean(NT_Handle pubentry, int64_t time, NT_Bool value) {
return nt::SetBoolean(pubentry, value, time);
}
NT_Bool NT_SetDefaultBoolean(NT_Handle pubentry, NT_Bool defaultValue) {
return nt::SetDefaultBoolean(pubentry, defaultValue);
}
NT_Bool NT_GetBoolean(NT_Handle subentry, NT_Bool defaultValue) {
return nt::GetBoolean(subentry, defaultValue);
}
void NT_GetAtomicBoolean(NT_Handle subentry, NT_Bool defaultValue, struct NT_TimestampedBoolean* value) {
auto cppValue = nt::GetAtomicBoolean(subentry, defaultValue);
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedBoolean(struct NT_TimestampedBoolean* value) {
}
struct NT_TimestampedBoolean* NT_ReadQueueBoolean(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueBoolean(subentry);
return ConvertToC<NT_TimestampedBoolean>(arr, len);
}
void NT_FreeQueueBoolean(struct NT_TimestampedBoolean* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedBoolean(&arr[i]);
}
std::free(arr);
}
NT_Bool* NT_ReadQueueValuesBoolean(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueValuesBoolean(subentry);
return ConvertToC<NT_Bool>(arr, len);
}
NT_Bool NT_SetInteger(NT_Handle pubentry, int64_t time, int64_t value) {
return nt::SetInteger(pubentry, value, time);
}
NT_Bool NT_SetDefaultInteger(NT_Handle pubentry, int64_t defaultValue) {
return nt::SetDefaultInteger(pubentry, defaultValue);
}
int64_t NT_GetInteger(NT_Handle subentry, int64_t defaultValue) {
return nt::GetInteger(subentry, defaultValue);
}
void NT_GetAtomicInteger(NT_Handle subentry, int64_t defaultValue, struct NT_TimestampedInteger* value) {
auto cppValue = nt::GetAtomicInteger(subentry, defaultValue);
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedInteger(struct NT_TimestampedInteger* value) {
}
struct NT_TimestampedInteger* NT_ReadQueueInteger(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueInteger(subentry);
return ConvertToC<NT_TimestampedInteger>(arr, len);
}
void NT_FreeQueueInteger(struct NT_TimestampedInteger* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedInteger(&arr[i]);
}
std::free(arr);
}
int64_t* NT_ReadQueueValuesInteger(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueValuesInteger(subentry);
return ConvertToC<int64_t>(arr, len);
}
NT_Bool NT_SetFloat(NT_Handle pubentry, int64_t time, float value) {
return nt::SetFloat(pubentry, value, time);
}
NT_Bool NT_SetDefaultFloat(NT_Handle pubentry, float defaultValue) {
return nt::SetDefaultFloat(pubentry, defaultValue);
}
float NT_GetFloat(NT_Handle subentry, float defaultValue) {
return nt::GetFloat(subentry, defaultValue);
}
void NT_GetAtomicFloat(NT_Handle subentry, float defaultValue, struct NT_TimestampedFloat* value) {
auto cppValue = nt::GetAtomicFloat(subentry, defaultValue);
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedFloat(struct NT_TimestampedFloat* value) {
}
struct NT_TimestampedFloat* NT_ReadQueueFloat(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueFloat(subentry);
return ConvertToC<NT_TimestampedFloat>(arr, len);
}
void NT_FreeQueueFloat(struct NT_TimestampedFloat* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedFloat(&arr[i]);
}
std::free(arr);
}
float* NT_ReadQueueValuesFloat(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueValuesFloat(subentry);
return ConvertToC<float>(arr, len);
}
NT_Bool NT_SetDouble(NT_Handle pubentry, int64_t time, double value) {
return nt::SetDouble(pubentry, value, time);
}
NT_Bool NT_SetDefaultDouble(NT_Handle pubentry, double defaultValue) {
return nt::SetDefaultDouble(pubentry, defaultValue);
}
double NT_GetDouble(NT_Handle subentry, double defaultValue) {
return nt::GetDouble(subentry, defaultValue);
}
void NT_GetAtomicDouble(NT_Handle subentry, double defaultValue, struct NT_TimestampedDouble* value) {
auto cppValue = nt::GetAtomicDouble(subentry, defaultValue);
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedDouble(struct NT_TimestampedDouble* value) {
}
struct NT_TimestampedDouble* NT_ReadQueueDouble(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueDouble(subentry);
return ConvertToC<NT_TimestampedDouble>(arr, len);
}
void NT_FreeQueueDouble(struct NT_TimestampedDouble* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedDouble(&arr[i]);
}
std::free(arr);
}
double* NT_ReadQueueValuesDouble(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueValuesDouble(subentry);
return ConvertToC<double>(arr, len);
}
NT_Bool NT_SetString(NT_Handle pubentry, int64_t time, const char* value, size_t len) {
return nt::SetString(pubentry, ConvertFromC(value, len), time);
}
NT_Bool NT_SetDefaultString(NT_Handle pubentry, const char* defaultValue, size_t defaultValueLen) {
return nt::SetDefaultString(pubentry, ConvertFromC(defaultValue, defaultValueLen));
}
char* NT_GetString(NT_Handle subentry, const char* defaultValue, size_t defaultValueLen, size_t* len) {
auto cppValue = nt::GetString(subentry, ConvertFromC(defaultValue, defaultValueLen));
return ConvertToC<char>(cppValue, len);
}
void NT_GetAtomicString(NT_Handle subentry, const char* defaultValue, size_t defaultValueLen, struct NT_TimestampedString* value) {
auto cppValue = nt::GetAtomicString(subentry, ConvertFromC(defaultValue, defaultValueLen));
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedString(struct NT_TimestampedString* value) {
std::free(value->value);
}
struct NT_TimestampedString* NT_ReadQueueString(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueString(subentry);
return ConvertToC<NT_TimestampedString>(arr, len);
}
void NT_FreeQueueString(struct NT_TimestampedString* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedString(&arr[i]);
}
std::free(arr);
}
NT_Bool NT_SetRaw(NT_Handle pubentry, int64_t time, const uint8_t* value, size_t len) {
return nt::SetRaw(pubentry, ConvertFromC(value, len), time);
}
NT_Bool NT_SetDefaultRaw(NT_Handle pubentry, const uint8_t* defaultValue, size_t defaultValueLen) {
return nt::SetDefaultRaw(pubentry, ConvertFromC(defaultValue, defaultValueLen));
}
uint8_t* NT_GetRaw(NT_Handle subentry, const uint8_t* defaultValue, size_t defaultValueLen, size_t* len) {
auto cppValue = nt::GetRaw(subentry, ConvertFromC(defaultValue, defaultValueLen));
return ConvertToC<uint8_t>(cppValue, len);
}
void NT_GetAtomicRaw(NT_Handle subentry, const uint8_t* defaultValue, size_t defaultValueLen, struct NT_TimestampedRaw* value) {
auto cppValue = nt::GetAtomicRaw(subentry, ConvertFromC(defaultValue, defaultValueLen));
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedRaw(struct NT_TimestampedRaw* value) {
std::free(value->value);
}
struct NT_TimestampedRaw* NT_ReadQueueRaw(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueRaw(subentry);
return ConvertToC<NT_TimestampedRaw>(arr, len);
}
void NT_FreeQueueRaw(struct NT_TimestampedRaw* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedRaw(&arr[i]);
}
std::free(arr);
}
NT_Bool NT_SetBooleanArray(NT_Handle pubentry, int64_t time, const NT_Bool* value, size_t len) {
return nt::SetBooleanArray(pubentry, ConvertFromC(value, len), time);
}
NT_Bool NT_SetDefaultBooleanArray(NT_Handle pubentry, const NT_Bool* defaultValue, size_t defaultValueLen) {
return nt::SetDefaultBooleanArray(pubentry, ConvertFromC(defaultValue, defaultValueLen));
}
NT_Bool* NT_GetBooleanArray(NT_Handle subentry, const NT_Bool* defaultValue, size_t defaultValueLen, size_t* len) {
auto cppValue = nt::GetBooleanArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
return ConvertToC<NT_Bool>(cppValue, len);
}
void NT_GetAtomicBooleanArray(NT_Handle subentry, const NT_Bool* defaultValue, size_t defaultValueLen, struct NT_TimestampedBooleanArray* value) {
auto cppValue = nt::GetAtomicBooleanArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedBooleanArray(struct NT_TimestampedBooleanArray* value) {
std::free(value->value);
}
struct NT_TimestampedBooleanArray* NT_ReadQueueBooleanArray(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueBooleanArray(subentry);
return ConvertToC<NT_TimestampedBooleanArray>(arr, len);
}
void NT_FreeQueueBooleanArray(struct NT_TimestampedBooleanArray* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedBooleanArray(&arr[i]);
}
std::free(arr);
}
NT_Bool NT_SetIntegerArray(NT_Handle pubentry, int64_t time, const int64_t* value, size_t len) {
return nt::SetIntegerArray(pubentry, ConvertFromC(value, len), time);
}
NT_Bool NT_SetDefaultIntegerArray(NT_Handle pubentry, const int64_t* defaultValue, size_t defaultValueLen) {
return nt::SetDefaultIntegerArray(pubentry, ConvertFromC(defaultValue, defaultValueLen));
}
int64_t* NT_GetIntegerArray(NT_Handle subentry, const int64_t* defaultValue, size_t defaultValueLen, size_t* len) {
auto cppValue = nt::GetIntegerArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
return ConvertToC<int64_t>(cppValue, len);
}
void NT_GetAtomicIntegerArray(NT_Handle subentry, const int64_t* defaultValue, size_t defaultValueLen, struct NT_TimestampedIntegerArray* value) {
auto cppValue = nt::GetAtomicIntegerArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedIntegerArray(struct NT_TimestampedIntegerArray* value) {
std::free(value->value);
}
struct NT_TimestampedIntegerArray* NT_ReadQueueIntegerArray(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueIntegerArray(subentry);
return ConvertToC<NT_TimestampedIntegerArray>(arr, len);
}
void NT_FreeQueueIntegerArray(struct NT_TimestampedIntegerArray* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedIntegerArray(&arr[i]);
}
std::free(arr);
}
NT_Bool NT_SetFloatArray(NT_Handle pubentry, int64_t time, const float* value, size_t len) {
return nt::SetFloatArray(pubentry, ConvertFromC(value, len), time);
}
NT_Bool NT_SetDefaultFloatArray(NT_Handle pubentry, const float* defaultValue, size_t defaultValueLen) {
return nt::SetDefaultFloatArray(pubentry, ConvertFromC(defaultValue, defaultValueLen));
}
float* NT_GetFloatArray(NT_Handle subentry, const float* defaultValue, size_t defaultValueLen, size_t* len) {
auto cppValue = nt::GetFloatArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
return ConvertToC<float>(cppValue, len);
}
void NT_GetAtomicFloatArray(NT_Handle subentry, const float* defaultValue, size_t defaultValueLen, struct NT_TimestampedFloatArray* value) {
auto cppValue = nt::GetAtomicFloatArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedFloatArray(struct NT_TimestampedFloatArray* value) {
std::free(value->value);
}
struct NT_TimestampedFloatArray* NT_ReadQueueFloatArray(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueFloatArray(subentry);
return ConvertToC<NT_TimestampedFloatArray>(arr, len);
}
void NT_FreeQueueFloatArray(struct NT_TimestampedFloatArray* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedFloatArray(&arr[i]);
}
std::free(arr);
}
NT_Bool NT_SetDoubleArray(NT_Handle pubentry, int64_t time, const double* value, size_t len) {
return nt::SetDoubleArray(pubentry, ConvertFromC(value, len), time);
}
NT_Bool NT_SetDefaultDoubleArray(NT_Handle pubentry, const double* defaultValue, size_t defaultValueLen) {
return nt::SetDefaultDoubleArray(pubentry, ConvertFromC(defaultValue, defaultValueLen));
}
double* NT_GetDoubleArray(NT_Handle subentry, const double* defaultValue, size_t defaultValueLen, size_t* len) {
auto cppValue = nt::GetDoubleArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
return ConvertToC<double>(cppValue, len);
}
void NT_GetAtomicDoubleArray(NT_Handle subentry, const double* defaultValue, size_t defaultValueLen, struct NT_TimestampedDoubleArray* value) {
auto cppValue = nt::GetAtomicDoubleArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedDoubleArray(struct NT_TimestampedDoubleArray* value) {
std::free(value->value);
}
struct NT_TimestampedDoubleArray* NT_ReadQueueDoubleArray(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueDoubleArray(subentry);
return ConvertToC<NT_TimestampedDoubleArray>(arr, len);
}
void NT_FreeQueueDoubleArray(struct NT_TimestampedDoubleArray* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedDoubleArray(&arr[i]);
}
std::free(arr);
}
NT_Bool NT_SetStringArray(NT_Handle pubentry, int64_t time, const struct NT_String* value, size_t len) {
return nt::SetStringArray(pubentry, ConvertFromC(value, len), time);
}
NT_Bool NT_SetDefaultStringArray(NT_Handle pubentry, const struct NT_String* defaultValue, size_t defaultValueLen) {
return nt::SetDefaultStringArray(pubentry, ConvertFromC(defaultValue, defaultValueLen));
}
struct NT_String* NT_GetStringArray(NT_Handle subentry, const struct NT_String* defaultValue, size_t defaultValueLen, size_t* len) {
auto cppValue = nt::GetStringArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
return ConvertToC<struct NT_String>(cppValue, len);
}
void NT_GetAtomicStringArray(NT_Handle subentry, const struct NT_String* defaultValue, size_t defaultValueLen, struct NT_TimestampedStringArray* value) {
auto cppValue = nt::GetAtomicStringArray(subentry, ConvertFromC(defaultValue, defaultValueLen));
ConvertToC(cppValue, value);
}
void NT_DisposeTimestampedStringArray(struct NT_TimestampedStringArray* value) {
NT_FreeStringArray(value->value, value->len);
}
struct NT_TimestampedStringArray* NT_ReadQueueStringArray(NT_Handle subentry, size_t* len) {
auto arr = nt::ReadQueueStringArray(subentry);
return ConvertToC<NT_TimestampedStringArray>(arr, len);
}
void NT_FreeQueueStringArray(struct NT_TimestampedStringArray* arr, size_t len) {
for (size_t i = 0; i < len; ++i) {
NT_DisposeTimestampedStringArray(&arr[i]);
}
std::free(arr);
}
} // extern "C"

View File

@@ -0,0 +1,463 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#include "ntcore_cpp_types.h"
#include "Handle.h"
#include "InstanceImpl.h"
namespace {
template <nt::ValidType T>
struct ValuesType {
using Vector =
std::vector<typename nt::TypeInfo<std::remove_cvref_t<T>>::Value>;
};
template <>
struct ValuesType<bool> {
using Vector = std::vector<int>;
};
} // namespace
namespace nt {
template <ValidType T>
static inline bool Set(NT_Handle pubentry, typename TypeInfo<T>::View value,
int64_t time) {
if (auto ii = InstanceImpl::Get(Handle{pubentry}.GetInst())) {
return ii->localStorage.SetEntryValue(
pubentry, MakeValue<T>(value, time == 0 ? Now() : time));
} else {
return {};
}
}
template <ValidType T>
static inline bool SetDefault(NT_Handle pubentry,
typename TypeInfo<T>::View defaultValue) {
if (auto ii = InstanceImpl::Get(Handle{pubentry}.GetInst())) {
return ii->localStorage.SetDefaultEntryValue(pubentry,
MakeValue<T>(defaultValue, 1));
} else {
return {};
}
}
template <ValidType T>
static inline Timestamped<typename TypeInfo<T>::Value> GetAtomic(
NT_Handle subentry, typename TypeInfo<T>::View defaultValue) {
if (auto ii = InstanceImpl::Get(Handle{subentry}.GetInst())) {
return ii->localStorage.GetAtomic<T>(subentry, defaultValue);
} else {
return {};
}
}
template <ValidType T>
inline Timestamped<typename TypeInfo<T>::SmallRet> GetAtomic(
NT_Handle subentry,
wpi::SmallVectorImpl<typename TypeInfo<T>::SmallElem>& buf,
typename TypeInfo<T>::View defaultValue) {
if (auto ii = InstanceImpl::Get(Handle{subentry}.GetInst())) {
return ii->localStorage.GetAtomic<T>(subentry, buf, defaultValue);
} else {
return {};
}
}
template <typename T>
static inline std::vector<Timestamped<typename TypeInfo<T>::Value>> ReadQueue(
NT_Handle subentry) {
if (auto ii = InstanceImpl::Get(Handle{subentry}.GetInst())) {
return ii->localStorage.ReadQueue<T>(subentry);
} else {
return {};
}
}
template <typename T>
static inline typename ValuesType<T>::Vector ReadQueueValues(
NT_Handle subentry) {
typename ValuesType<T>::Vector rv;
auto arr = ReadQueue<T>(subentry);
rv.reserve(arr.size());
for (auto&& elem : arr) {
rv.emplace_back(std::move(elem.value));
}
return rv;
}
bool SetBoolean(NT_Handle pubentry, bool value, int64_t time) {
return Set<bool>(pubentry, value, time);
}
bool SetDefaultBoolean(NT_Handle pubentry, bool defaultValue) {
return SetDefault<bool>(pubentry, defaultValue);
}
bool GetBoolean(NT_Handle subentry, bool defaultValue) {
return GetAtomic<bool>(subentry, defaultValue).value;
}
TimestampedBoolean GetAtomicBoolean(
NT_Handle subentry, bool defaultValue) {
return GetAtomic<bool>(subentry, defaultValue);
}
std::vector<TimestampedBoolean> ReadQueueBoolean(NT_Handle subentry) {
return ReadQueue<bool>(subentry);
}
std::vector<int> ReadQueueValuesBoolean(NT_Handle subentry) {
return ReadQueueValues<bool>(subentry);
}
bool SetInteger(NT_Handle pubentry, int64_t value, int64_t time) {
return Set<int64_t>(pubentry, value, time);
}
bool SetDefaultInteger(NT_Handle pubentry, int64_t defaultValue) {
return SetDefault<int64_t>(pubentry, defaultValue);
}
int64_t GetInteger(NT_Handle subentry, int64_t defaultValue) {
return GetAtomic<int64_t>(subentry, defaultValue).value;
}
TimestampedInteger GetAtomicInteger(
NT_Handle subentry, int64_t defaultValue) {
return GetAtomic<int64_t>(subentry, defaultValue);
}
std::vector<TimestampedInteger> ReadQueueInteger(NT_Handle subentry) {
return ReadQueue<int64_t>(subentry);
}
std::vector<int64_t> ReadQueueValuesInteger(NT_Handle subentry) {
return ReadQueueValues<int64_t>(subentry);
}
bool SetFloat(NT_Handle pubentry, float value, int64_t time) {
return Set<float>(pubentry, value, time);
}
bool SetDefaultFloat(NT_Handle pubentry, float defaultValue) {
return SetDefault<float>(pubentry, defaultValue);
}
float GetFloat(NT_Handle subentry, float defaultValue) {
return GetAtomic<float>(subentry, defaultValue).value;
}
TimestampedFloat GetAtomicFloat(
NT_Handle subentry, float defaultValue) {
return GetAtomic<float>(subentry, defaultValue);
}
std::vector<TimestampedFloat> ReadQueueFloat(NT_Handle subentry) {
return ReadQueue<float>(subentry);
}
std::vector<float> ReadQueueValuesFloat(NT_Handle subentry) {
return ReadQueueValues<float>(subentry);
}
bool SetDouble(NT_Handle pubentry, double value, int64_t time) {
return Set<double>(pubentry, value, time);
}
bool SetDefaultDouble(NT_Handle pubentry, double defaultValue) {
return SetDefault<double>(pubentry, defaultValue);
}
double GetDouble(NT_Handle subentry, double defaultValue) {
return GetAtomic<double>(subentry, defaultValue).value;
}
TimestampedDouble GetAtomicDouble(
NT_Handle subentry, double defaultValue) {
return GetAtomic<double>(subentry, defaultValue);
}
std::vector<TimestampedDouble> ReadQueueDouble(NT_Handle subentry) {
return ReadQueue<double>(subentry);
}
std::vector<double> ReadQueueValuesDouble(NT_Handle subentry) {
return ReadQueueValues<double>(subentry);
}
bool SetString(NT_Handle pubentry, std::string_view value, int64_t time) {
return Set<std::string>(pubentry, value, time);
}
bool SetDefaultString(NT_Handle pubentry, std::string_view defaultValue) {
return SetDefault<std::string>(pubentry, defaultValue);
}
std::string GetString(NT_Handle subentry, std::string_view defaultValue) {
return GetAtomic<std::string>(subentry, defaultValue).value;
}
TimestampedString GetAtomicString(
NT_Handle subentry, std::string_view defaultValue) {
return GetAtomic<std::string>(subentry, defaultValue);
}
std::vector<TimestampedString> ReadQueueString(NT_Handle subentry) {
return ReadQueue<std::string>(subentry);
}
std::vector<std::string> ReadQueueValuesString(NT_Handle subentry) {
return ReadQueueValues<std::string>(subentry);
}
std::string_view GetString(
NT_Handle subentry,
wpi::SmallVectorImpl<char>& buf,
std::string_view defaultValue) {
return GetAtomic<std::string>(subentry, buf, defaultValue).value;
}
TimestampedStringView GetAtomicString(
NT_Handle subentry,
wpi::SmallVectorImpl<char>& buf,
std::string_view defaultValue) {
return GetAtomic<std::string>(subentry, buf, defaultValue);
}
bool SetRaw(NT_Handle pubentry, std::span<const uint8_t> value, int64_t time) {
return Set<uint8_t[]>(pubentry, value, time);
}
bool SetDefaultRaw(NT_Handle pubentry, std::span<const uint8_t> defaultValue) {
return SetDefault<uint8_t[]>(pubentry, defaultValue);
}
std::vector<uint8_t> GetRaw(NT_Handle subentry, std::span<const uint8_t> defaultValue) {
return GetAtomic<uint8_t[]>(subentry, defaultValue).value;
}
TimestampedRaw GetAtomicRaw(
NT_Handle subentry, std::span<const uint8_t> defaultValue) {
return GetAtomic<uint8_t[]>(subentry, defaultValue);
}
std::vector<TimestampedRaw> ReadQueueRaw(NT_Handle subentry) {
return ReadQueue<uint8_t[]>(subentry);
}
std::vector<std::vector<uint8_t>> ReadQueueValuesRaw(NT_Handle subentry) {
return ReadQueueValues<uint8_t[]>(subentry);
}
std::span<uint8_t> GetRaw(
NT_Handle subentry,
wpi::SmallVectorImpl<uint8_t>& buf,
std::span<const uint8_t> defaultValue) {
return GetAtomic<uint8_t[]>(subentry, buf, defaultValue).value;
}
TimestampedRawView GetAtomicRaw(
NT_Handle subentry,
wpi::SmallVectorImpl<uint8_t>& buf,
std::span<const uint8_t> defaultValue) {
return GetAtomic<uint8_t[]>(subentry, buf, defaultValue);
}
bool SetBooleanArray(NT_Handle pubentry, std::span<const int> value, int64_t time) {
return Set<bool[]>(pubentry, value, time);
}
bool SetDefaultBooleanArray(NT_Handle pubentry, std::span<const int> defaultValue) {
return SetDefault<bool[]>(pubentry, defaultValue);
}
std::vector<int> GetBooleanArray(NT_Handle subentry, std::span<const int> defaultValue) {
return GetAtomic<bool[]>(subentry, defaultValue).value;
}
TimestampedBooleanArray GetAtomicBooleanArray(
NT_Handle subentry, std::span<const int> defaultValue) {
return GetAtomic<bool[]>(subentry, defaultValue);
}
std::vector<TimestampedBooleanArray> ReadQueueBooleanArray(NT_Handle subentry) {
return ReadQueue<bool[]>(subentry);
}
std::vector<std::vector<int>> ReadQueueValuesBooleanArray(NT_Handle subentry) {
return ReadQueueValues<bool[]>(subentry);
}
std::span<int> GetBooleanArray(
NT_Handle subentry,
wpi::SmallVectorImpl<int>& buf,
std::span<const int> defaultValue) {
return GetAtomic<bool[]>(subentry, buf, defaultValue).value;
}
TimestampedBooleanArrayView GetAtomicBooleanArray(
NT_Handle subentry,
wpi::SmallVectorImpl<int>& buf,
std::span<const int> defaultValue) {
return GetAtomic<bool[]>(subentry, buf, defaultValue);
}
bool SetIntegerArray(NT_Handle pubentry, std::span<const int64_t> value, int64_t time) {
return Set<int64_t[]>(pubentry, value, time);
}
bool SetDefaultIntegerArray(NT_Handle pubentry, std::span<const int64_t> defaultValue) {
return SetDefault<int64_t[]>(pubentry, defaultValue);
}
std::vector<int64_t> GetIntegerArray(NT_Handle subentry, std::span<const int64_t> defaultValue) {
return GetAtomic<int64_t[]>(subentry, defaultValue).value;
}
TimestampedIntegerArray GetAtomicIntegerArray(
NT_Handle subentry, std::span<const int64_t> defaultValue) {
return GetAtomic<int64_t[]>(subentry, defaultValue);
}
std::vector<TimestampedIntegerArray> ReadQueueIntegerArray(NT_Handle subentry) {
return ReadQueue<int64_t[]>(subentry);
}
std::vector<std::vector<int64_t>> ReadQueueValuesIntegerArray(NT_Handle subentry) {
return ReadQueueValues<int64_t[]>(subentry);
}
std::span<int64_t> GetIntegerArray(
NT_Handle subentry,
wpi::SmallVectorImpl<int64_t>& buf,
std::span<const int64_t> defaultValue) {
return GetAtomic<int64_t[]>(subentry, buf, defaultValue).value;
}
TimestampedIntegerArrayView GetAtomicIntegerArray(
NT_Handle subentry,
wpi::SmallVectorImpl<int64_t>& buf,
std::span<const int64_t> defaultValue) {
return GetAtomic<int64_t[]>(subentry, buf, defaultValue);
}
bool SetFloatArray(NT_Handle pubentry, std::span<const float> value, int64_t time) {
return Set<float[]>(pubentry, value, time);
}
bool SetDefaultFloatArray(NT_Handle pubentry, std::span<const float> defaultValue) {
return SetDefault<float[]>(pubentry, defaultValue);
}
std::vector<float> GetFloatArray(NT_Handle subentry, std::span<const float> defaultValue) {
return GetAtomic<float[]>(subentry, defaultValue).value;
}
TimestampedFloatArray GetAtomicFloatArray(
NT_Handle subentry, std::span<const float> defaultValue) {
return GetAtomic<float[]>(subentry, defaultValue);
}
std::vector<TimestampedFloatArray> ReadQueueFloatArray(NT_Handle subentry) {
return ReadQueue<float[]>(subentry);
}
std::vector<std::vector<float>> ReadQueueValuesFloatArray(NT_Handle subentry) {
return ReadQueueValues<float[]>(subentry);
}
std::span<float> GetFloatArray(
NT_Handle subentry,
wpi::SmallVectorImpl<float>& buf,
std::span<const float> defaultValue) {
return GetAtomic<float[]>(subentry, buf, defaultValue).value;
}
TimestampedFloatArrayView GetAtomicFloatArray(
NT_Handle subentry,
wpi::SmallVectorImpl<float>& buf,
std::span<const float> defaultValue) {
return GetAtomic<float[]>(subentry, buf, defaultValue);
}
bool SetDoubleArray(NT_Handle pubentry, std::span<const double> value, int64_t time) {
return Set<double[]>(pubentry, value, time);
}
bool SetDefaultDoubleArray(NT_Handle pubentry, std::span<const double> defaultValue) {
return SetDefault<double[]>(pubentry, defaultValue);
}
std::vector<double> GetDoubleArray(NT_Handle subentry, std::span<const double> defaultValue) {
return GetAtomic<double[]>(subentry, defaultValue).value;
}
TimestampedDoubleArray GetAtomicDoubleArray(
NT_Handle subentry, std::span<const double> defaultValue) {
return GetAtomic<double[]>(subentry, defaultValue);
}
std::vector<TimestampedDoubleArray> ReadQueueDoubleArray(NT_Handle subentry) {
return ReadQueue<double[]>(subentry);
}
std::vector<std::vector<double>> ReadQueueValuesDoubleArray(NT_Handle subentry) {
return ReadQueueValues<double[]>(subentry);
}
std::span<double> GetDoubleArray(
NT_Handle subentry,
wpi::SmallVectorImpl<double>& buf,
std::span<const double> defaultValue) {
return GetAtomic<double[]>(subentry, buf, defaultValue).value;
}
TimestampedDoubleArrayView GetAtomicDoubleArray(
NT_Handle subentry,
wpi::SmallVectorImpl<double>& buf,
std::span<const double> defaultValue) {
return GetAtomic<double[]>(subentry, buf, defaultValue);
}
bool SetStringArray(NT_Handle pubentry, std::span<const std::string> value, int64_t time) {
return Set<std::string[]>(pubentry, value, time);
}
bool SetDefaultStringArray(NT_Handle pubentry, std::span<const std::string> defaultValue) {
return SetDefault<std::string[]>(pubentry, defaultValue);
}
std::vector<std::string> GetStringArray(NT_Handle subentry, std::span<const std::string> defaultValue) {
return GetAtomic<std::string[]>(subentry, defaultValue).value;
}
TimestampedStringArray GetAtomicStringArray(
NT_Handle subentry, std::span<const std::string> defaultValue) {
return GetAtomic<std::string[]>(subentry, defaultValue);
}
std::vector<TimestampedStringArray> ReadQueueStringArray(NT_Handle subentry) {
return ReadQueue<std::string[]>(subentry);
}
std::vector<std::vector<std::string>> ReadQueueValuesStringArray(NT_Handle subentry) {
return ReadQueueValues<std::string[]>(subentry);
}
} // namespace nt

View File

@@ -0,0 +1,426 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <utility>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class BooleanArrayTopic;
/**
* NetworkTables BooleanArray subscriber.
*/
class BooleanArraySubscriber : public Subscriber {
public:
using TopicType = BooleanArrayTopic;
using ValueType = std::vector<int>;
using ParamType = std::span<const int>;
using TimestampedValueType = TimestampedBooleanArray;
using SmallRetType = std::span<int>;
using SmallElemType = int;
using TimestampedValueViewType = TimestampedBooleanArrayView;
BooleanArraySubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* BooleanArrayTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
BooleanArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @param buf storage for returned value
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @param buf storage for returned value
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf,
ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables BooleanArray publisher.
*/
class BooleanArrayPublisher : public Publisher {
public:
using TopicType = BooleanArrayTopic;
using ValueType = std::vector<int>;
using ParamType = std::span<const int>;
using SmallRetType = std::span<int>;
using SmallElemType = int;
using TimestampedValueType = TimestampedBooleanArray;
BooleanArrayPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* BooleanArrayTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit BooleanArrayPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables BooleanArray entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class BooleanArrayEntry final : public BooleanArraySubscriber,
public BooleanArrayPublisher {
public:
using SubscriberType = BooleanArraySubscriber;
using PublisherType = BooleanArrayPublisher;
using TopicType = BooleanArrayTopic;
using ValueType = std::vector<int>;
using ParamType = std::span<const int>;
using SmallRetType = std::span<int>;
using SmallElemType = int;
using TimestampedValueType = TimestampedBooleanArray;
BooleanArrayEntry() = default;
/**
* Construct from an entry handle; recommended to use
* BooleanArrayTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
BooleanArrayEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables BooleanArray topic.
*/
class BooleanArrayTopic final : public Topic {
public:
using SubscriberType = BooleanArraySubscriber;
using PublisherType = BooleanArrayPublisher;
using EntryType = BooleanArrayEntry;
using ValueType = std::vector<int>;
using ParamType = std::span<const int>;
using TimestampedValueType = TimestampedBooleanArray;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "boolean[]";
BooleanArrayTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetBooleanArrayTopic() instead.
*
* @param handle Native handle
*/
explicit BooleanArrayTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit BooleanArrayTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/BooleanArrayTopic.inc"

View File

@@ -0,0 +1,137 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/BooleanArrayTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline BooleanArraySubscriber::BooleanArraySubscriber(
NT_Subscriber handle, std::span<const int> defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
inline std::vector<int> BooleanArraySubscriber::Get() const {
return Get(m_defaultValue);
}
inline std::vector<int> BooleanArraySubscriber::Get(
std::span<const int> defaultValue) const {
return ::nt::GetBooleanArray(m_subHandle, defaultValue);
}
inline std::span<int> BooleanArraySubscriber::Get(wpi::SmallVectorImpl<int>& buf) const {
return Get(buf, m_defaultValue);
}
inline std::span<int> BooleanArraySubscriber::Get(wpi::SmallVectorImpl<int>& buf, std::span<const int> defaultValue) const {
return nt::GetBooleanArray(m_subHandle, buf, defaultValue);
}
inline TimestampedBooleanArray BooleanArraySubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedBooleanArray BooleanArraySubscriber::GetAtomic(
std::span<const int> defaultValue) const {
return ::nt::GetAtomicBooleanArray(m_subHandle, defaultValue);
}
inline TimestampedBooleanArrayView BooleanArraySubscriber::GetAtomic(wpi::SmallVectorImpl<int>& buf) const {
return GetAtomic(buf, m_defaultValue);
}
inline TimestampedBooleanArrayView BooleanArraySubscriber::GetAtomic(wpi::SmallVectorImpl<int>& buf, std::span<const int> defaultValue) const {
return nt::GetAtomicBooleanArray(m_subHandle, buf, defaultValue);
}
inline std::vector<TimestampedBooleanArray>
BooleanArraySubscriber::ReadQueue() {
return ::nt::ReadQueueBooleanArray(m_subHandle);
}
inline BooleanArrayTopic BooleanArraySubscriber::GetTopic() const {
return BooleanArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline BooleanArrayPublisher::BooleanArrayPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void BooleanArrayPublisher::Set(std::span<const int> value,
int64_t time) {
::nt::SetBooleanArray(m_pubHandle, value, time);
}
inline void BooleanArrayPublisher::SetDefault(std::span<const int> value) {
::nt::SetDefaultBooleanArray(m_pubHandle, value);
}
inline BooleanArrayTopic BooleanArrayPublisher::GetTopic() const {
return BooleanArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline BooleanArrayEntry::BooleanArrayEntry(
NT_Entry handle, std::span<const int> defaultValue)
: BooleanArraySubscriber{handle, defaultValue},
BooleanArrayPublisher{handle} {}
inline BooleanArrayTopic BooleanArrayEntry::GetTopic() const {
return BooleanArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void BooleanArrayEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline BooleanArraySubscriber BooleanArrayTopic::Subscribe(
std::span<const int> defaultValue,
const PubSubOptions& options) {
return BooleanArraySubscriber{
::nt::Subscribe(m_handle, NT_BOOLEAN_ARRAY, "boolean[]", options),
defaultValue};
}
inline BooleanArraySubscriber BooleanArrayTopic::SubscribeEx(
std::string_view typeString, std::span<const int> defaultValue,
const PubSubOptions& options) {
return BooleanArraySubscriber{
::nt::Subscribe(m_handle, NT_BOOLEAN_ARRAY, typeString, options),
defaultValue};
}
inline BooleanArrayPublisher BooleanArrayTopic::Publish(
const PubSubOptions& options) {
return BooleanArrayPublisher{
::nt::Publish(m_handle, NT_BOOLEAN_ARRAY, "boolean[]", options)};
}
inline BooleanArrayPublisher BooleanArrayTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return BooleanArrayPublisher{
::nt::PublishEx(m_handle, NT_BOOLEAN_ARRAY, typeString, properties, options)};
}
inline BooleanArrayEntry BooleanArrayTopic::GetEntry(
std::span<const int> defaultValue,
const PubSubOptions& options) {
return BooleanArrayEntry{
::nt::GetEntry(m_handle, NT_BOOLEAN_ARRAY, "boolean[]", options),
defaultValue};
}
inline BooleanArrayEntry BooleanArrayTopic::GetEntryEx(
std::string_view typeString, std::span<const int> defaultValue,
const PubSubOptions& options) {
return BooleanArrayEntry{
::nt::GetEntry(m_handle, NT_BOOLEAN_ARRAY, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,373 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class BooleanTopic;
/**
* NetworkTables Boolean subscriber.
*/
class BooleanSubscriber : public Subscriber {
public:
using TopicType = BooleanTopic;
using ValueType = bool;
using ParamType = bool;
using TimestampedValueType = TimestampedBoolean;
BooleanSubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* BooleanTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
BooleanSubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables Boolean publisher.
*/
class BooleanPublisher : public Publisher {
public:
using TopicType = BooleanTopic;
using ValueType = bool;
using ParamType = bool;
using TimestampedValueType = TimestampedBoolean;
BooleanPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* BooleanTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit BooleanPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables Boolean entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class BooleanEntry final : public BooleanSubscriber,
public BooleanPublisher {
public:
using SubscriberType = BooleanSubscriber;
using PublisherType = BooleanPublisher;
using TopicType = BooleanTopic;
using ValueType = bool;
using ParamType = bool;
using TimestampedValueType = TimestampedBoolean;
BooleanEntry() = default;
/**
* Construct from an entry handle; recommended to use
* BooleanTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
BooleanEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables Boolean topic.
*/
class BooleanTopic final : public Topic {
public:
using SubscriberType = BooleanSubscriber;
using PublisherType = BooleanPublisher;
using EntryType = BooleanEntry;
using ValueType = bool;
using ParamType = bool;
using TimestampedValueType = TimestampedBoolean;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "boolean";
BooleanTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetBooleanTopic() instead.
*
* @param handle Native handle
*/
explicit BooleanTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit BooleanTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/BooleanTopic.inc"

View File

@@ -0,0 +1,121 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/BooleanTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline BooleanSubscriber::BooleanSubscriber(
NT_Subscriber handle, bool defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue} {}
inline bool BooleanSubscriber::Get() const {
return Get(m_defaultValue);
}
inline bool BooleanSubscriber::Get(
bool defaultValue) const {
return ::nt::GetBoolean(m_subHandle, defaultValue);
}
inline TimestampedBoolean BooleanSubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedBoolean BooleanSubscriber::GetAtomic(
bool defaultValue) const {
return ::nt::GetAtomicBoolean(m_subHandle, defaultValue);
}
inline std::vector<TimestampedBoolean>
BooleanSubscriber::ReadQueue() {
return ::nt::ReadQueueBoolean(m_subHandle);
}
inline BooleanTopic BooleanSubscriber::GetTopic() const {
return BooleanTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline BooleanPublisher::BooleanPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void BooleanPublisher::Set(bool value,
int64_t time) {
::nt::SetBoolean(m_pubHandle, value, time);
}
inline void BooleanPublisher::SetDefault(bool value) {
::nt::SetDefaultBoolean(m_pubHandle, value);
}
inline BooleanTopic BooleanPublisher::GetTopic() const {
return BooleanTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline BooleanEntry::BooleanEntry(
NT_Entry handle, bool defaultValue)
: BooleanSubscriber{handle, defaultValue},
BooleanPublisher{handle} {}
inline BooleanTopic BooleanEntry::GetTopic() const {
return BooleanTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void BooleanEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline BooleanSubscriber BooleanTopic::Subscribe(
bool defaultValue,
const PubSubOptions& options) {
return BooleanSubscriber{
::nt::Subscribe(m_handle, NT_BOOLEAN, "boolean", options),
defaultValue};
}
inline BooleanSubscriber BooleanTopic::SubscribeEx(
std::string_view typeString, bool defaultValue,
const PubSubOptions& options) {
return BooleanSubscriber{
::nt::Subscribe(m_handle, NT_BOOLEAN, typeString, options),
defaultValue};
}
inline BooleanPublisher BooleanTopic::Publish(
const PubSubOptions& options) {
return BooleanPublisher{
::nt::Publish(m_handle, NT_BOOLEAN, "boolean", options)};
}
inline BooleanPublisher BooleanTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return BooleanPublisher{
::nt::PublishEx(m_handle, NT_BOOLEAN, typeString, properties, options)};
}
inline BooleanEntry BooleanTopic::GetEntry(
bool defaultValue,
const PubSubOptions& options) {
return BooleanEntry{
::nt::GetEntry(m_handle, NT_BOOLEAN, "boolean", options),
defaultValue};
}
inline BooleanEntry BooleanTopic::GetEntryEx(
std::string_view typeString, bool defaultValue,
const PubSubOptions& options) {
return BooleanEntry{
::nt::GetEntry(m_handle, NT_BOOLEAN, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,426 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <utility>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class DoubleArrayTopic;
/**
* NetworkTables DoubleArray subscriber.
*/
class DoubleArraySubscriber : public Subscriber {
public:
using TopicType = DoubleArrayTopic;
using ValueType = std::vector<double>;
using ParamType = std::span<const double>;
using TimestampedValueType = TimestampedDoubleArray;
using SmallRetType = std::span<double>;
using SmallElemType = double;
using TimestampedValueViewType = TimestampedDoubleArrayView;
DoubleArraySubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* DoubleArrayTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
DoubleArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @param buf storage for returned value
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @param buf storage for returned value
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf,
ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables DoubleArray publisher.
*/
class DoubleArrayPublisher : public Publisher {
public:
using TopicType = DoubleArrayTopic;
using ValueType = std::vector<double>;
using ParamType = std::span<const double>;
using SmallRetType = std::span<double>;
using SmallElemType = double;
using TimestampedValueType = TimestampedDoubleArray;
DoubleArrayPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* DoubleArrayTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit DoubleArrayPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables DoubleArray entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class DoubleArrayEntry final : public DoubleArraySubscriber,
public DoubleArrayPublisher {
public:
using SubscriberType = DoubleArraySubscriber;
using PublisherType = DoubleArrayPublisher;
using TopicType = DoubleArrayTopic;
using ValueType = std::vector<double>;
using ParamType = std::span<const double>;
using SmallRetType = std::span<double>;
using SmallElemType = double;
using TimestampedValueType = TimestampedDoubleArray;
DoubleArrayEntry() = default;
/**
* Construct from an entry handle; recommended to use
* DoubleArrayTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
DoubleArrayEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables DoubleArray topic.
*/
class DoubleArrayTopic final : public Topic {
public:
using SubscriberType = DoubleArraySubscriber;
using PublisherType = DoubleArrayPublisher;
using EntryType = DoubleArrayEntry;
using ValueType = std::vector<double>;
using ParamType = std::span<const double>;
using TimestampedValueType = TimestampedDoubleArray;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "double[]";
DoubleArrayTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetDoubleArrayTopic() instead.
*
* @param handle Native handle
*/
explicit DoubleArrayTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit DoubleArrayTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/DoubleArrayTopic.inc"

View File

@@ -0,0 +1,137 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/DoubleArrayTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline DoubleArraySubscriber::DoubleArraySubscriber(
NT_Subscriber handle, std::span<const double> defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
inline std::vector<double> DoubleArraySubscriber::Get() const {
return Get(m_defaultValue);
}
inline std::vector<double> DoubleArraySubscriber::Get(
std::span<const double> defaultValue) const {
return ::nt::GetDoubleArray(m_subHandle, defaultValue);
}
inline std::span<double> DoubleArraySubscriber::Get(wpi::SmallVectorImpl<double>& buf) const {
return Get(buf, m_defaultValue);
}
inline std::span<double> DoubleArraySubscriber::Get(wpi::SmallVectorImpl<double>& buf, std::span<const double> defaultValue) const {
return nt::GetDoubleArray(m_subHandle, buf, defaultValue);
}
inline TimestampedDoubleArray DoubleArraySubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedDoubleArray DoubleArraySubscriber::GetAtomic(
std::span<const double> defaultValue) const {
return ::nt::GetAtomicDoubleArray(m_subHandle, defaultValue);
}
inline TimestampedDoubleArrayView DoubleArraySubscriber::GetAtomic(wpi::SmallVectorImpl<double>& buf) const {
return GetAtomic(buf, m_defaultValue);
}
inline TimestampedDoubleArrayView DoubleArraySubscriber::GetAtomic(wpi::SmallVectorImpl<double>& buf, std::span<const double> defaultValue) const {
return nt::GetAtomicDoubleArray(m_subHandle, buf, defaultValue);
}
inline std::vector<TimestampedDoubleArray>
DoubleArraySubscriber::ReadQueue() {
return ::nt::ReadQueueDoubleArray(m_subHandle);
}
inline DoubleArrayTopic DoubleArraySubscriber::GetTopic() const {
return DoubleArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline DoubleArrayPublisher::DoubleArrayPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void DoubleArrayPublisher::Set(std::span<const double> value,
int64_t time) {
::nt::SetDoubleArray(m_pubHandle, value, time);
}
inline void DoubleArrayPublisher::SetDefault(std::span<const double> value) {
::nt::SetDefaultDoubleArray(m_pubHandle, value);
}
inline DoubleArrayTopic DoubleArrayPublisher::GetTopic() const {
return DoubleArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline DoubleArrayEntry::DoubleArrayEntry(
NT_Entry handle, std::span<const double> defaultValue)
: DoubleArraySubscriber{handle, defaultValue},
DoubleArrayPublisher{handle} {}
inline DoubleArrayTopic DoubleArrayEntry::GetTopic() const {
return DoubleArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void DoubleArrayEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline DoubleArraySubscriber DoubleArrayTopic::Subscribe(
std::span<const double> defaultValue,
const PubSubOptions& options) {
return DoubleArraySubscriber{
::nt::Subscribe(m_handle, NT_DOUBLE_ARRAY, "double[]", options),
defaultValue};
}
inline DoubleArraySubscriber DoubleArrayTopic::SubscribeEx(
std::string_view typeString, std::span<const double> defaultValue,
const PubSubOptions& options) {
return DoubleArraySubscriber{
::nt::Subscribe(m_handle, NT_DOUBLE_ARRAY, typeString, options),
defaultValue};
}
inline DoubleArrayPublisher DoubleArrayTopic::Publish(
const PubSubOptions& options) {
return DoubleArrayPublisher{
::nt::Publish(m_handle, NT_DOUBLE_ARRAY, "double[]", options)};
}
inline DoubleArrayPublisher DoubleArrayTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return DoubleArrayPublisher{
::nt::PublishEx(m_handle, NT_DOUBLE_ARRAY, typeString, properties, options)};
}
inline DoubleArrayEntry DoubleArrayTopic::GetEntry(
std::span<const double> defaultValue,
const PubSubOptions& options) {
return DoubleArrayEntry{
::nt::GetEntry(m_handle, NT_DOUBLE_ARRAY, "double[]", options),
defaultValue};
}
inline DoubleArrayEntry DoubleArrayTopic::GetEntryEx(
std::string_view typeString, std::span<const double> defaultValue,
const PubSubOptions& options) {
return DoubleArrayEntry{
::nt::GetEntry(m_handle, NT_DOUBLE_ARRAY, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,373 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class DoubleTopic;
/**
* NetworkTables Double subscriber.
*/
class DoubleSubscriber : public Subscriber {
public:
using TopicType = DoubleTopic;
using ValueType = double;
using ParamType = double;
using TimestampedValueType = TimestampedDouble;
DoubleSubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* DoubleTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
DoubleSubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables Double publisher.
*/
class DoublePublisher : public Publisher {
public:
using TopicType = DoubleTopic;
using ValueType = double;
using ParamType = double;
using TimestampedValueType = TimestampedDouble;
DoublePublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* DoubleTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit DoublePublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables Double entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class DoubleEntry final : public DoubleSubscriber,
public DoublePublisher {
public:
using SubscriberType = DoubleSubscriber;
using PublisherType = DoublePublisher;
using TopicType = DoubleTopic;
using ValueType = double;
using ParamType = double;
using TimestampedValueType = TimestampedDouble;
DoubleEntry() = default;
/**
* Construct from an entry handle; recommended to use
* DoubleTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
DoubleEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables Double topic.
*/
class DoubleTopic final : public Topic {
public:
using SubscriberType = DoubleSubscriber;
using PublisherType = DoublePublisher;
using EntryType = DoubleEntry;
using ValueType = double;
using ParamType = double;
using TimestampedValueType = TimestampedDouble;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "double";
DoubleTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetDoubleTopic() instead.
*
* @param handle Native handle
*/
explicit DoubleTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit DoubleTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/DoubleTopic.inc"

View File

@@ -0,0 +1,121 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/DoubleTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline DoubleSubscriber::DoubleSubscriber(
NT_Subscriber handle, double defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue} {}
inline double DoubleSubscriber::Get() const {
return Get(m_defaultValue);
}
inline double DoubleSubscriber::Get(
double defaultValue) const {
return ::nt::GetDouble(m_subHandle, defaultValue);
}
inline TimestampedDouble DoubleSubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedDouble DoubleSubscriber::GetAtomic(
double defaultValue) const {
return ::nt::GetAtomicDouble(m_subHandle, defaultValue);
}
inline std::vector<TimestampedDouble>
DoubleSubscriber::ReadQueue() {
return ::nt::ReadQueueDouble(m_subHandle);
}
inline DoubleTopic DoubleSubscriber::GetTopic() const {
return DoubleTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline DoublePublisher::DoublePublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void DoublePublisher::Set(double value,
int64_t time) {
::nt::SetDouble(m_pubHandle, value, time);
}
inline void DoublePublisher::SetDefault(double value) {
::nt::SetDefaultDouble(m_pubHandle, value);
}
inline DoubleTopic DoublePublisher::GetTopic() const {
return DoubleTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline DoubleEntry::DoubleEntry(
NT_Entry handle, double defaultValue)
: DoubleSubscriber{handle, defaultValue},
DoublePublisher{handle} {}
inline DoubleTopic DoubleEntry::GetTopic() const {
return DoubleTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void DoubleEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline DoubleSubscriber DoubleTopic::Subscribe(
double defaultValue,
const PubSubOptions& options) {
return DoubleSubscriber{
::nt::Subscribe(m_handle, NT_DOUBLE, "double", options),
defaultValue};
}
inline DoubleSubscriber DoubleTopic::SubscribeEx(
std::string_view typeString, double defaultValue,
const PubSubOptions& options) {
return DoubleSubscriber{
::nt::Subscribe(m_handle, NT_DOUBLE, typeString, options),
defaultValue};
}
inline DoublePublisher DoubleTopic::Publish(
const PubSubOptions& options) {
return DoublePublisher{
::nt::Publish(m_handle, NT_DOUBLE, "double", options)};
}
inline DoublePublisher DoubleTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return DoublePublisher{
::nt::PublishEx(m_handle, NT_DOUBLE, typeString, properties, options)};
}
inline DoubleEntry DoubleTopic::GetEntry(
double defaultValue,
const PubSubOptions& options) {
return DoubleEntry{
::nt::GetEntry(m_handle, NT_DOUBLE, "double", options),
defaultValue};
}
inline DoubleEntry DoubleTopic::GetEntryEx(
std::string_view typeString, double defaultValue,
const PubSubOptions& options) {
return DoubleEntry{
::nt::GetEntry(m_handle, NT_DOUBLE, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,426 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <utility>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class FloatArrayTopic;
/**
* NetworkTables FloatArray subscriber.
*/
class FloatArraySubscriber : public Subscriber {
public:
using TopicType = FloatArrayTopic;
using ValueType = std::vector<float>;
using ParamType = std::span<const float>;
using TimestampedValueType = TimestampedFloatArray;
using SmallRetType = std::span<float>;
using SmallElemType = float;
using TimestampedValueViewType = TimestampedFloatArrayView;
FloatArraySubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* FloatArrayTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
FloatArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @param buf storage for returned value
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @param buf storage for returned value
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf,
ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables FloatArray publisher.
*/
class FloatArrayPublisher : public Publisher {
public:
using TopicType = FloatArrayTopic;
using ValueType = std::vector<float>;
using ParamType = std::span<const float>;
using SmallRetType = std::span<float>;
using SmallElemType = float;
using TimestampedValueType = TimestampedFloatArray;
FloatArrayPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* FloatArrayTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit FloatArrayPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables FloatArray entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class FloatArrayEntry final : public FloatArraySubscriber,
public FloatArrayPublisher {
public:
using SubscriberType = FloatArraySubscriber;
using PublisherType = FloatArrayPublisher;
using TopicType = FloatArrayTopic;
using ValueType = std::vector<float>;
using ParamType = std::span<const float>;
using SmallRetType = std::span<float>;
using SmallElemType = float;
using TimestampedValueType = TimestampedFloatArray;
FloatArrayEntry() = default;
/**
* Construct from an entry handle; recommended to use
* FloatArrayTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
FloatArrayEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables FloatArray topic.
*/
class FloatArrayTopic final : public Topic {
public:
using SubscriberType = FloatArraySubscriber;
using PublisherType = FloatArrayPublisher;
using EntryType = FloatArrayEntry;
using ValueType = std::vector<float>;
using ParamType = std::span<const float>;
using TimestampedValueType = TimestampedFloatArray;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "float[]";
FloatArrayTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetFloatArrayTopic() instead.
*
* @param handle Native handle
*/
explicit FloatArrayTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit FloatArrayTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/FloatArrayTopic.inc"

View File

@@ -0,0 +1,137 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/FloatArrayTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline FloatArraySubscriber::FloatArraySubscriber(
NT_Subscriber handle, std::span<const float> defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
inline std::vector<float> FloatArraySubscriber::Get() const {
return Get(m_defaultValue);
}
inline std::vector<float> FloatArraySubscriber::Get(
std::span<const float> defaultValue) const {
return ::nt::GetFloatArray(m_subHandle, defaultValue);
}
inline std::span<float> FloatArraySubscriber::Get(wpi::SmallVectorImpl<float>& buf) const {
return Get(buf, m_defaultValue);
}
inline std::span<float> FloatArraySubscriber::Get(wpi::SmallVectorImpl<float>& buf, std::span<const float> defaultValue) const {
return nt::GetFloatArray(m_subHandle, buf, defaultValue);
}
inline TimestampedFloatArray FloatArraySubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedFloatArray FloatArraySubscriber::GetAtomic(
std::span<const float> defaultValue) const {
return ::nt::GetAtomicFloatArray(m_subHandle, defaultValue);
}
inline TimestampedFloatArrayView FloatArraySubscriber::GetAtomic(wpi::SmallVectorImpl<float>& buf) const {
return GetAtomic(buf, m_defaultValue);
}
inline TimestampedFloatArrayView FloatArraySubscriber::GetAtomic(wpi::SmallVectorImpl<float>& buf, std::span<const float> defaultValue) const {
return nt::GetAtomicFloatArray(m_subHandle, buf, defaultValue);
}
inline std::vector<TimestampedFloatArray>
FloatArraySubscriber::ReadQueue() {
return ::nt::ReadQueueFloatArray(m_subHandle);
}
inline FloatArrayTopic FloatArraySubscriber::GetTopic() const {
return FloatArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline FloatArrayPublisher::FloatArrayPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void FloatArrayPublisher::Set(std::span<const float> value,
int64_t time) {
::nt::SetFloatArray(m_pubHandle, value, time);
}
inline void FloatArrayPublisher::SetDefault(std::span<const float> value) {
::nt::SetDefaultFloatArray(m_pubHandle, value);
}
inline FloatArrayTopic FloatArrayPublisher::GetTopic() const {
return FloatArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline FloatArrayEntry::FloatArrayEntry(
NT_Entry handle, std::span<const float> defaultValue)
: FloatArraySubscriber{handle, defaultValue},
FloatArrayPublisher{handle} {}
inline FloatArrayTopic FloatArrayEntry::GetTopic() const {
return FloatArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void FloatArrayEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline FloatArraySubscriber FloatArrayTopic::Subscribe(
std::span<const float> defaultValue,
const PubSubOptions& options) {
return FloatArraySubscriber{
::nt::Subscribe(m_handle, NT_FLOAT_ARRAY, "float[]", options),
defaultValue};
}
inline FloatArraySubscriber FloatArrayTopic::SubscribeEx(
std::string_view typeString, std::span<const float> defaultValue,
const PubSubOptions& options) {
return FloatArraySubscriber{
::nt::Subscribe(m_handle, NT_FLOAT_ARRAY, typeString, options),
defaultValue};
}
inline FloatArrayPublisher FloatArrayTopic::Publish(
const PubSubOptions& options) {
return FloatArrayPublisher{
::nt::Publish(m_handle, NT_FLOAT_ARRAY, "float[]", options)};
}
inline FloatArrayPublisher FloatArrayTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return FloatArrayPublisher{
::nt::PublishEx(m_handle, NT_FLOAT_ARRAY, typeString, properties, options)};
}
inline FloatArrayEntry FloatArrayTopic::GetEntry(
std::span<const float> defaultValue,
const PubSubOptions& options) {
return FloatArrayEntry{
::nt::GetEntry(m_handle, NT_FLOAT_ARRAY, "float[]", options),
defaultValue};
}
inline FloatArrayEntry FloatArrayTopic::GetEntryEx(
std::string_view typeString, std::span<const float> defaultValue,
const PubSubOptions& options) {
return FloatArrayEntry{
::nt::GetEntry(m_handle, NT_FLOAT_ARRAY, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,373 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class FloatTopic;
/**
* NetworkTables Float subscriber.
*/
class FloatSubscriber : public Subscriber {
public:
using TopicType = FloatTopic;
using ValueType = float;
using ParamType = float;
using TimestampedValueType = TimestampedFloat;
FloatSubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* FloatTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
FloatSubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables Float publisher.
*/
class FloatPublisher : public Publisher {
public:
using TopicType = FloatTopic;
using ValueType = float;
using ParamType = float;
using TimestampedValueType = TimestampedFloat;
FloatPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* FloatTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit FloatPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables Float entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class FloatEntry final : public FloatSubscriber,
public FloatPublisher {
public:
using SubscriberType = FloatSubscriber;
using PublisherType = FloatPublisher;
using TopicType = FloatTopic;
using ValueType = float;
using ParamType = float;
using TimestampedValueType = TimestampedFloat;
FloatEntry() = default;
/**
* Construct from an entry handle; recommended to use
* FloatTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
FloatEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables Float topic.
*/
class FloatTopic final : public Topic {
public:
using SubscriberType = FloatSubscriber;
using PublisherType = FloatPublisher;
using EntryType = FloatEntry;
using ValueType = float;
using ParamType = float;
using TimestampedValueType = TimestampedFloat;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "float";
FloatTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetFloatTopic() instead.
*
* @param handle Native handle
*/
explicit FloatTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit FloatTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/FloatTopic.inc"

View File

@@ -0,0 +1,121 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/FloatTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline FloatSubscriber::FloatSubscriber(
NT_Subscriber handle, float defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue} {}
inline float FloatSubscriber::Get() const {
return Get(m_defaultValue);
}
inline float FloatSubscriber::Get(
float defaultValue) const {
return ::nt::GetFloat(m_subHandle, defaultValue);
}
inline TimestampedFloat FloatSubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedFloat FloatSubscriber::GetAtomic(
float defaultValue) const {
return ::nt::GetAtomicFloat(m_subHandle, defaultValue);
}
inline std::vector<TimestampedFloat>
FloatSubscriber::ReadQueue() {
return ::nt::ReadQueueFloat(m_subHandle);
}
inline FloatTopic FloatSubscriber::GetTopic() const {
return FloatTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline FloatPublisher::FloatPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void FloatPublisher::Set(float value,
int64_t time) {
::nt::SetFloat(m_pubHandle, value, time);
}
inline void FloatPublisher::SetDefault(float value) {
::nt::SetDefaultFloat(m_pubHandle, value);
}
inline FloatTopic FloatPublisher::GetTopic() const {
return FloatTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline FloatEntry::FloatEntry(
NT_Entry handle, float defaultValue)
: FloatSubscriber{handle, defaultValue},
FloatPublisher{handle} {}
inline FloatTopic FloatEntry::GetTopic() const {
return FloatTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void FloatEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline FloatSubscriber FloatTopic::Subscribe(
float defaultValue,
const PubSubOptions& options) {
return FloatSubscriber{
::nt::Subscribe(m_handle, NT_FLOAT, "float", options),
defaultValue};
}
inline FloatSubscriber FloatTopic::SubscribeEx(
std::string_view typeString, float defaultValue,
const PubSubOptions& options) {
return FloatSubscriber{
::nt::Subscribe(m_handle, NT_FLOAT, typeString, options),
defaultValue};
}
inline FloatPublisher FloatTopic::Publish(
const PubSubOptions& options) {
return FloatPublisher{
::nt::Publish(m_handle, NT_FLOAT, "float", options)};
}
inline FloatPublisher FloatTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return FloatPublisher{
::nt::PublishEx(m_handle, NT_FLOAT, typeString, properties, options)};
}
inline FloatEntry FloatTopic::GetEntry(
float defaultValue,
const PubSubOptions& options) {
return FloatEntry{
::nt::GetEntry(m_handle, NT_FLOAT, "float", options),
defaultValue};
}
inline FloatEntry FloatTopic::GetEntryEx(
std::string_view typeString, float defaultValue,
const PubSubOptions& options) {
return FloatEntry{
::nt::GetEntry(m_handle, NT_FLOAT, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,426 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <utility>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class IntegerArrayTopic;
/**
* NetworkTables IntegerArray subscriber.
*/
class IntegerArraySubscriber : public Subscriber {
public:
using TopicType = IntegerArrayTopic;
using ValueType = std::vector<int64_t>;
using ParamType = std::span<const int64_t>;
using TimestampedValueType = TimestampedIntegerArray;
using SmallRetType = std::span<int64_t>;
using SmallElemType = int64_t;
using TimestampedValueViewType = TimestampedIntegerArrayView;
IntegerArraySubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* IntegerArrayTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
IntegerArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @param buf storage for returned value
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @param buf storage for returned value
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf,
ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables IntegerArray publisher.
*/
class IntegerArrayPublisher : public Publisher {
public:
using TopicType = IntegerArrayTopic;
using ValueType = std::vector<int64_t>;
using ParamType = std::span<const int64_t>;
using SmallRetType = std::span<int64_t>;
using SmallElemType = int64_t;
using TimestampedValueType = TimestampedIntegerArray;
IntegerArrayPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* IntegerArrayTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit IntegerArrayPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables IntegerArray entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class IntegerArrayEntry final : public IntegerArraySubscriber,
public IntegerArrayPublisher {
public:
using SubscriberType = IntegerArraySubscriber;
using PublisherType = IntegerArrayPublisher;
using TopicType = IntegerArrayTopic;
using ValueType = std::vector<int64_t>;
using ParamType = std::span<const int64_t>;
using SmallRetType = std::span<int64_t>;
using SmallElemType = int64_t;
using TimestampedValueType = TimestampedIntegerArray;
IntegerArrayEntry() = default;
/**
* Construct from an entry handle; recommended to use
* IntegerArrayTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
IntegerArrayEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables IntegerArray topic.
*/
class IntegerArrayTopic final : public Topic {
public:
using SubscriberType = IntegerArraySubscriber;
using PublisherType = IntegerArrayPublisher;
using EntryType = IntegerArrayEntry;
using ValueType = std::vector<int64_t>;
using ParamType = std::span<const int64_t>;
using TimestampedValueType = TimestampedIntegerArray;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "int[]";
IntegerArrayTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetIntegerArrayTopic() instead.
*
* @param handle Native handle
*/
explicit IntegerArrayTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit IntegerArrayTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/IntegerArrayTopic.inc"

View File

@@ -0,0 +1,137 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/IntegerArrayTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline IntegerArraySubscriber::IntegerArraySubscriber(
NT_Subscriber handle, std::span<const int64_t> defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
inline std::vector<int64_t> IntegerArraySubscriber::Get() const {
return Get(m_defaultValue);
}
inline std::vector<int64_t> IntegerArraySubscriber::Get(
std::span<const int64_t> defaultValue) const {
return ::nt::GetIntegerArray(m_subHandle, defaultValue);
}
inline std::span<int64_t> IntegerArraySubscriber::Get(wpi::SmallVectorImpl<int64_t>& buf) const {
return Get(buf, m_defaultValue);
}
inline std::span<int64_t> IntegerArraySubscriber::Get(wpi::SmallVectorImpl<int64_t>& buf, std::span<const int64_t> defaultValue) const {
return nt::GetIntegerArray(m_subHandle, buf, defaultValue);
}
inline TimestampedIntegerArray IntegerArraySubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedIntegerArray IntegerArraySubscriber::GetAtomic(
std::span<const int64_t> defaultValue) const {
return ::nt::GetAtomicIntegerArray(m_subHandle, defaultValue);
}
inline TimestampedIntegerArrayView IntegerArraySubscriber::GetAtomic(wpi::SmallVectorImpl<int64_t>& buf) const {
return GetAtomic(buf, m_defaultValue);
}
inline TimestampedIntegerArrayView IntegerArraySubscriber::GetAtomic(wpi::SmallVectorImpl<int64_t>& buf, std::span<const int64_t> defaultValue) const {
return nt::GetAtomicIntegerArray(m_subHandle, buf, defaultValue);
}
inline std::vector<TimestampedIntegerArray>
IntegerArraySubscriber::ReadQueue() {
return ::nt::ReadQueueIntegerArray(m_subHandle);
}
inline IntegerArrayTopic IntegerArraySubscriber::GetTopic() const {
return IntegerArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline IntegerArrayPublisher::IntegerArrayPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void IntegerArrayPublisher::Set(std::span<const int64_t> value,
int64_t time) {
::nt::SetIntegerArray(m_pubHandle, value, time);
}
inline void IntegerArrayPublisher::SetDefault(std::span<const int64_t> value) {
::nt::SetDefaultIntegerArray(m_pubHandle, value);
}
inline IntegerArrayTopic IntegerArrayPublisher::GetTopic() const {
return IntegerArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline IntegerArrayEntry::IntegerArrayEntry(
NT_Entry handle, std::span<const int64_t> defaultValue)
: IntegerArraySubscriber{handle, defaultValue},
IntegerArrayPublisher{handle} {}
inline IntegerArrayTopic IntegerArrayEntry::GetTopic() const {
return IntegerArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void IntegerArrayEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline IntegerArraySubscriber IntegerArrayTopic::Subscribe(
std::span<const int64_t> defaultValue,
const PubSubOptions& options) {
return IntegerArraySubscriber{
::nt::Subscribe(m_handle, NT_INTEGER_ARRAY, "int[]", options),
defaultValue};
}
inline IntegerArraySubscriber IntegerArrayTopic::SubscribeEx(
std::string_view typeString, std::span<const int64_t> defaultValue,
const PubSubOptions& options) {
return IntegerArraySubscriber{
::nt::Subscribe(m_handle, NT_INTEGER_ARRAY, typeString, options),
defaultValue};
}
inline IntegerArrayPublisher IntegerArrayTopic::Publish(
const PubSubOptions& options) {
return IntegerArrayPublisher{
::nt::Publish(m_handle, NT_INTEGER_ARRAY, "int[]", options)};
}
inline IntegerArrayPublisher IntegerArrayTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return IntegerArrayPublisher{
::nt::PublishEx(m_handle, NT_INTEGER_ARRAY, typeString, properties, options)};
}
inline IntegerArrayEntry IntegerArrayTopic::GetEntry(
std::span<const int64_t> defaultValue,
const PubSubOptions& options) {
return IntegerArrayEntry{
::nt::GetEntry(m_handle, NT_INTEGER_ARRAY, "int[]", options),
defaultValue};
}
inline IntegerArrayEntry IntegerArrayTopic::GetEntryEx(
std::string_view typeString, std::span<const int64_t> defaultValue,
const PubSubOptions& options) {
return IntegerArrayEntry{
::nt::GetEntry(m_handle, NT_INTEGER_ARRAY, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,373 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class IntegerTopic;
/**
* NetworkTables Integer subscriber.
*/
class IntegerSubscriber : public Subscriber {
public:
using TopicType = IntegerTopic;
using ValueType = int64_t;
using ParamType = int64_t;
using TimestampedValueType = TimestampedInteger;
IntegerSubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* IntegerTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
IntegerSubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables Integer publisher.
*/
class IntegerPublisher : public Publisher {
public:
using TopicType = IntegerTopic;
using ValueType = int64_t;
using ParamType = int64_t;
using TimestampedValueType = TimestampedInteger;
IntegerPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* IntegerTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit IntegerPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables Integer entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class IntegerEntry final : public IntegerSubscriber,
public IntegerPublisher {
public:
using SubscriberType = IntegerSubscriber;
using PublisherType = IntegerPublisher;
using TopicType = IntegerTopic;
using ValueType = int64_t;
using ParamType = int64_t;
using TimestampedValueType = TimestampedInteger;
IntegerEntry() = default;
/**
* Construct from an entry handle; recommended to use
* IntegerTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
IntegerEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables Integer topic.
*/
class IntegerTopic final : public Topic {
public:
using SubscriberType = IntegerSubscriber;
using PublisherType = IntegerPublisher;
using EntryType = IntegerEntry;
using ValueType = int64_t;
using ParamType = int64_t;
using TimestampedValueType = TimestampedInteger;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "int";
IntegerTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetIntegerTopic() instead.
*
* @param handle Native handle
*/
explicit IntegerTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit IntegerTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/IntegerTopic.inc"

View File

@@ -0,0 +1,121 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/IntegerTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline IntegerSubscriber::IntegerSubscriber(
NT_Subscriber handle, int64_t defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue} {}
inline int64_t IntegerSubscriber::Get() const {
return Get(m_defaultValue);
}
inline int64_t IntegerSubscriber::Get(
int64_t defaultValue) const {
return ::nt::GetInteger(m_subHandle, defaultValue);
}
inline TimestampedInteger IntegerSubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedInteger IntegerSubscriber::GetAtomic(
int64_t defaultValue) const {
return ::nt::GetAtomicInteger(m_subHandle, defaultValue);
}
inline std::vector<TimestampedInteger>
IntegerSubscriber::ReadQueue() {
return ::nt::ReadQueueInteger(m_subHandle);
}
inline IntegerTopic IntegerSubscriber::GetTopic() const {
return IntegerTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline IntegerPublisher::IntegerPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void IntegerPublisher::Set(int64_t value,
int64_t time) {
::nt::SetInteger(m_pubHandle, value, time);
}
inline void IntegerPublisher::SetDefault(int64_t value) {
::nt::SetDefaultInteger(m_pubHandle, value);
}
inline IntegerTopic IntegerPublisher::GetTopic() const {
return IntegerTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline IntegerEntry::IntegerEntry(
NT_Entry handle, int64_t defaultValue)
: IntegerSubscriber{handle, defaultValue},
IntegerPublisher{handle} {}
inline IntegerTopic IntegerEntry::GetTopic() const {
return IntegerTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void IntegerEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline IntegerSubscriber IntegerTopic::Subscribe(
int64_t defaultValue,
const PubSubOptions& options) {
return IntegerSubscriber{
::nt::Subscribe(m_handle, NT_INTEGER, "int", options),
defaultValue};
}
inline IntegerSubscriber IntegerTopic::SubscribeEx(
std::string_view typeString, int64_t defaultValue,
const PubSubOptions& options) {
return IntegerSubscriber{
::nt::Subscribe(m_handle, NT_INTEGER, typeString, options),
defaultValue};
}
inline IntegerPublisher IntegerTopic::Publish(
const PubSubOptions& options) {
return IntegerPublisher{
::nt::Publish(m_handle, NT_INTEGER, "int", options)};
}
inline IntegerPublisher IntegerTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return IntegerPublisher{
::nt::PublishEx(m_handle, NT_INTEGER, typeString, properties, options)};
}
inline IntegerEntry IntegerTopic::GetEntry(
int64_t defaultValue,
const PubSubOptions& options) {
return IntegerEntry{
::nt::GetEntry(m_handle, NT_INTEGER, "int", options),
defaultValue};
}
inline IntegerEntry IntegerTopic::GetEntryEx(
std::string_view typeString, int64_t defaultValue,
const PubSubOptions& options) {
return IntegerEntry{
::nt::GetEntry(m_handle, NT_INTEGER, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,384 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <utility>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class RawTopic;
/**
* NetworkTables Raw subscriber.
*/
class RawSubscriber : public Subscriber {
public:
using TopicType = RawTopic;
using ValueType = std::vector<uint8_t>;
using ParamType = std::span<const uint8_t>;
using TimestampedValueType = TimestampedRaw;
using SmallRetType = std::span<uint8_t>;
using SmallElemType = uint8_t;
using TimestampedValueViewType = TimestampedRawView;
RawSubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* RawTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
RawSubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @param buf storage for returned value
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @param buf storage for returned value
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf,
ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables Raw publisher.
*/
class RawPublisher : public Publisher {
public:
using TopicType = RawTopic;
using ValueType = std::vector<uint8_t>;
using ParamType = std::span<const uint8_t>;
using SmallRetType = std::span<uint8_t>;
using SmallElemType = uint8_t;
using TimestampedValueType = TimestampedRaw;
RawPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* RawTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit RawPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables Raw entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class RawEntry final : public RawSubscriber,
public RawPublisher {
public:
using SubscriberType = RawSubscriber;
using PublisherType = RawPublisher;
using TopicType = RawTopic;
using ValueType = std::vector<uint8_t>;
using ParamType = std::span<const uint8_t>;
using SmallRetType = std::span<uint8_t>;
using SmallElemType = uint8_t;
using TimestampedValueType = TimestampedRaw;
RawEntry() = default;
/**
* Construct from an entry handle; recommended to use
* RawTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
RawEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables Raw topic.
*/
class RawTopic final : public Topic {
public:
using SubscriberType = RawSubscriber;
using PublisherType = RawPublisher;
using EntryType = RawEntry;
using ValueType = std::vector<uint8_t>;
using ParamType = std::span<const uint8_t>;
using TimestampedValueType = TimestampedRaw;
RawTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetRawTopic() instead.
*
* @param handle Native handle
*/
explicit RawTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit RawTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param typeString type string
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(std::string_view typeString, 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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/RawTopic.inc"

View File

@@ -0,0 +1,121 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/RawTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline RawSubscriber::RawSubscriber(
NT_Subscriber handle, std::span<const uint8_t> defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
inline std::vector<uint8_t> RawSubscriber::Get() const {
return Get(m_defaultValue);
}
inline std::vector<uint8_t> RawSubscriber::Get(
std::span<const uint8_t> defaultValue) const {
return ::nt::GetRaw(m_subHandle, defaultValue);
}
inline std::span<uint8_t> RawSubscriber::Get(wpi::SmallVectorImpl<uint8_t>& buf) const {
return Get(buf, m_defaultValue);
}
inline std::span<uint8_t> RawSubscriber::Get(wpi::SmallVectorImpl<uint8_t>& buf, std::span<const uint8_t> defaultValue) const {
return nt::GetRaw(m_subHandle, buf, defaultValue);
}
inline TimestampedRaw RawSubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedRaw RawSubscriber::GetAtomic(
std::span<const uint8_t> defaultValue) const {
return ::nt::GetAtomicRaw(m_subHandle, defaultValue);
}
inline TimestampedRawView RawSubscriber::GetAtomic(wpi::SmallVectorImpl<uint8_t>& buf) const {
return GetAtomic(buf, m_defaultValue);
}
inline TimestampedRawView RawSubscriber::GetAtomic(wpi::SmallVectorImpl<uint8_t>& buf, std::span<const uint8_t> defaultValue) const {
return nt::GetAtomicRaw(m_subHandle, buf, defaultValue);
}
inline std::vector<TimestampedRaw>
RawSubscriber::ReadQueue() {
return ::nt::ReadQueueRaw(m_subHandle);
}
inline RawTopic RawSubscriber::GetTopic() const {
return RawTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline RawPublisher::RawPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void RawPublisher::Set(std::span<const uint8_t> value,
int64_t time) {
::nt::SetRaw(m_pubHandle, value, time);
}
inline void RawPublisher::SetDefault(std::span<const uint8_t> value) {
::nt::SetDefaultRaw(m_pubHandle, value);
}
inline RawTopic RawPublisher::GetTopic() const {
return RawTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline RawEntry::RawEntry(
NT_Entry handle, std::span<const uint8_t> defaultValue)
: RawSubscriber{handle, defaultValue},
RawPublisher{handle} {}
inline RawTopic RawEntry::GetTopic() const {
return RawTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void RawEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline RawSubscriber RawTopic::Subscribe(
std::string_view typeString, std::span<const uint8_t> defaultValue,
const PubSubOptions& options) {
return RawSubscriber{
::nt::Subscribe(m_handle, NT_RAW, typeString, options),
defaultValue};
}
inline RawPublisher RawTopic::Publish(
std::string_view typeString, const PubSubOptions& options) {
return RawPublisher{
::nt::Publish(m_handle, NT_RAW, typeString, options)};
}
inline RawPublisher RawTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return RawPublisher{
::nt::PublishEx(m_handle, NT_RAW, typeString, properties, options)};
}
inline RawEntry RawTopic::GetEntry(
std::string_view typeString, std::span<const uint8_t> defaultValue,
const PubSubOptions& options) {
return RawEntry{
::nt::GetEntry(m_handle, NT_RAW, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,373 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <utility>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class StringArrayTopic;
/**
* NetworkTables StringArray subscriber.
*/
class StringArraySubscriber : public Subscriber {
public:
using TopicType = StringArrayTopic;
using ValueType = std::vector<std::string>;
using ParamType = std::span<const std::string>;
using TimestampedValueType = TimestampedStringArray;
StringArraySubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* StringArrayTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
StringArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables StringArray publisher.
*/
class StringArrayPublisher : public Publisher {
public:
using TopicType = StringArrayTopic;
using ValueType = std::vector<std::string>;
using ParamType = std::span<const std::string>;
using TimestampedValueType = TimestampedStringArray;
StringArrayPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* StringArrayTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit StringArrayPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables StringArray entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class StringArrayEntry final : public StringArraySubscriber,
public StringArrayPublisher {
public:
using SubscriberType = StringArraySubscriber;
using PublisherType = StringArrayPublisher;
using TopicType = StringArrayTopic;
using ValueType = std::vector<std::string>;
using ParamType = std::span<const std::string>;
using TimestampedValueType = TimestampedStringArray;
StringArrayEntry() = default;
/**
* Construct from an entry handle; recommended to use
* StringArrayTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
StringArrayEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables StringArray topic.
*/
class StringArrayTopic final : public Topic {
public:
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;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "string[]";
StringArrayTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetStringArrayTopic() instead.
*
* @param handle Native handle
*/
explicit StringArrayTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit StringArrayTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/StringArrayTopic.inc"

View File

@@ -0,0 +1,121 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/StringArrayTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline StringArraySubscriber::StringArraySubscriber(
NT_Subscriber handle, std::span<const std::string> defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
inline std::vector<std::string> StringArraySubscriber::Get() const {
return Get(m_defaultValue);
}
inline std::vector<std::string> StringArraySubscriber::Get(
std::span<const std::string> defaultValue) const {
return ::nt::GetStringArray(m_subHandle, defaultValue);
}
inline TimestampedStringArray StringArraySubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedStringArray StringArraySubscriber::GetAtomic(
std::span<const std::string> defaultValue) const {
return ::nt::GetAtomicStringArray(m_subHandle, defaultValue);
}
inline std::vector<TimestampedStringArray>
StringArraySubscriber::ReadQueue() {
return ::nt::ReadQueueStringArray(m_subHandle);
}
inline StringArrayTopic StringArraySubscriber::GetTopic() const {
return StringArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline StringArrayPublisher::StringArrayPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void StringArrayPublisher::Set(std::span<const std::string> value,
int64_t time) {
::nt::SetStringArray(m_pubHandle, value, time);
}
inline void StringArrayPublisher::SetDefault(std::span<const std::string> value) {
::nt::SetDefaultStringArray(m_pubHandle, value);
}
inline StringArrayTopic StringArrayPublisher::GetTopic() const {
return StringArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline StringArrayEntry::StringArrayEntry(
NT_Entry handle, std::span<const std::string> defaultValue)
: StringArraySubscriber{handle, defaultValue},
StringArrayPublisher{handle} {}
inline StringArrayTopic StringArrayEntry::GetTopic() const {
return StringArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void StringArrayEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline StringArraySubscriber StringArrayTopic::Subscribe(
std::span<const std::string> defaultValue,
const PubSubOptions& options) {
return StringArraySubscriber{
::nt::Subscribe(m_handle, NT_STRING_ARRAY, "string[]", options),
defaultValue};
}
inline StringArraySubscriber StringArrayTopic::SubscribeEx(
std::string_view typeString, std::span<const std::string> defaultValue,
const PubSubOptions& options) {
return StringArraySubscriber{
::nt::Subscribe(m_handle, NT_STRING_ARRAY, typeString, options),
defaultValue};
}
inline StringArrayPublisher StringArrayTopic::Publish(
const PubSubOptions& options) {
return StringArrayPublisher{
::nt::Publish(m_handle, NT_STRING_ARRAY, "string[]", options)};
}
inline StringArrayPublisher StringArrayTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return StringArrayPublisher{
::nt::PublishEx(m_handle, NT_STRING_ARRAY, typeString, properties, options)};
}
inline StringArrayEntry StringArrayTopic::GetEntry(
std::span<const std::string> defaultValue,
const PubSubOptions& options) {
return StringArrayEntry{
::nt::GetEntry(m_handle, NT_STRING_ARRAY, "string[]", options),
defaultValue};
}
inline StringArrayEntry StringArrayTopic::GetEntryEx(
std::string_view typeString, std::span<const std::string> defaultValue,
const PubSubOptions& options) {
return StringArrayEntry{
::nt::GetEntry(m_handle, NT_STRING_ARRAY, typeString, options),
defaultValue};
}
} // namespace nt

View File

@@ -0,0 +1,428 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <string>
#include <string_view>
#include <utility>
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class StringTopic;
/**
* NetworkTables String subscriber.
*/
class StringSubscriber : public Subscriber {
public:
using TopicType = StringTopic;
using ValueType = std::string;
using ParamType = std::string_view;
using TimestampedValueType = TimestampedString;
using SmallRetType = std::string_view;
using SmallElemType = char;
using TimestampedValueViewType = TimestampedStringView;
StringSubscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* StringTopic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
StringSubscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @param buf storage for returned value
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @param buf storage for returned value
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf,
ParamType defaultValue) const;
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables String publisher.
*/
class StringPublisher : public Publisher {
public:
using TopicType = StringTopic;
using ValueType = std::string;
using ParamType = std::string_view;
using SmallRetType = std::string_view;
using SmallElemType = char;
using TimestampedValueType = TimestampedString;
StringPublisher() = default;
/**
* Construct from a publisher handle; recommended to use
* StringTopic::Publish() instead.
*
* @param handle Native handle
*/
explicit StringPublisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables String entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class StringEntry final : public StringSubscriber,
public StringPublisher {
public:
using SubscriberType = StringSubscriber;
using PublisherType = StringPublisher;
using TopicType = StringTopic;
using ValueType = std::string;
using ParamType = std::string_view;
using SmallRetType = std::string_view;
using SmallElemType = char;
using TimestampedValueType = TimestampedString;
StringEntry() = default;
/**
* Construct from an entry handle; recommended to use
* StringTopic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
StringEntry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables String topic.
*/
class StringTopic final : public Topic {
public:
using SubscriberType = StringSubscriber;
using PublisherType = StringPublisher;
using EntryType = StringEntry;
using ValueType = std::string;
using ParamType = std::string_view;
using TimestampedValueType = TimestampedString;
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = "string";
StringTopic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::GetStringTopic() instead.
*
* @param handle Native handle
*/
explicit StringTopic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit StringTopic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
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.
*
* @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.
*
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish(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.
*
* @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.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry(ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
/**
* 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.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
};
} // namespace nt
#include "networktables/StringTopic.inc"

View File

@@ -0,0 +1,137 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <vector>
#include "networktables/StringTopic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline StringSubscriber::StringSubscriber(
NT_Subscriber handle, std::string_view defaultValue)
: Subscriber{handle},
m_defaultValue{defaultValue} {}
inline std::string StringSubscriber::Get() const {
return Get(m_defaultValue);
}
inline std::string StringSubscriber::Get(
std::string_view defaultValue) const {
return ::nt::GetString(m_subHandle, defaultValue);
}
inline std::string_view StringSubscriber::Get(wpi::SmallVectorImpl<char>& buf) const {
return Get(buf, m_defaultValue);
}
inline std::string_view StringSubscriber::Get(wpi::SmallVectorImpl<char>& buf, std::string_view defaultValue) const {
return nt::GetString(m_subHandle, buf, defaultValue);
}
inline TimestampedString StringSubscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline TimestampedString StringSubscriber::GetAtomic(
std::string_view defaultValue) const {
return ::nt::GetAtomicString(m_subHandle, defaultValue);
}
inline TimestampedStringView StringSubscriber::GetAtomic(wpi::SmallVectorImpl<char>& buf) const {
return GetAtomic(buf, m_defaultValue);
}
inline TimestampedStringView StringSubscriber::GetAtomic(wpi::SmallVectorImpl<char>& buf, std::string_view defaultValue) const {
return nt::GetAtomicString(m_subHandle, buf, defaultValue);
}
inline std::vector<TimestampedString>
StringSubscriber::ReadQueue() {
return ::nt::ReadQueueString(m_subHandle);
}
inline StringTopic StringSubscriber::GetTopic() const {
return StringTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline StringPublisher::StringPublisher(NT_Publisher handle)
: Publisher{handle} {}
inline void StringPublisher::Set(std::string_view value,
int64_t time) {
::nt::SetString(m_pubHandle, value, time);
}
inline void StringPublisher::SetDefault(std::string_view value) {
::nt::SetDefaultString(m_pubHandle, value);
}
inline StringTopic StringPublisher::GetTopic() const {
return StringTopic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline StringEntry::StringEntry(
NT_Entry handle, std::string_view defaultValue)
: StringSubscriber{handle, defaultValue},
StringPublisher{handle} {}
inline StringTopic StringEntry::GetTopic() const {
return StringTopic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void StringEntry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline StringSubscriber StringTopic::Subscribe(
std::string_view defaultValue,
const PubSubOptions& options) {
return StringSubscriber{
::nt::Subscribe(m_handle, NT_STRING, "string", options),
defaultValue};
}
inline StringSubscriber StringTopic::SubscribeEx(
std::string_view typeString, std::string_view defaultValue,
const PubSubOptions& options) {
return StringSubscriber{
::nt::Subscribe(m_handle, NT_STRING, typeString, options),
defaultValue};
}
inline StringPublisher StringTopic::Publish(
const PubSubOptions& options) {
return StringPublisher{
::nt::Publish(m_handle, NT_STRING, "string", options)};
}
inline StringPublisher StringTopic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return StringPublisher{
::nt::PublishEx(m_handle, NT_STRING, typeString, properties, options)};
}
inline StringEntry StringTopic::GetEntry(
std::string_view defaultValue,
const PubSubOptions& options) {
return StringEntry{
::nt::GetEntry(m_handle, NT_STRING, "string", options),
defaultValue};
}
inline StringEntry StringTopic::GetEntryEx(
std::string_view typeString, std::string_view defaultValue,
const PubSubOptions& options) {
return StringEntry{
::nt::GetEntry(m_handle, NT_STRING, typeString, options),
defaultValue};
}
} // namespace nt

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,998 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "ntcore_c.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
/**
* Timestamped value.
* @ingroup ntcore_cpp_handle_api
*/
template <typename T>
struct Timestamped {
Timestamped() = default;
Timestamped(int64_t time, int64_t serverTime, T value)
: time{time}, serverTime{serverTime}, value{std::move(value)} {}
/**
* Time in local time base.
*/
int64_t time = 0;
/**
* Time in server time base. May be 0 or 1 for locally set values.
*/
int64_t serverTime = 0;
/**
* Value.
*/
T value = {};
};
/**
* Timestamped Boolean.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedBoolean = Timestamped<bool>;
/**
* @defgroup ntcore_Boolean_func Boolean Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetBoolean(NT_Handle pubentry, bool value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultBoolean(NT_Handle pubentry, bool defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
bool GetBoolean(NT_Handle subentry, bool defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedBoolean GetAtomicBoolean(NT_Handle subentry, bool defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedBoolean> ReadQueueBoolean(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<int> ReadQueueValuesBoolean(NT_Handle subentry);
/** @} */
/**
* Timestamped Integer.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedInteger = Timestamped<int64_t>;
/**
* @defgroup ntcore_Integer_func Integer Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetInteger(NT_Handle pubentry, int64_t value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultInteger(NT_Handle pubentry, int64_t defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
int64_t GetInteger(NT_Handle subentry, int64_t defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedInteger GetAtomicInteger(NT_Handle subentry, int64_t defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedInteger> ReadQueueInteger(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<int64_t> ReadQueueValuesInteger(NT_Handle subentry);
/** @} */
/**
* Timestamped Float.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedFloat = Timestamped<float>;
/**
* @defgroup ntcore_Float_func Float Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetFloat(NT_Handle pubentry, float value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultFloat(NT_Handle pubentry, float defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
float GetFloat(NT_Handle subentry, float defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedFloat GetAtomicFloat(NT_Handle subentry, float defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedFloat> ReadQueueFloat(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<float> ReadQueueValuesFloat(NT_Handle subentry);
/** @} */
/**
* Timestamped Double.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedDouble = Timestamped<double>;
/**
* @defgroup ntcore_Double_func Double Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetDouble(NT_Handle pubentry, double value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultDouble(NT_Handle pubentry, double defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
double GetDouble(NT_Handle subentry, double defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedDouble GetAtomicDouble(NT_Handle subentry, double defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedDouble> ReadQueueDouble(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<double> ReadQueueValuesDouble(NT_Handle subentry);
/** @} */
/**
* Timestamped String.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedString = Timestamped<std::string>;
/**
* Timestamped String view (for SmallVector-taking functions).
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedStringView = Timestamped<std::string_view>;
/**
* @defgroup ntcore_String_func String Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetString(NT_Handle pubentry, std::string_view value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultString(NT_Handle pubentry, std::string_view defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
std::string GetString(NT_Handle subentry, std::string_view defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedString GetAtomicString(NT_Handle subentry, std::string_view defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedString> ReadQueueString(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<std::string> ReadQueueValuesString(NT_Handle subentry);
std::string_view GetString(NT_Handle subentry, wpi::SmallVectorImpl<char>& buf, std::string_view defaultValue);
TimestampedStringView GetAtomicString(
NT_Handle subentry,
wpi::SmallVectorImpl<char>& buf,
std::string_view defaultValue);
/** @} */
/**
* Timestamped Raw.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedRaw = Timestamped<std::vector<uint8_t>>;
/**
* Timestamped Raw view (for SmallVector-taking functions).
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedRawView = Timestamped<std::span<uint8_t>>;
/**
* @defgroup ntcore_Raw_func Raw Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetRaw(NT_Handle pubentry, std::span<const uint8_t> value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultRaw(NT_Handle pubentry, std::span<const uint8_t> defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
std::vector<uint8_t> GetRaw(NT_Handle subentry, std::span<const uint8_t> defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedRaw GetAtomicRaw(NT_Handle subentry, std::span<const uint8_t> defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedRaw> ReadQueueRaw(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<std::vector<uint8_t>> ReadQueueValuesRaw(NT_Handle subentry);
std::span<uint8_t> GetRaw(NT_Handle subentry, wpi::SmallVectorImpl<uint8_t>& buf, std::span<const uint8_t> defaultValue);
TimestampedRawView GetAtomicRaw(
NT_Handle subentry,
wpi::SmallVectorImpl<uint8_t>& buf,
std::span<const uint8_t> defaultValue);
/** @} */
/**
* Timestamped BooleanArray.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedBooleanArray = Timestamped<std::vector<int>>;
/**
* Timestamped BooleanArray view (for SmallVector-taking functions).
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedBooleanArrayView = Timestamped<std::span<int>>;
/**
* @defgroup ntcore_BooleanArray_func BooleanArray Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetBooleanArray(NT_Handle pubentry, std::span<const int> value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultBooleanArray(NT_Handle pubentry, std::span<const int> defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
std::vector<int> GetBooleanArray(NT_Handle subentry, std::span<const int> defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedBooleanArray GetAtomicBooleanArray(NT_Handle subentry, std::span<const int> defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedBooleanArray> ReadQueueBooleanArray(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<std::vector<int>> ReadQueueValuesBooleanArray(NT_Handle subentry);
std::span<int> GetBooleanArray(NT_Handle subentry, wpi::SmallVectorImpl<int>& buf, std::span<const int> defaultValue);
TimestampedBooleanArrayView GetAtomicBooleanArray(
NT_Handle subentry,
wpi::SmallVectorImpl<int>& buf,
std::span<const int> defaultValue);
/** @} */
/**
* Timestamped IntegerArray.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedIntegerArray = Timestamped<std::vector<int64_t>>;
/**
* Timestamped IntegerArray view (for SmallVector-taking functions).
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedIntegerArrayView = Timestamped<std::span<int64_t>>;
/**
* @defgroup ntcore_IntegerArray_func IntegerArray Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetIntegerArray(NT_Handle pubentry, std::span<const int64_t> value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultIntegerArray(NT_Handle pubentry, std::span<const int64_t> defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
std::vector<int64_t> GetIntegerArray(NT_Handle subentry, std::span<const int64_t> defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedIntegerArray GetAtomicIntegerArray(NT_Handle subentry, std::span<const int64_t> defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedIntegerArray> ReadQueueIntegerArray(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<std::vector<int64_t>> ReadQueueValuesIntegerArray(NT_Handle subentry);
std::span<int64_t> GetIntegerArray(NT_Handle subentry, wpi::SmallVectorImpl<int64_t>& buf, std::span<const int64_t> defaultValue);
TimestampedIntegerArrayView GetAtomicIntegerArray(
NT_Handle subentry,
wpi::SmallVectorImpl<int64_t>& buf,
std::span<const int64_t> defaultValue);
/** @} */
/**
* Timestamped FloatArray.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedFloatArray = Timestamped<std::vector<float>>;
/**
* Timestamped FloatArray view (for SmallVector-taking functions).
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedFloatArrayView = Timestamped<std::span<float>>;
/**
* @defgroup ntcore_FloatArray_func FloatArray Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetFloatArray(NT_Handle pubentry, std::span<const float> value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultFloatArray(NT_Handle pubentry, std::span<const float> defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
std::vector<float> GetFloatArray(NT_Handle subentry, std::span<const float> defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedFloatArray GetAtomicFloatArray(NT_Handle subentry, std::span<const float> defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedFloatArray> ReadQueueFloatArray(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<std::vector<float>> ReadQueueValuesFloatArray(NT_Handle subentry);
std::span<float> GetFloatArray(NT_Handle subentry, wpi::SmallVectorImpl<float>& buf, std::span<const float> defaultValue);
TimestampedFloatArrayView GetAtomicFloatArray(
NT_Handle subentry,
wpi::SmallVectorImpl<float>& buf,
std::span<const float> defaultValue);
/** @} */
/**
* Timestamped DoubleArray.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedDoubleArray = Timestamped<std::vector<double>>;
/**
* Timestamped DoubleArray view (for SmallVector-taking functions).
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedDoubleArrayView = Timestamped<std::span<double>>;
/**
* @defgroup ntcore_DoubleArray_func DoubleArray Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetDoubleArray(NT_Handle pubentry, std::span<const double> value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultDoubleArray(NT_Handle pubentry, std::span<const double> defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
std::vector<double> GetDoubleArray(NT_Handle subentry, std::span<const double> defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedDoubleArray GetAtomicDoubleArray(NT_Handle subentry, std::span<const double> defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedDoubleArray> ReadQueueDoubleArray(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<std::vector<double>> ReadQueueValuesDoubleArray(NT_Handle subentry);
std::span<double> GetDoubleArray(NT_Handle subentry, wpi::SmallVectorImpl<double>& buf, std::span<const double> defaultValue);
TimestampedDoubleArrayView GetAtomicDoubleArray(
NT_Handle subentry,
wpi::SmallVectorImpl<double>& buf,
std::span<const double> defaultValue);
/** @} */
/**
* Timestamped StringArray.
* @ingroup ntcore_cpp_handle_api
*/
using TimestampedStringArray = Timestamped<std::vector<std::string>>;
/**
* @defgroup ntcore_StringArray_func StringArray Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool SetStringArray(NT_Handle pubentry, std::span<const std::string> value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefaultStringArray(NT_Handle pubentry, std::span<const std::string> defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
std::vector<std::string> GetStringArray(NT_Handle subentry, std::span<const std::string> defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedStringArray GetAtomicStringArray(NT_Handle subentry, std::span<const std::string> defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedStringArray> ReadQueueStringArray(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<std::vector<std::string>> ReadQueueValuesStringArray(NT_Handle subentry);
/** @} */
} // namespace nt