[ntcore] Commit generated files (#5962)

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

View File

@@ -0,0 +1,440 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
{{ cpp.INCLUDES }}
#include <span>
#include <string_view>
#include <vector>
#include <wpi/json_fwd.h>
#include "networktables/Topic.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
class {{ TypeName }}Topic;
/**
* NetworkTables {{ TypeName }} subscriber.
*/
class {{ TypeName }}Subscriber : public Subscriber {
public:
using TopicType = {{ TypeName }}Topic;
using ValueType = {{ cpp.ValueType }};
using ParamType = {{ cpp.ParamType }};
using TimestampedValueType = Timestamped{{ TypeName }};
{% if cpp.SmallRetType and cpp.SmallElemType %}
using SmallRetType = {{ cpp.SmallRetType }};
using SmallElemType = {{ cpp.SmallElemType }};
using TimestampedValueViewType = Timestamped{{ TypeName }}View;
{% endif %}
{{ TypeName }}Subscriber() = default;
/**
* Construct from a subscriber handle; recommended to use
* {{TypeName}}Topic::Subscribe() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
{{ TypeName }}Subscriber(NT_Subscriber handle, ParamType defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
ValueType Get() const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param defaultValue default value to return if no value has been published
* @return value
*/
ValueType Get(ParamType defaultValue) const;
{% if cpp.SmallRetType and cpp.SmallElemType %}
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @param buf storage for returned value
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return value
*/
SmallRetType Get(wpi::SmallVectorImpl<SmallElemType>& buf, ParamType defaultValue) const;
{% endif %}
/**
* Get the last published value along with its timestamp
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @return timestamped value
*/
TimestampedValueType GetAtomic() const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueType GetAtomic(ParamType defaultValue) const;
{% if cpp.SmallRetType and cpp.SmallElemType %}
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the stored default value and a
* timestamp of 0.
*
* @param buf storage for returned value
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf) const;
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param buf storage for returned value
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
TimestampedValueViewType GetAtomic(
wpi::SmallVectorImpl<SmallElemType>& buf,
ParamType defaultValue) const;
{% endif %}
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<TimestampedValueType> ReadQueue();
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
private:
ValueType m_defaultValue;
};
/**
* NetworkTables {{ TypeName }} publisher.
*/
class {{ TypeName }}Publisher : public Publisher {
public:
using TopicType = {{ TypeName }}Topic;
using ValueType = {{ cpp.ValueType }};
using ParamType = {{ cpp.ParamType }};
{% if cpp.SmallRetType and cpp.SmallElemType %}
using SmallRetType = {{ cpp.SmallRetType }};
using SmallElemType = {{ cpp.SmallElemType }};
{% endif %}
using TimestampedValueType = Timestamped{{ TypeName }};
{{ TypeName }}Publisher() = default;
/**
* Construct from a publisher handle; recommended to use
* {{TypeName}}Topic::Publish() instead.
*
* @param handle Native handle
*/
explicit {{ TypeName }}Publisher(NT_Publisher handle);
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void Set(ParamType value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void SetDefault(ParamType value);
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
};
/**
* NetworkTables {{ TypeName }} entry.
*
* @note Unlike NetworkTableEntry, the entry goes away when this is destroyed.
*/
class {{ TypeName }}Entry final : public {{ TypeName }}Subscriber,
public {{ TypeName }}Publisher {
public:
using SubscriberType = {{ TypeName }}Subscriber;
using PublisherType = {{ TypeName }}Publisher;
using TopicType = {{ TypeName }}Topic;
using ValueType = {{ cpp.ValueType }};
using ParamType = {{ cpp.ParamType }};
{% if cpp.SmallRetType and cpp.SmallElemType %}
using SmallRetType = {{ cpp.SmallRetType }};
using SmallElemType = {{ cpp.SmallElemType }};
{% endif %}
using TimestampedValueType = Timestamped{{ TypeName }};
{{ TypeName }}Entry() = default;
/**
* Construct from an entry handle; recommended to use
* {{TypeName}}Topic::GetEntry() instead.
*
* @param handle Native handle
* @param defaultValue Default value
*/
{{ TypeName }}Entry(NT_Entry handle, ParamType defaultValue);
/**
* Determines if the native handle is valid.
*
* @return True if the native handle is valid, false otherwise.
*/
explicit operator bool() const { return m_subHandle != 0; }
/**
* Gets the native handle for the entry.
*
* @return Native handle
*/
NT_Entry GetHandle() const { return m_subHandle; }
/**
* Get the corresponding topic.
*
* @return Topic
*/
TopicType GetTopic() const;
/**
* Stops publishing the entry if it's published.
*/
void Unpublish();
};
/**
* NetworkTables {{ TypeName }} topic.
*/
class {{ TypeName }}Topic final : public Topic {
public:
using SubscriberType = {{ TypeName }}Subscriber;
using PublisherType = {{ TypeName }}Publisher;
using EntryType = {{ TypeName }}Entry;
using ValueType = {{ cpp.ValueType }};
using ParamType = {{ cpp.ParamType }};
using TimestampedValueType = Timestamped{{ TypeName }};
{%- if TypeString %}
/** The default type string for this topic type. */
static constexpr std::string_view kTypeString = {{ TypeString }};
{%- endif %}
{{ TypeName }}Topic() = default;
/**
* Construct from a topic handle; recommended to use
* NetworkTableInstance::Get{{TypeName}}Topic() instead.
*
* @param handle Native handle
*/
explicit {{ TypeName }}Topic(NT_Topic handle) : Topic{handle} {}
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
explicit {{ TypeName }}Topic(Topic topic) : Topic{topic} {}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not destroyed.
*
* @note Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
{%- if not TypeString %}
* @param typeString type string
{% endif %}
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType Subscribe(
{% if not TypeString %}std::string_view typeString, {% endif %}ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
{%- if TypeString %}
/**
* Create a new subscriber to the topic, with specific type string.
*
* <p>The subscriber is only active as long as the returned object
* is not destroyed.
*
* @note Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
[[nodiscard]]
SubscriberType SubscribeEx(
std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
{% endif %}
/**
* Create a new publisher to the topic.
*
* The publisher is only active as long as the returned object
* is not destroyed.
*
* @note It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the
* server on a first-come, first-served basis. Any published values that
* do not match the topic's data type are dropped (ignored). To determine
* if the data type matches, use the appropriate Topic functions.
*
{%- if not TypeString %}
* @param typeString type string
{% endif %}
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType Publish({% if not TypeString %}std::string_view typeString, {% endif %}const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new publisher to the topic, with type string and initial
* properties.
*
* The publisher is only active as long as the returned object
* is not destroyed.
*
* @note It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the
* server on a first-come, first-served basis. Any published values that
* do not match the topic's data type are dropped (ignored). To determine
* if the data type matches, use the appropriate Topic functions.
*
* @param typeString type string
* @param properties JSON properties
* @param options publish options
* @return publisher
*/
[[nodiscard]]
PublisherType PublishEx(std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options = kDefaultPubSubOptions);
/**
* Create a new entry for the topic.
*
* Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not destroyed. The publisher
* is created when the entry is first written to, and remains active until
* either Unpublish() is called or the entry is destroyed.
*
* @note It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the
* server on a first-come, first-served basis. Any published values that
* do not match the topic's data type are dropped (ignored), and the entry
* will show no new values if the data type does not match. To determine
* if the data type matches, use the appropriate Topic functions.
*
{%- if not TypeString %}
* @param typeString type string
{% endif %}
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntry({% if not TypeString %}std::string_view typeString, {% endif %}ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
{%- if TypeString %}
/**
* Create a new entry for the topic, with specific type string.
*
* Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not destroyed. The publisher
* is created when the entry is first written to, and remains active until
* either Unpublish() is called or the entry is destroyed.
*
* @note It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the
* server on a first-come, first-served basis. Any published values that
* do not match the topic's data type are dropped (ignored), and the entry
* will show no new values if the data type does not match. To determine
* if the data type matches, use the appropriate Topic functions.
*
* @param typeString type string
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
[[nodiscard]]
EntryType GetEntryEx(std::string_view typeString, ParamType defaultValue,
const PubSubOptions& options = kDefaultPubSubOptions);
{% endif %}
};
} // namespace nt
#include "networktables/{{ TypeName }}Topic.inc"

View File

@@ -0,0 +1,140 @@
// 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/{{ TypeName }}Topic.h"
#include "networktables/NetworkTableType.h"
#include "ntcore_cpp.h"
namespace nt {
inline {{ TypeName }}Subscriber::{{ TypeName }}Subscriber(
NT_Subscriber handle, {{ cpp.ParamType }} defaultValue)
: Subscriber{handle},
m_defaultValue{{ '{' }}{{ cpp.DefaultValueCopy|default('defaultValue') }}} {}
inline {{ cpp.ValueType }} {{ TypeName }}Subscriber::Get() const {
return Get(m_defaultValue);
}
inline {{ cpp.ValueType }} {{ TypeName }}Subscriber::Get(
{{ cpp.ParamType }} defaultValue) const {
return ::nt::Get{{ TypeName }}(m_subHandle, defaultValue);
}
{% if cpp.SmallRetType and cpp.SmallElemType %}
inline {{ cpp.SmallRetType }} {{ TypeName }}Subscriber::Get(wpi::SmallVectorImpl<{{ cpp.SmallElemType }}>& buf) const {
return Get(buf, m_defaultValue);
}
inline {{ cpp.SmallRetType }} {{ TypeName }}Subscriber::Get(wpi::SmallVectorImpl<{{ cpp.SmallElemType }}>& buf, {{ cpp.ParamType }} defaultValue) const {
return nt::Get{{ TypeName }}(m_subHandle, buf, defaultValue);
}
{% endif %}
inline Timestamped{{ TypeName }} {{ TypeName }}Subscriber::GetAtomic() const {
return GetAtomic(m_defaultValue);
}
inline Timestamped{{ TypeName }} {{ TypeName }}Subscriber::GetAtomic(
{{ cpp.ParamType }} defaultValue) const {
return ::nt::GetAtomic{{ TypeName }}(m_subHandle, defaultValue);
}
{% if cpp.SmallRetType and cpp.SmallElemType %}
inline Timestamped{{ TypeName }}View {{ TypeName }}Subscriber::GetAtomic(wpi::SmallVectorImpl<{{ cpp.SmallElemType }}>& buf) const {
return GetAtomic(buf, m_defaultValue);
}
inline Timestamped{{ TypeName }}View {{ TypeName }}Subscriber::GetAtomic(wpi::SmallVectorImpl<{{ cpp.SmallElemType }}>& buf, {{ cpp.ParamType }} defaultValue) const {
return nt::GetAtomic{{ TypeName }}(m_subHandle, buf, defaultValue);
}
{% endif %}
inline std::vector<Timestamped{{ TypeName }}>
{{ TypeName }}Subscriber::ReadQueue() {
return ::nt::ReadQueue{{ TypeName }}(m_subHandle);
}
inline {{ TypeName }}Topic {{ TypeName }}Subscriber::GetTopic() const {
return {{ TypeName }}Topic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline {{ TypeName }}Publisher::{{ TypeName }}Publisher(NT_Publisher handle)
: Publisher{handle} {}
inline void {{ TypeName }}Publisher::Set({{ cpp.ParamType }} value,
int64_t time) {
::nt::Set{{ TypeName }}(m_pubHandle, value, time);
}
inline void {{ TypeName }}Publisher::SetDefault({{ cpp.ParamType }} value) {
::nt::SetDefault{{ TypeName }}(m_pubHandle, value);
}
inline {{ TypeName }}Topic {{ TypeName }}Publisher::GetTopic() const {
return {{ TypeName }}Topic{::nt::GetTopicFromHandle(m_pubHandle)};
}
inline {{ TypeName }}Entry::{{ TypeName }}Entry(
NT_Entry handle, {{ cpp.ParamType }} defaultValue)
: {{ TypeName }}Subscriber{handle, defaultValue},
{{ TypeName }}Publisher{handle} {}
inline {{ TypeName }}Topic {{ TypeName }}Entry::GetTopic() const {
return {{ TypeName }}Topic{::nt::GetTopicFromHandle(m_subHandle)};
}
inline void {{ TypeName }}Entry::Unpublish() {
::nt::Unpublish(m_pubHandle);
}
inline {{ TypeName }}Subscriber {{ TypeName }}Topic::Subscribe(
{% if not TypeString %}std::string_view typeString, {% endif %}{{ cpp.ParamType }} defaultValue,
const PubSubOptions& options) {
return {{ TypeName }}Subscriber{
::nt::Subscribe(m_handle, NT_{{ cpp.TYPE_NAME }}, {{ TypeString|default('typeString') }}, options),
defaultValue};
}
{%- if TypeString %}
inline {{ TypeName }}Subscriber {{ TypeName }}Topic::SubscribeEx(
std::string_view typeString, {{ cpp.ParamType }} defaultValue,
const PubSubOptions& options) {
return {{ TypeName }}Subscriber{
::nt::Subscribe(m_handle, NT_{{ cpp.TYPE_NAME }}, typeString, options),
defaultValue};
}
{% endif %}
inline {{ TypeName }}Publisher {{ TypeName }}Topic::Publish(
{% if not TypeString %}std::string_view typeString, {% endif %}const PubSubOptions& options) {
return {{ TypeName }}Publisher{
::nt::Publish(m_handle, NT_{{ cpp.TYPE_NAME }}, {{ TypeString|default('typeString') }}, options)};
}
inline {{ TypeName }}Publisher {{ TypeName }}Topic::PublishEx(
std::string_view typeString,
const wpi::json& properties, const PubSubOptions& options) {
return {{ TypeName }}Publisher{
::nt::PublishEx(m_handle, NT_{{ cpp.TYPE_NAME }}, typeString, properties, options)};
}
inline {{ TypeName }}Entry {{ TypeName }}Topic::GetEntry(
{% if not TypeString %}std::string_view typeString, {% endif %}{{ cpp.ParamType }} defaultValue,
const PubSubOptions& options) {
return {{ TypeName }}Entry{
::nt::GetEntry(m_handle, NT_{{ cpp.TYPE_NAME }}, {{ TypeString|default('typeString') }}, options),
defaultValue};
}
{%- if TypeString %}
inline {{ TypeName }}Entry {{ TypeName }}Topic::GetEntryEx(
std::string_view typeString, {{ cpp.ParamType }} defaultValue,
const PubSubOptions& options) {
return {{ TypeName }}Entry{
::nt::GetEntry(m_handle, NT_{{ cpp.TYPE_NAME }}, typeString, options),
defaultValue};
}
{% endif %}
} // namespace nt

View File

@@ -0,0 +1,154 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include "ntcore_c.h"
#ifdef __cplusplus
extern "C" {
#endif
{% for t in types %}
/**
* Timestamped {{ t.TypeName }}.
* @ingroup ntcore_c_api
*/
struct NT_Timestamped{{ t.TypeName }} {
/**
* Time in local time base.
*/
int64_t time;
/**
* Time in server time base. May be 0 or 1 for locally set values.
*/
int64_t serverTime;
/**
* Value.
*/
{{ t.c.ValueType }} value;
{%- if t.c.IsArray %}
/**
* Value length.
*/
size_t len;
{% endif %}
};
/**
* @defgroup ntcore_{{ t.TypeName }}_cfunc {{ t.TypeName }} Functions
* @ingroup ntcore_c_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param time timestamp; 0 indicates current NT time should be used
* @param value value to publish
{%- if t.c.IsArray %}
* @param len length of value
{% endif %}
*/
NT_Bool NT_Set{{ t.TypeName }}(NT_Handle pubentry, int64_t time, {{ t.c.ParamType }} value{% if t.c.IsArray %}, size_t len{% endif %});
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
{%- if t.c.IsArray %}
* @param defaultValueLen length of default value
{% endif %}
*/
NT_Bool NT_SetDefault{{ t.TypeName }}(NT_Handle pubentry, {{ t.c.ParamType }} defaultValue{% if t.c.IsArray %}, size_t defaultValueLen{% endif %});
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
{%- if t.c.IsArray %}
* @param defaultValueLen length of default value
* @param len length of returned value (output)
{% endif %}
* @return value
*/
{{ t.c.ValueType }} NT_Get{{ t.TypeName }}(NT_Handle subentry, {{ t.c.ParamType }} defaultValue{% if t.c.IsArray %}, size_t defaultValueLen, size_t* len{% endif %});
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
{%- if t.c.IsArray %}
* @param defaultValueLen length of default value
{% endif %}
* @param value timestamped value (output)
*/
void NT_GetAtomic{{ t.TypeName }}(NT_Handle subentry, {{ t.c.ParamType }} defaultValue{% if t.c.IsArray %}, size_t defaultValueLen{% endif %}, struct NT_Timestamped{{ t.TypeName }}* value);
/**
* Disposes a timestamped value (as returned by NT_GetAtomic{{ t.TypeName }}).
*
* @param value timestamped value
*/
void NT_DisposeTimestamped{{ t.TypeName }}(struct NT_Timestamped{{ t.TypeName }}* value);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @param len length of returned array (output)
* @return Array of timestamped values; NULL if no new changes have
* been published since the previous call.
*/
struct NT_Timestamped{{ t.TypeName }}* NT_ReadQueue{{ t.TypeName }}(NT_Handle subentry, size_t* len);
/**
* Frees a timestamped array of values (as returned by NT_ReadQueue{{ t.TypeName }}).
*
* @param arr array
* @param len length of array
*/
void NT_FreeQueue{{ t.TypeName }}(struct NT_Timestamped{{ t.TypeName }}* arr, size_t len);
{%- if not t.c.IsArray %}
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @param len length of returned array (output)
* @return Array of values; NULL if no new changes have
* been published since the previous call.
*/
{{ t.c.ValueType }}* NT_ReadQueueValues{{ t.TypeName }}(NT_Handle subentry, size_t* len);
{%- endif %}
/** @} */
{% endfor %}
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -0,0 +1,144 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
#pragma once
#include <stdint.h>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "ntcore_c.h"
namespace wpi {
template <typename T>
class SmallVectorImpl;
} // namespace wpi
namespace nt {
/**
* Timestamped value.
* @ingroup ntcore_cpp_handle_api
*/
template <typename T>
struct Timestamped {
Timestamped() = default;
Timestamped(int64_t time, int64_t serverTime, T value)
: time{time}, serverTime{serverTime}, value{std::move(value)} {}
/**
* Time in local time base.
*/
int64_t time = 0;
/**
* Time in server time base. May be 0 or 1 for locally set values.
*/
int64_t serverTime = 0;
/**
* Value.
*/
T value = {};
};
{% for t in types %}
/**
* Timestamped {{ t.TypeName }}.
* @ingroup ntcore_cpp_handle_api
*/
using Timestamped{{ t.TypeName }} = Timestamped<{{ t.cpp.ValueType }}>;
{% if t.cpp.SmallRetType %}
/**
* Timestamped {{ t.TypeName }} view (for SmallVector-taking functions).
* @ingroup ntcore_cpp_handle_api
*/
using Timestamped{{ t.TypeName }}View = Timestamped<{{ t.cpp.SmallRetType }}>;
{% endif %}
/**
* @defgroup ntcore_{{ t.TypeName }}_func {{ t.TypeName }} Functions
* @ingroup ntcore_cpp_handle_api
* @{
*/
/**
* Publish a new value.
*
* @param pubentry publisher or entry handle
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
bool Set{{ t.TypeName }}(NT_Handle pubentry, {{ t.cpp.ParamType }} value, int64_t time = 0);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param pubentry publisher or entry handle
* @param defaultValue default value
*/
bool SetDefault{{ t.TypeName }}(NT_Handle pubentry, {{ t.cpp.ParamType }} defaultValue);
/**
* Get the last published value.
* If no value has been published, returns the passed defaultValue.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return value
*/
{{ t.cpp.ValueType }} Get{{ t.TypeName }}(NT_Handle subentry, {{ t.cpp.ParamType }} defaultValue);
/**
* Get the last published value along with its timestamp.
* If no value has been published, returns the passed defaultValue and a
* timestamp of 0.
*
* @param subentry subscriber or entry handle
* @param defaultValue default value to return if no value has been published
* @return timestamped value
*/
Timestamped{{ t.TypeName }} GetAtomic{{ t.TypeName}}(NT_Handle subentry, {{ t.cpp.ParamType }} defaultValue);
/**
* Get an array of all value changes since the last call to ReadQueue.
* Also provides a timestamp for each value.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of timestamped values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<Timestamped{{ t.TypeName }}> ReadQueue{{ t.TypeName }}(NT_Handle subentry);
/**
* Get an array of all value changes since the last call to ReadQueue.
*
* @note The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @param subentry subscriber or entry handle
* @return Array of values; empty array if no new changes have
* been published since the previous call.
*/
std::vector<{% if t.cpp.ValueType == "bool" %}int{% else %}{{ t.cpp.ValueType }}{% endif %}> ReadQueueValues{{ t.TypeName }}(NT_Handle subentry);
{% if t.cpp.SmallRetType and t.cpp.SmallElemType %}
{{ t.cpp.SmallRetType }} Get{{ t.TypeName }}(NT_Handle subentry, wpi::SmallVectorImpl<{{ t.cpp.SmallElemType }}>& buf, {{ t.cpp.ParamType }} defaultValue);
Timestamped{{ t.TypeName }}View GetAtomic{{ t.TypeName }}(
NT_Handle subentry,
wpi::SmallVectorImpl<{{ t.cpp.SmallElemType }}>& buf,
{{ t.cpp.ParamType }} defaultValue);
{% endif %}
/** @} */
{% endfor %}
} // namespace nt