mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[ntcore] Merge .inc files into headers (#7210)
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -50,7 +52,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
BooleanArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
BooleanArraySubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -58,7 +62,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -67,7 +73,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetBooleanArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -76,7 +84,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
* @param buf storage for returned value
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return Get(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -86,7 +96,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const {
|
||||
return nt::GetBooleanArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -95,7 +107,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -105,7 +119,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicBooleanArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -116,7 +132,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return GetAtomic(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -129,7 +147,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf,
|
||||
ParamType defaultValue) const;
|
||||
ParamType defaultValue) const {
|
||||
return nt::GetAtomicBooleanArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -141,7 +161,9 @@ class BooleanArraySubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueBooleanArray(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -176,7 +198,7 @@ class BooleanArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit BooleanArrayPublisher(NT_Publisher handle);
|
||||
explicit BooleanArrayPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -184,7 +206,9 @@ class BooleanArrayPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetBooleanArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -193,7 +217,9 @@ class BooleanArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultBooleanArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -231,7 +257,9 @@ class BooleanArrayEntry final : public BooleanArraySubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
BooleanArrayEntry(NT_Entry handle, ParamType defaultValue);
|
||||
BooleanArrayEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: BooleanArraySubscriber{handle, defaultValue},
|
||||
BooleanArrayPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -257,7 +285,9 @@ class BooleanArrayEntry final : public BooleanArraySubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -309,7 +339,11 @@ class BooleanArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_BOOLEAN_ARRAY, "boolean[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -329,7 +363,11 @@ class BooleanArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_BOOLEAN_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -347,7 +385,10 @@ class BooleanArrayTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanArrayPublisher{
|
||||
::nt::Publish(m_handle, NT_BOOLEAN_ARRAY, "boolean[]", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -369,7 +410,10 @@ class BooleanArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanArrayPublisher{
|
||||
::nt::PublishEx(m_handle, NT_BOOLEAN_ARRAY, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -393,7 +437,11 @@ class BooleanArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_BOOLEAN_ARRAY, "boolean[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -417,10 +465,24 @@ class BooleanArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_BOOLEAN_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline BooleanArrayTopic BooleanArraySubscriber::GetTopic() const {
|
||||
return BooleanArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/BooleanArrayTopic.inc"
|
||||
inline BooleanArrayTopic BooleanArrayPublisher::GetTopic() const {
|
||||
return BooleanArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline BooleanArrayTopic BooleanArrayEntry::GetTopic() const {
|
||||
return BooleanArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
// 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, ParamType 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(
|
||||
ParamType 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, ParamType defaultValue) const {
|
||||
return nt::GetBooleanArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedBooleanArray BooleanArraySubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedBooleanArray BooleanArraySubscriber::GetAtomic(
|
||||
ParamType 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, ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetBooleanArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void BooleanArrayPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultBooleanArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline BooleanArrayTopic BooleanArrayPublisher::GetTopic() const {
|
||||
return BooleanArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline BooleanArrayEntry::BooleanArrayEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -46,7 +48,9 @@ class BooleanSubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
BooleanSubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
BooleanSubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -54,7 +58,9 @@ class BooleanSubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -63,7 +69,9 @@ class BooleanSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetBoolean(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -72,7 +80,9 @@ class BooleanSubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -82,7 +92,9 @@ class BooleanSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicBoolean(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -94,7 +106,9 @@ class BooleanSubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueBoolean(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -126,7 +140,7 @@ class BooleanPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit BooleanPublisher(NT_Publisher handle);
|
||||
explicit BooleanPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -134,7 +148,9 @@ class BooleanPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetBoolean(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -143,7 +159,9 @@ class BooleanPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultBoolean(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -178,7 +196,9 @@ class BooleanEntry final : public BooleanSubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
BooleanEntry(NT_Entry handle, ParamType defaultValue);
|
||||
BooleanEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: BooleanSubscriber{handle, defaultValue},
|
||||
BooleanPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -204,7 +224,9 @@ class BooleanEntry final : public BooleanSubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,7 +278,11 @@ class BooleanTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_BOOLEAN, "boolean", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -276,7 +302,11 @@ class BooleanTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_BOOLEAN, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -294,7 +324,10 @@ class BooleanTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanPublisher{
|
||||
::nt::Publish(m_handle, NT_BOOLEAN, "boolean", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -316,7 +349,10 @@ class BooleanTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanPublisher{
|
||||
::nt::PublishEx(m_handle, NT_BOOLEAN, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -340,7 +376,11 @@ class BooleanTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanEntry{
|
||||
::nt::GetEntry(m_handle, NT_BOOLEAN, "boolean", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -364,10 +404,24 @@ class BooleanTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return BooleanEntry{
|
||||
::nt::GetEntry(m_handle, NT_BOOLEAN, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline BooleanTopic BooleanSubscriber::GetTopic() const {
|
||||
return BooleanTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/BooleanTopic.inc"
|
||||
inline BooleanTopic BooleanPublisher::GetTopic() const {
|
||||
return BooleanTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline BooleanTopic BooleanEntry::GetTopic() const {
|
||||
return BooleanTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// 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, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
inline bool BooleanSubscriber::Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
inline bool BooleanSubscriber::Get(
|
||||
ParamType defaultValue) const {
|
||||
return ::nt::GetBoolean(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedBoolean BooleanSubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedBoolean BooleanSubscriber::GetAtomic(
|
||||
ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetBoolean(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void BooleanPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultBoolean(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline BooleanTopic BooleanPublisher::GetTopic() const {
|
||||
return BooleanTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline BooleanEntry::BooleanEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -50,7 +52,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
DoubleArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
DoubleArraySubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -58,7 +62,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -67,7 +73,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetDoubleArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -76,7 +84,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
* @param buf storage for returned value
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return Get(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -86,7 +96,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const {
|
||||
return nt::GetDoubleArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -95,7 +107,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -105,7 +119,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicDoubleArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -116,7 +132,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return GetAtomic(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -129,7 +147,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf,
|
||||
ParamType defaultValue) const;
|
||||
ParamType defaultValue) const {
|
||||
return nt::GetAtomicDoubleArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -141,7 +161,9 @@ class DoubleArraySubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueDoubleArray(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -176,7 +198,7 @@ class DoubleArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit DoubleArrayPublisher(NT_Publisher handle);
|
||||
explicit DoubleArrayPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -184,7 +206,9 @@ class DoubleArrayPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetDoubleArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -193,7 +217,9 @@ class DoubleArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultDoubleArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -231,7 +257,9 @@ class DoubleArrayEntry final : public DoubleArraySubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
DoubleArrayEntry(NT_Entry handle, ParamType defaultValue);
|
||||
DoubleArrayEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: DoubleArraySubscriber{handle, defaultValue},
|
||||
DoubleArrayPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -257,7 +285,9 @@ class DoubleArrayEntry final : public DoubleArraySubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -309,7 +339,11 @@ class DoubleArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_DOUBLE_ARRAY, "double[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -329,7 +363,11 @@ class DoubleArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_DOUBLE_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -347,7 +385,10 @@ class DoubleArrayTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleArrayPublisher{
|
||||
::nt::Publish(m_handle, NT_DOUBLE_ARRAY, "double[]", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -369,7 +410,10 @@ class DoubleArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleArrayPublisher{
|
||||
::nt::PublishEx(m_handle, NT_DOUBLE_ARRAY, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -393,7 +437,11 @@ class DoubleArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_DOUBLE_ARRAY, "double[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -417,10 +465,24 @@ class DoubleArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_DOUBLE_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline DoubleArrayTopic DoubleArraySubscriber::GetTopic() const {
|
||||
return DoubleArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/DoubleArrayTopic.inc"
|
||||
inline DoubleArrayTopic DoubleArrayPublisher::GetTopic() const {
|
||||
return DoubleArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline DoubleArrayTopic DoubleArrayEntry::GetTopic() const {
|
||||
return DoubleArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
// 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, ParamType 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(
|
||||
ParamType 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, ParamType defaultValue) const {
|
||||
return nt::GetDoubleArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedDoubleArray DoubleArraySubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedDoubleArray DoubleArraySubscriber::GetAtomic(
|
||||
ParamType 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, ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetDoubleArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void DoubleArrayPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultDoubleArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline DoubleArrayTopic DoubleArrayPublisher::GetTopic() const {
|
||||
return DoubleArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline DoubleArrayEntry::DoubleArrayEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -46,7 +48,9 @@ class DoubleSubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
DoubleSubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
DoubleSubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -54,7 +58,9 @@ class DoubleSubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -63,7 +69,9 @@ class DoubleSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetDouble(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -72,7 +80,9 @@ class DoubleSubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -82,7 +92,9 @@ class DoubleSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicDouble(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -94,7 +106,9 @@ class DoubleSubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueDouble(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -126,7 +140,7 @@ class DoublePublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit DoublePublisher(NT_Publisher handle);
|
||||
explicit DoublePublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -134,7 +148,9 @@ class DoublePublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetDouble(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -143,7 +159,9 @@ class DoublePublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultDouble(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -178,7 +196,9 @@ class DoubleEntry final : public DoubleSubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
DoubleEntry(NT_Entry handle, ParamType defaultValue);
|
||||
DoubleEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: DoubleSubscriber{handle, defaultValue},
|
||||
DoublePublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -204,7 +224,9 @@ class DoubleEntry final : public DoubleSubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,7 +278,11 @@ class DoubleTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_DOUBLE, "double", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -276,7 +302,11 @@ class DoubleTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_DOUBLE, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -294,7 +324,10 @@ class DoubleTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoublePublisher{
|
||||
::nt::Publish(m_handle, NT_DOUBLE, "double", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -316,7 +349,10 @@ class DoubleTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoublePublisher{
|
||||
::nt::PublishEx(m_handle, NT_DOUBLE, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -340,7 +376,11 @@ class DoubleTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleEntry{
|
||||
::nt::GetEntry(m_handle, NT_DOUBLE, "double", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -364,10 +404,24 @@ class DoubleTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return DoubleEntry{
|
||||
::nt::GetEntry(m_handle, NT_DOUBLE, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline DoubleTopic DoubleSubscriber::GetTopic() const {
|
||||
return DoubleTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/DoubleTopic.inc"
|
||||
inline DoubleTopic DoublePublisher::GetTopic() const {
|
||||
return DoubleTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline DoubleTopic DoubleEntry::GetTopic() const {
|
||||
return DoubleTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// 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, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
inline double DoubleSubscriber::Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
inline double DoubleSubscriber::Get(
|
||||
ParamType defaultValue) const {
|
||||
return ::nt::GetDouble(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedDouble DoubleSubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedDouble DoubleSubscriber::GetAtomic(
|
||||
ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetDouble(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void DoublePublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultDouble(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline DoubleTopic DoublePublisher::GetTopic() const {
|
||||
return DoubleTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline DoubleEntry::DoubleEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -50,7 +52,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
FloatArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
FloatArraySubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -58,7 +62,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -67,7 +73,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetFloatArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -76,7 +84,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
* @param buf storage for returned value
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return Get(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -86,7 +96,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const {
|
||||
return nt::GetFloatArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -95,7 +107,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -105,7 +119,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicFloatArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -116,7 +132,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return GetAtomic(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -129,7 +147,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf,
|
||||
ParamType defaultValue) const;
|
||||
ParamType defaultValue) const {
|
||||
return nt::GetAtomicFloatArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -141,7 +161,9 @@ class FloatArraySubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueFloatArray(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -176,7 +198,7 @@ class FloatArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit FloatArrayPublisher(NT_Publisher handle);
|
||||
explicit FloatArrayPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -184,7 +206,9 @@ class FloatArrayPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetFloatArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -193,7 +217,9 @@ class FloatArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultFloatArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -231,7 +257,9 @@ class FloatArrayEntry final : public FloatArraySubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
FloatArrayEntry(NT_Entry handle, ParamType defaultValue);
|
||||
FloatArrayEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: FloatArraySubscriber{handle, defaultValue},
|
||||
FloatArrayPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -257,7 +285,9 @@ class FloatArrayEntry final : public FloatArraySubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -309,7 +339,11 @@ class FloatArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_FLOAT_ARRAY, "float[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -329,7 +363,11 @@ class FloatArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_FLOAT_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -347,7 +385,10 @@ class FloatArrayTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatArrayPublisher{
|
||||
::nt::Publish(m_handle, NT_FLOAT_ARRAY, "float[]", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -369,7 +410,10 @@ class FloatArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatArrayPublisher{
|
||||
::nt::PublishEx(m_handle, NT_FLOAT_ARRAY, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -393,7 +437,11 @@ class FloatArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_FLOAT_ARRAY, "float[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -417,10 +465,24 @@ class FloatArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_FLOAT_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline FloatArrayTopic FloatArraySubscriber::GetTopic() const {
|
||||
return FloatArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/FloatArrayTopic.inc"
|
||||
inline FloatArrayTopic FloatArrayPublisher::GetTopic() const {
|
||||
return FloatArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline FloatArrayTopic FloatArrayEntry::GetTopic() const {
|
||||
return FloatArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
// 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, ParamType 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(
|
||||
ParamType 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, ParamType defaultValue) const {
|
||||
return nt::GetFloatArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedFloatArray FloatArraySubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedFloatArray FloatArraySubscriber::GetAtomic(
|
||||
ParamType 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, ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetFloatArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void FloatArrayPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultFloatArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline FloatArrayTopic FloatArrayPublisher::GetTopic() const {
|
||||
return FloatArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline FloatArrayEntry::FloatArrayEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -46,7 +48,9 @@ class FloatSubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
FloatSubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
FloatSubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -54,7 +58,9 @@ class FloatSubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -63,7 +69,9 @@ class FloatSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetFloat(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -72,7 +80,9 @@ class FloatSubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -82,7 +92,9 @@ class FloatSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicFloat(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -94,7 +106,9 @@ class FloatSubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueFloat(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -126,7 +140,7 @@ class FloatPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit FloatPublisher(NT_Publisher handle);
|
||||
explicit FloatPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -134,7 +148,9 @@ class FloatPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetFloat(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -143,7 +159,9 @@ class FloatPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultFloat(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -178,7 +196,9 @@ class FloatEntry final : public FloatSubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
FloatEntry(NT_Entry handle, ParamType defaultValue);
|
||||
FloatEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: FloatSubscriber{handle, defaultValue},
|
||||
FloatPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -204,7 +224,9 @@ class FloatEntry final : public FloatSubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,7 +278,11 @@ class FloatTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_FLOAT, "float", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -276,7 +302,11 @@ class FloatTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_FLOAT, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -294,7 +324,10 @@ class FloatTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatPublisher{
|
||||
::nt::Publish(m_handle, NT_FLOAT, "float", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -316,7 +349,10 @@ class FloatTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatPublisher{
|
||||
::nt::PublishEx(m_handle, NT_FLOAT, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -340,7 +376,11 @@ class FloatTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatEntry{
|
||||
::nt::GetEntry(m_handle, NT_FLOAT, "float", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -364,10 +404,24 @@ class FloatTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return FloatEntry{
|
||||
::nt::GetEntry(m_handle, NT_FLOAT, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline FloatTopic FloatSubscriber::GetTopic() const {
|
||||
return FloatTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/FloatTopic.inc"
|
||||
inline FloatTopic FloatPublisher::GetTopic() const {
|
||||
return FloatTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline FloatTopic FloatEntry::GetTopic() const {
|
||||
return FloatTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// 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, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
inline float FloatSubscriber::Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
inline float FloatSubscriber::Get(
|
||||
ParamType defaultValue) const {
|
||||
return ::nt::GetFloat(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedFloat FloatSubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedFloat FloatSubscriber::GetAtomic(
|
||||
ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetFloat(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void FloatPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultFloat(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline FloatTopic FloatPublisher::GetTopic() const {
|
||||
return FloatTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline FloatEntry::FloatEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -50,7 +52,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
IntegerArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
IntegerArraySubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -58,7 +62,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -67,7 +73,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetIntegerArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -76,7 +84,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
* @param buf storage for returned value
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return Get(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -86,7 +96,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const {
|
||||
return nt::GetIntegerArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -95,7 +107,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -105,7 +119,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicIntegerArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -116,7 +132,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return GetAtomic(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -129,7 +147,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf,
|
||||
ParamType defaultValue) const;
|
||||
ParamType defaultValue) const {
|
||||
return nt::GetAtomicIntegerArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -141,7 +161,9 @@ class IntegerArraySubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueIntegerArray(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -176,7 +198,7 @@ class IntegerArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit IntegerArrayPublisher(NT_Publisher handle);
|
||||
explicit IntegerArrayPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -184,7 +206,9 @@ class IntegerArrayPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetIntegerArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -193,7 +217,9 @@ class IntegerArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultIntegerArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -231,7 +257,9 @@ class IntegerArrayEntry final : public IntegerArraySubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
IntegerArrayEntry(NT_Entry handle, ParamType defaultValue);
|
||||
IntegerArrayEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: IntegerArraySubscriber{handle, defaultValue},
|
||||
IntegerArrayPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -257,7 +285,9 @@ class IntegerArrayEntry final : public IntegerArraySubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -309,7 +339,11 @@ class IntegerArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_INTEGER_ARRAY, "int[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -329,7 +363,11 @@ class IntegerArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_INTEGER_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -347,7 +385,10 @@ class IntegerArrayTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerArrayPublisher{
|
||||
::nt::Publish(m_handle, NT_INTEGER_ARRAY, "int[]", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -369,7 +410,10 @@ class IntegerArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerArrayPublisher{
|
||||
::nt::PublishEx(m_handle, NT_INTEGER_ARRAY, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -393,7 +437,11 @@ class IntegerArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_INTEGER_ARRAY, "int[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -417,10 +465,24 @@ class IntegerArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_INTEGER_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline IntegerArrayTopic IntegerArraySubscriber::GetTopic() const {
|
||||
return IntegerArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/IntegerArrayTopic.inc"
|
||||
inline IntegerArrayTopic IntegerArrayPublisher::GetTopic() const {
|
||||
return IntegerArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline IntegerArrayTopic IntegerArrayEntry::GetTopic() const {
|
||||
return IntegerArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
// 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, ParamType 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(
|
||||
ParamType 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, ParamType defaultValue) const {
|
||||
return nt::GetIntegerArray(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedIntegerArray IntegerArraySubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedIntegerArray IntegerArraySubscriber::GetAtomic(
|
||||
ParamType 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, ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetIntegerArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void IntegerArrayPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultIntegerArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline IntegerArrayTopic IntegerArrayPublisher::GetTopic() const {
|
||||
return IntegerArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline IntegerArrayEntry::IntegerArrayEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -46,7 +48,9 @@ class IntegerSubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
IntegerSubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
IntegerSubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -54,7 +58,9 @@ class IntegerSubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -63,7 +69,9 @@ class IntegerSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetInteger(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -72,7 +80,9 @@ class IntegerSubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -82,7 +92,9 @@ class IntegerSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicInteger(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -94,7 +106,9 @@ class IntegerSubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueInteger(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -126,7 +140,7 @@ class IntegerPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit IntegerPublisher(NT_Publisher handle);
|
||||
explicit IntegerPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -134,7 +148,9 @@ class IntegerPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetInteger(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -143,7 +159,9 @@ class IntegerPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultInteger(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -178,7 +196,9 @@ class IntegerEntry final : public IntegerSubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
IntegerEntry(NT_Entry handle, ParamType defaultValue);
|
||||
IntegerEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: IntegerSubscriber{handle, defaultValue},
|
||||
IntegerPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -204,7 +224,9 @@ class IntegerEntry final : public IntegerSubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,7 +278,11 @@ class IntegerTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_INTEGER, "int", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -276,7 +302,11 @@ class IntegerTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_INTEGER, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -294,7 +324,10 @@ class IntegerTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerPublisher{
|
||||
::nt::Publish(m_handle, NT_INTEGER, "int", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -316,7 +349,10 @@ class IntegerTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerPublisher{
|
||||
::nt::PublishEx(m_handle, NT_INTEGER, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -340,7 +376,11 @@ class IntegerTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerEntry{
|
||||
::nt::GetEntry(m_handle, NT_INTEGER, "int", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -364,10 +404,24 @@ class IntegerTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return IntegerEntry{
|
||||
::nt::GetEntry(m_handle, NT_INTEGER, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline IntegerTopic IntegerSubscriber::GetTopic() const {
|
||||
return IntegerTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/IntegerTopic.inc"
|
||||
inline IntegerTopic IntegerPublisher::GetTopic() const {
|
||||
return IntegerTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline IntegerTopic IntegerEntry::GetTopic() const {
|
||||
return IntegerTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// 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, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
inline int64_t IntegerSubscriber::Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
inline int64_t IntegerSubscriber::Get(
|
||||
ParamType defaultValue) const {
|
||||
return ::nt::GetInteger(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedInteger IntegerSubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedInteger IntegerSubscriber::GetAtomic(
|
||||
ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetInteger(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void IntegerPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultInteger(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline IntegerTopic IntegerPublisher::GetTopic() const {
|
||||
return IntegerTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline IntegerEntry::IntegerEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -50,7 +52,9 @@ class RawSubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
RawSubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
RawSubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -58,7 +62,9 @@ class RawSubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -67,7 +73,9 @@ class RawSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetRaw(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -76,7 +84,9 @@ class RawSubscriber : public Subscriber {
|
||||
* @param buf storage for returned value
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return Get(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -86,7 +96,9 @@ class RawSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const {
|
||||
return nt::GetRaw(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -95,7 +107,9 @@ class RawSubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -105,7 +119,9 @@ class RawSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicRaw(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -116,7 +132,9 @@ class RawSubscriber : public Subscriber {
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return GetAtomic(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -129,7 +147,9 @@ class RawSubscriber : public Subscriber {
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf,
|
||||
ParamType defaultValue) const;
|
||||
ParamType defaultValue) const {
|
||||
return nt::GetAtomicRaw(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -141,7 +161,9 @@ class RawSubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueRaw(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -176,7 +198,7 @@ class RawPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit RawPublisher(NT_Publisher handle);
|
||||
explicit RawPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -184,7 +206,9 @@ class RawPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetRaw(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -193,7 +217,9 @@ class RawPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultRaw(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -231,7 +257,9 @@ class RawEntry final : public RawSubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
RawEntry(NT_Entry handle, ParamType defaultValue);
|
||||
RawEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: RawSubscriber{handle, defaultValue},
|
||||
RawPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -257,7 +285,9 @@ class RawEntry final : public RawSubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -309,7 +339,11 @@ class RawTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return RawSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_RAW, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
*
|
||||
@@ -328,7 +362,10 @@ class RawTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(std::string_view typeString, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(std::string_view typeString, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return RawPublisher{
|
||||
::nt::Publish(m_handle, NT_RAW, typeString, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -350,7 +387,10 @@ class RawTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return RawPublisher{
|
||||
::nt::PublishEx(m_handle, NT_RAW, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -376,9 +416,23 @@ class RawTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return RawEntry{
|
||||
::nt::GetEntry(m_handle, NT_RAW, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline RawTopic RawSubscriber::GetTopic() const {
|
||||
return RawTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/RawTopic.inc"
|
||||
inline RawTopic RawPublisher::GetTopic() const {
|
||||
return RawTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline RawTopic RawEntry::GetTopic() const {
|
||||
return RawTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// 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, ParamType 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(
|
||||
ParamType 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, ParamType defaultValue) const {
|
||||
return nt::GetRaw(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedRaw RawSubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedRaw RawSubscriber::GetAtomic(
|
||||
ParamType 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, ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetRaw(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void RawPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultRaw(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline RawTopic RawPublisher::GetTopic() const {
|
||||
return RawTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline RawEntry::RawEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -46,7 +48,9 @@ class StringArraySubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
StringArraySubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
StringArraySubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue.begin(), defaultValue.end()} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -54,7 +58,9 @@ class StringArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -63,7 +69,9 @@ class StringArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetStringArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -72,7 +80,9 @@ class StringArraySubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -82,7 +92,9 @@ class StringArraySubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicStringArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -94,7 +106,9 @@ class StringArraySubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueStringArray(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -126,7 +140,7 @@ class StringArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit StringArrayPublisher(NT_Publisher handle);
|
||||
explicit StringArrayPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -134,7 +148,9 @@ class StringArrayPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetStringArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -143,7 +159,9 @@ class StringArrayPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultStringArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -178,7 +196,9 @@ class StringArrayEntry final : public StringArraySubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
StringArrayEntry(NT_Entry handle, ParamType defaultValue);
|
||||
StringArrayEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: StringArraySubscriber{handle, defaultValue},
|
||||
StringArrayPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -204,7 +224,9 @@ class StringArrayEntry final : public StringArraySubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -256,7 +278,11 @@ class StringArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_STRING_ARRAY, "string[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -276,7 +302,11 @@ class StringArrayTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringArraySubscriber{
|
||||
::nt::Subscribe(m_handle, NT_STRING_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -294,7 +324,10 @@ class StringArrayTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringArrayPublisher{
|
||||
::nt::Publish(m_handle, NT_STRING_ARRAY, "string[]", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -316,7 +349,10 @@ class StringArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringArrayPublisher{
|
||||
::nt::PublishEx(m_handle, NT_STRING_ARRAY, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -340,7 +376,11 @@ class StringArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_STRING_ARRAY, "string[]", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -364,10 +404,24 @@ class StringArrayTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringArrayEntry{
|
||||
::nt::GetEntry(m_handle, NT_STRING_ARRAY, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline StringArrayTopic StringArraySubscriber::GetTopic() const {
|
||||
return StringArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/StringArrayTopic.inc"
|
||||
inline StringArrayTopic StringArrayPublisher::GetTopic() const {
|
||||
return StringArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline StringArrayTopic StringArrayEntry::GetTopic() const {
|
||||
return StringArrayTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
// 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, ParamType 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(
|
||||
ParamType defaultValue) const {
|
||||
return ::nt::GetStringArray(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedStringArray StringArraySubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedStringArray StringArraySubscriber::GetAtomic(
|
||||
ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetStringArray(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void StringArrayPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultStringArray(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline StringArrayTopic StringArrayPublisher::GetTopic() const {
|
||||
return StringArrayTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline StringArrayEntry::StringArrayEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
#include "networktables/NetworkTableType.h"
|
||||
#include "networktables/Topic.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
template <typename T>
|
||||
@@ -52,7 +54,9 @@ class StringSubscriber : public Subscriber {
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
StringSubscriber(NT_Subscriber handle, ParamType defaultValue);
|
||||
StringSubscriber(NT_Subscriber handle, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -60,7 +64,9 @@ class StringSubscriber : public Subscriber {
|
||||
*
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get() const;
|
||||
ValueType Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -69,7 +75,9 @@ class StringSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
ValueType Get(ParamType defaultValue) const;
|
||||
ValueType Get(ParamType defaultValue) const {
|
||||
return ::nt::GetString(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -78,7 +86,9 @@ class StringSubscriber : public Subscriber {
|
||||
* @param buf storage for returned value
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return Get(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value.
|
||||
@@ -88,7 +98,9 @@ class StringSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return value
|
||||
*/
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
|
||||
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const {
|
||||
return nt::GetString(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp
|
||||
@@ -97,7 +109,9 @@ class StringSubscriber : public Subscriber {
|
||||
*
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic() const;
|
||||
TimestampedValueType GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -107,7 +121,9 @@ class StringSubscriber : public Subscriber {
|
||||
* @param defaultValue default value to return if no value has been published
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const;
|
||||
TimestampedValueType GetAtomic(ParamType defaultValue) const {
|
||||
return ::nt::GetAtomicString(m_subHandle, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -118,7 +134,9 @@ class StringSubscriber : public Subscriber {
|
||||
* @return timestamped value
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const;
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf) const {
|
||||
return GetAtomic(buf, m_defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last published value along with its timestamp.
|
||||
@@ -131,7 +149,9 @@ class StringSubscriber : public Subscriber {
|
||||
*/
|
||||
TimestampedValueViewType GetAtomic(
|
||||
wpi::SmallVectorImpl<SmallElemType>& buf,
|
||||
ParamType defaultValue) const;
|
||||
ParamType defaultValue) const {
|
||||
return nt::GetAtomicString(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all value changes since the last call to ReadQueue.
|
||||
@@ -143,7 +163,9 @@ class StringSubscriber : public Subscriber {
|
||||
* @return Array of timestamped values; empty array if no new changes have
|
||||
* been published since the previous call.
|
||||
*/
|
||||
std::vector<TimestampedValueType> ReadQueue();
|
||||
std::vector<TimestampedValueType> ReadQueue() {
|
||||
return ::nt::ReadQueueString(m_subHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -178,7 +200,7 @@ class StringPublisher : public Publisher {
|
||||
*
|
||||
* @param handle Native handle
|
||||
*/
|
||||
explicit StringPublisher(NT_Publisher handle);
|
||||
explicit StringPublisher(NT_Publisher handle) : Publisher{handle} {}
|
||||
|
||||
/**
|
||||
* Publish a new value.
|
||||
@@ -186,7 +208,9 @@ class StringPublisher : public Publisher {
|
||||
* @param value value to publish
|
||||
* @param time timestamp; 0 indicates current NT time should be used
|
||||
*/
|
||||
void Set(ParamType value, int64_t time = 0);
|
||||
void Set(ParamType value, int64_t time = 0) {
|
||||
::nt::SetString(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a default value.
|
||||
@@ -195,7 +219,9 @@ class StringPublisher : public Publisher {
|
||||
*
|
||||
* @param value value
|
||||
*/
|
||||
void SetDefault(ParamType value);
|
||||
void SetDefault(ParamType value) {
|
||||
::nt::SetDefaultString(m_pubHandle, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corresponding topic.
|
||||
@@ -233,7 +259,9 @@ class StringEntry final : public StringSubscriber,
|
||||
* @param handle Native handle
|
||||
* @param defaultValue Default value
|
||||
*/
|
||||
StringEntry(NT_Entry handle, ParamType defaultValue);
|
||||
StringEntry(NT_Entry handle, ParamType defaultValue)
|
||||
: StringSubscriber{handle, defaultValue},
|
||||
StringPublisher{handle} {}
|
||||
|
||||
/**
|
||||
* Determines if the native handle is valid.
|
||||
@@ -259,7 +287,9 @@ class StringEntry final : public StringSubscriber,
|
||||
/**
|
||||
* Stops publishing the entry if it's published.
|
||||
*/
|
||||
void Unpublish();
|
||||
void Unpublish() {
|
||||
::nt::Unpublish(m_pubHandle);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -311,7 +341,11 @@ class StringTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType Subscribe(
|
||||
ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_STRING, "string", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new subscriber to the topic, with specific type string.
|
||||
*
|
||||
@@ -331,7 +365,11 @@ class StringTopic final : public Topic {
|
||||
[[nodiscard]]
|
||||
SubscriberType SubscribeEx(
|
||||
std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringSubscriber{
|
||||
::nt::Subscribe(m_handle, NT_STRING, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic.
|
||||
@@ -349,7 +387,10 @@ class StringTopic final : public Topic {
|
||||
* @return publisher
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
PublisherType Publish(const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringPublisher{
|
||||
::nt::Publish(m_handle, NT_STRING, "string", options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new publisher to the topic, with type string and initial
|
||||
@@ -371,7 +412,10 @@ class StringTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
PublisherType PublishEx(std::string_view typeString,
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringPublisher{
|
||||
::nt::PublishEx(m_handle, NT_STRING, typeString, properties, options)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry for the topic.
|
||||
@@ -395,7 +439,11 @@ class StringTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntry(ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringEntry{
|
||||
::nt::GetEntry(m_handle, NT_STRING, "string", options),
|
||||
defaultValue};
|
||||
}
|
||||
/**
|
||||
* Create a new entry for the topic, with specific type string.
|
||||
*
|
||||
@@ -419,10 +467,24 @@ class StringTopic final : public Topic {
|
||||
*/
|
||||
[[nodiscard]]
|
||||
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
|
||||
const PubSubOptions& options = kDefaultPubSubOptions);
|
||||
const PubSubOptions& options = kDefaultPubSubOptions) {
|
||||
return StringEntry{
|
||||
::nt::GetEntry(m_handle, NT_STRING, typeString, options),
|
||||
defaultValue};
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
inline StringTopic StringSubscriber::GetTopic() const {
|
||||
return StringTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
#include "networktables/StringTopic.inc"
|
||||
inline StringTopic StringPublisher::GetTopic() const {
|
||||
return StringTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline StringTopic StringEntry::GetTopic() const {
|
||||
return StringTopic{::nt::GetTopicFromHandle(m_subHandle)};
|
||||
}
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
// 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, ParamType defaultValue)
|
||||
: Subscriber{handle},
|
||||
m_defaultValue{defaultValue} {}
|
||||
|
||||
inline std::string StringSubscriber::Get() const {
|
||||
return Get(m_defaultValue);
|
||||
}
|
||||
|
||||
inline std::string StringSubscriber::Get(
|
||||
ParamType 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, ParamType defaultValue) const {
|
||||
return nt::GetString(m_subHandle, buf, defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedString StringSubscriber::GetAtomic() const {
|
||||
return GetAtomic(m_defaultValue);
|
||||
}
|
||||
|
||||
inline TimestampedString StringSubscriber::GetAtomic(
|
||||
ParamType 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, ParamType 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(ParamType value,
|
||||
int64_t time) {
|
||||
::nt::SetString(m_pubHandle, value, time);
|
||||
}
|
||||
|
||||
inline void StringPublisher::SetDefault(ParamType value) {
|
||||
::nt::SetDefaultString(m_pubHandle, value);
|
||||
}
|
||||
|
||||
inline StringTopic StringPublisher::GetTopic() const {
|
||||
return StringTopic{::nt::GetTopicFromHandle(m_pubHandle)};
|
||||
}
|
||||
|
||||
inline StringEntry::StringEntry(
|
||||
NT_Entry handle, ParamType 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
|
||||
Reference in New Issue
Block a user