[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,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables BooleanArray entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface BooleanArrayEntry extends BooleanArraySubscriber, BooleanArrayPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables BooleanArray implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class BooleanArrayEntryImpl extends EntryBase implements BooleanArrayEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
BooleanArrayEntryImpl(BooleanArrayTopic topic, int handle, boolean[] defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public BooleanArrayTopic getTopic() {
return m_topic;
}
@Override
public boolean[] get() {
return NetworkTablesJNI.getBooleanArray(m_handle, m_defaultValue);
}
@Override
public boolean[] get(boolean[] defaultValue) {
return NetworkTablesJNI.getBooleanArray(m_handle, defaultValue);
}
@Override
public TimestampedBooleanArray getAtomic() {
return NetworkTablesJNI.getAtomicBooleanArray(m_handle, m_defaultValue);
}
@Override
public TimestampedBooleanArray getAtomic(boolean[] defaultValue) {
return NetworkTablesJNI.getAtomicBooleanArray(m_handle, defaultValue);
}
@Override
public TimestampedBooleanArray[] readQueue() {
return NetworkTablesJNI.readQueueBooleanArray(m_handle);
}
@Override
public boolean[][] readQueueValues() {
return NetworkTablesJNI.readQueueValuesBooleanArray(m_handle);
}
@Override
public void set(boolean[] value, long time) {
NetworkTablesJNI.setBooleanArray(m_handle, time, value);
}
@Override
public void setDefault(boolean[] value) {
NetworkTablesJNI.setDefaultBooleanArray(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final BooleanArrayTopic m_topic;
private final boolean[] m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Consumer;
/** NetworkTables BooleanArray publisher. */
public interface BooleanArrayPublisher extends Publisher, Consumer<boolean[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
BooleanArrayTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(boolean[] value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(boolean[] value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(boolean[] value);
@Override
default void accept(boolean[] value) {
set(value);
}
}

View File

@@ -0,0 +1,80 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables BooleanArray subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface BooleanArraySubscriber extends Subscriber, Supplier<boolean[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
BooleanArrayTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
boolean[] get();
/**
* 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
*/
boolean[] get(boolean[] defaultValue);
/**
* 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
*/
TimestampedBooleanArray getAtomic();
/**
* 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
*/
TimestampedBooleanArray getAtomic(boolean[] defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedBooleanArray[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
boolean[][] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables BooleanArray topic. */
public final class BooleanArrayTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "boolean[]";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public BooleanArrayTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getBooleanArrayTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public BooleanArrayTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public BooleanArraySubscriber subscribe(
boolean[] defaultValue,
PubSubOption... options) {
return new BooleanArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kBooleanArray.getValue(),
"boolean[]", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public BooleanArraySubscriber subscribeEx(
String typeString,
boolean[] defaultValue,
PubSubOption... options) {
return new BooleanArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kBooleanArray.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public BooleanArrayPublisher publish(
PubSubOption... options) {
return new BooleanArrayEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kBooleanArray.getValue(),
"boolean[]", options),
new boolean[] {});
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public BooleanArrayPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new BooleanArrayEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kBooleanArray.getValue(),
typeString, properties, options),
new boolean[] {});
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public BooleanArrayEntry getEntry(
boolean[] defaultValue,
PubSubOption... options) {
return new BooleanArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kBooleanArray.getValue(),
"boolean[]", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public BooleanArrayEntry getEntryEx(
String typeString,
boolean[] defaultValue,
PubSubOption... options) {
return new BooleanArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kBooleanArray.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables Boolean entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface BooleanEntry extends BooleanSubscriber, BooleanPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Boolean implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class BooleanEntryImpl extends EntryBase implements BooleanEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
BooleanEntryImpl(BooleanTopic topic, int handle, boolean defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public BooleanTopic getTopic() {
return m_topic;
}
@Override
public boolean get() {
return NetworkTablesJNI.getBoolean(m_handle, m_defaultValue);
}
@Override
public boolean get(boolean defaultValue) {
return NetworkTablesJNI.getBoolean(m_handle, defaultValue);
}
@Override
public TimestampedBoolean getAtomic() {
return NetworkTablesJNI.getAtomicBoolean(m_handle, m_defaultValue);
}
@Override
public TimestampedBoolean getAtomic(boolean defaultValue) {
return NetworkTablesJNI.getAtomicBoolean(m_handle, defaultValue);
}
@Override
public TimestampedBoolean[] readQueue() {
return NetworkTablesJNI.readQueueBoolean(m_handle);
}
@Override
public boolean[] readQueueValues() {
return NetworkTablesJNI.readQueueValuesBoolean(m_handle);
}
@Override
public void set(boolean value, long time) {
NetworkTablesJNI.setBoolean(m_handle, time, value);
}
@Override
public void setDefault(boolean value) {
NetworkTablesJNI.setDefaultBoolean(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final BooleanTopic m_topic;
private final boolean m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import edu.wpi.first.util.function.BooleanConsumer;
/** NetworkTables Boolean publisher. */
public interface BooleanPublisher extends Publisher, BooleanConsumer {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
BooleanTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(boolean value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(boolean value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(boolean value);
@Override
default void accept(boolean value) {
set(value);
}
}

View File

@@ -0,0 +1,85 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.BooleanSupplier;
/** NetworkTables Boolean subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface BooleanSubscriber extends Subscriber, BooleanSupplier {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
BooleanTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
boolean get();
/**
* 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
*/
boolean get(boolean defaultValue);
@Override
default boolean getAsBoolean() {
return get();
}
/**
* 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
*/
TimestampedBoolean getAtomic();
/**
* 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
*/
TimestampedBoolean getAtomic(boolean defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedBoolean[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
boolean[] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Boolean topic. */
public final class BooleanTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "boolean";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public BooleanTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getBooleanTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public BooleanTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public BooleanSubscriber subscribe(
boolean defaultValue,
PubSubOption... options) {
return new BooleanEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kBoolean.getValue(),
"boolean", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public BooleanSubscriber subscribeEx(
String typeString,
boolean defaultValue,
PubSubOption... options) {
return new BooleanEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kBoolean.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public BooleanPublisher publish(
PubSubOption... options) {
return new BooleanEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kBoolean.getValue(),
"boolean", options),
false);
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public BooleanPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new BooleanEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kBoolean.getValue(),
typeString, properties, options),
false);
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public BooleanEntry getEntry(
boolean defaultValue,
PubSubOption... options) {
return new BooleanEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kBoolean.getValue(),
"boolean", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public BooleanEntry getEntryEx(
String typeString,
boolean defaultValue,
PubSubOption... options) {
return new BooleanEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kBoolean.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables DoubleArray entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface DoubleArrayEntry extends DoubleArraySubscriber, DoubleArrayPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables DoubleArray implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class DoubleArrayEntryImpl extends EntryBase implements DoubleArrayEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
DoubleArrayEntryImpl(DoubleArrayTopic topic, int handle, double[] defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public DoubleArrayTopic getTopic() {
return m_topic;
}
@Override
public double[] get() {
return NetworkTablesJNI.getDoubleArray(m_handle, m_defaultValue);
}
@Override
public double[] get(double[] defaultValue) {
return NetworkTablesJNI.getDoubleArray(m_handle, defaultValue);
}
@Override
public TimestampedDoubleArray getAtomic() {
return NetworkTablesJNI.getAtomicDoubleArray(m_handle, m_defaultValue);
}
@Override
public TimestampedDoubleArray getAtomic(double[] defaultValue) {
return NetworkTablesJNI.getAtomicDoubleArray(m_handle, defaultValue);
}
@Override
public TimestampedDoubleArray[] readQueue() {
return NetworkTablesJNI.readQueueDoubleArray(m_handle);
}
@Override
public double[][] readQueueValues() {
return NetworkTablesJNI.readQueueValuesDoubleArray(m_handle);
}
@Override
public void set(double[] value, long time) {
NetworkTablesJNI.setDoubleArray(m_handle, time, value);
}
@Override
public void setDefault(double[] value) {
NetworkTablesJNI.setDefaultDoubleArray(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final DoubleArrayTopic m_topic;
private final double[] m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Consumer;
/** NetworkTables DoubleArray publisher. */
public interface DoubleArrayPublisher extends Publisher, Consumer<double[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
DoubleArrayTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(double[] value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(double[] value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(double[] value);
@Override
default void accept(double[] value) {
set(value);
}
}

View File

@@ -0,0 +1,80 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables DoubleArray subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface DoubleArraySubscriber extends Subscriber, Supplier<double[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
DoubleArrayTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
double[] get();
/**
* 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
*/
double[] get(double[] defaultValue);
/**
* 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
*/
TimestampedDoubleArray getAtomic();
/**
* 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
*/
TimestampedDoubleArray getAtomic(double[] defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedDoubleArray[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
double[][] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables DoubleArray topic. */
public final class DoubleArrayTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "double[]";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public DoubleArrayTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getDoubleArrayTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public DoubleArrayTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public DoubleArraySubscriber subscribe(
double[] defaultValue,
PubSubOption... options) {
return new DoubleArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kDoubleArray.getValue(),
"double[]", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public DoubleArraySubscriber subscribeEx(
String typeString,
double[] defaultValue,
PubSubOption... options) {
return new DoubleArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kDoubleArray.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public DoubleArrayPublisher publish(
PubSubOption... options) {
return new DoubleArrayEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kDoubleArray.getValue(),
"double[]", options),
new double[] {});
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public DoubleArrayPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new DoubleArrayEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kDoubleArray.getValue(),
typeString, properties, options),
new double[] {});
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public DoubleArrayEntry getEntry(
double[] defaultValue,
PubSubOption... options) {
return new DoubleArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kDoubleArray.getValue(),
"double[]", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public DoubleArrayEntry getEntryEx(
String typeString,
double[] defaultValue,
PubSubOption... options) {
return new DoubleArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kDoubleArray.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables Double entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface DoubleEntry extends DoubleSubscriber, DoublePublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Double implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class DoubleEntryImpl extends EntryBase implements DoubleEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
DoubleEntryImpl(DoubleTopic topic, int handle, double defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public DoubleTopic getTopic() {
return m_topic;
}
@Override
public double get() {
return NetworkTablesJNI.getDouble(m_handle, m_defaultValue);
}
@Override
public double get(double defaultValue) {
return NetworkTablesJNI.getDouble(m_handle, defaultValue);
}
@Override
public TimestampedDouble getAtomic() {
return NetworkTablesJNI.getAtomicDouble(m_handle, m_defaultValue);
}
@Override
public TimestampedDouble getAtomic(double defaultValue) {
return NetworkTablesJNI.getAtomicDouble(m_handle, defaultValue);
}
@Override
public TimestampedDouble[] readQueue() {
return NetworkTablesJNI.readQueueDouble(m_handle);
}
@Override
public double[] readQueueValues() {
return NetworkTablesJNI.readQueueValuesDouble(m_handle);
}
@Override
public void set(double value, long time) {
NetworkTablesJNI.setDouble(m_handle, time, value);
}
@Override
public void setDefault(double value) {
NetworkTablesJNI.setDefaultDouble(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final DoubleTopic m_topic;
private final double m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.DoubleConsumer;
/** NetworkTables Double publisher. */
public interface DoublePublisher extends Publisher, DoubleConsumer {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
DoubleTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(double value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(double value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(double value);
@Override
default void accept(double value) {
set(value);
}
}

View File

@@ -0,0 +1,85 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.DoubleSupplier;
/** NetworkTables Double subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface DoubleSubscriber extends Subscriber, DoubleSupplier {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
DoubleTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
double get();
/**
* 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
*/
double get(double defaultValue);
@Override
default double getAsDouble() {
return get();
}
/**
* 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
*/
TimestampedDouble getAtomic();
/**
* 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
*/
TimestampedDouble getAtomic(double defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedDouble[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
double[] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Double topic. */
public final class DoubleTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "double";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public DoubleTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getDoubleTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public DoubleTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public DoubleSubscriber subscribe(
double defaultValue,
PubSubOption... options) {
return new DoubleEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kDouble.getValue(),
"double", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public DoubleSubscriber subscribeEx(
String typeString,
double defaultValue,
PubSubOption... options) {
return new DoubleEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kDouble.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public DoublePublisher publish(
PubSubOption... options) {
return new DoubleEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kDouble.getValue(),
"double", options),
0);
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public DoublePublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new DoubleEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kDouble.getValue(),
typeString, properties, options),
0);
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public DoubleEntry getEntry(
double defaultValue,
PubSubOption... options) {
return new DoubleEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kDouble.getValue(),
"double", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public DoubleEntry getEntryEx(
String typeString,
double defaultValue,
PubSubOption... options) {
return new DoubleEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kDouble.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables FloatArray entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface FloatArrayEntry extends FloatArraySubscriber, FloatArrayPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables FloatArray implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class FloatArrayEntryImpl extends EntryBase implements FloatArrayEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
FloatArrayEntryImpl(FloatArrayTopic topic, int handle, float[] defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public FloatArrayTopic getTopic() {
return m_topic;
}
@Override
public float[] get() {
return NetworkTablesJNI.getFloatArray(m_handle, m_defaultValue);
}
@Override
public float[] get(float[] defaultValue) {
return NetworkTablesJNI.getFloatArray(m_handle, defaultValue);
}
@Override
public TimestampedFloatArray getAtomic() {
return NetworkTablesJNI.getAtomicFloatArray(m_handle, m_defaultValue);
}
@Override
public TimestampedFloatArray getAtomic(float[] defaultValue) {
return NetworkTablesJNI.getAtomicFloatArray(m_handle, defaultValue);
}
@Override
public TimestampedFloatArray[] readQueue() {
return NetworkTablesJNI.readQueueFloatArray(m_handle);
}
@Override
public float[][] readQueueValues() {
return NetworkTablesJNI.readQueueValuesFloatArray(m_handle);
}
@Override
public void set(float[] value, long time) {
NetworkTablesJNI.setFloatArray(m_handle, time, value);
}
@Override
public void setDefault(float[] value) {
NetworkTablesJNI.setDefaultFloatArray(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final FloatArrayTopic m_topic;
private final float[] m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Consumer;
/** NetworkTables FloatArray publisher. */
public interface FloatArrayPublisher extends Publisher, Consumer<float[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
FloatArrayTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(float[] value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(float[] value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(float[] value);
@Override
default void accept(float[] value) {
set(value);
}
}

View File

@@ -0,0 +1,80 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables FloatArray subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface FloatArraySubscriber extends Subscriber, Supplier<float[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
FloatArrayTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
float[] get();
/**
* 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
*/
float[] get(float[] defaultValue);
/**
* 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
*/
TimestampedFloatArray getAtomic();
/**
* 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
*/
TimestampedFloatArray getAtomic(float[] defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedFloatArray[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
float[][] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables FloatArray topic. */
public final class FloatArrayTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "float[]";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public FloatArrayTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getFloatArrayTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public FloatArrayTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public FloatArraySubscriber subscribe(
float[] defaultValue,
PubSubOption... options) {
return new FloatArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kFloatArray.getValue(),
"float[]", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public FloatArraySubscriber subscribeEx(
String typeString,
float[] defaultValue,
PubSubOption... options) {
return new FloatArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kFloatArray.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public FloatArrayPublisher publish(
PubSubOption... options) {
return new FloatArrayEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kFloatArray.getValue(),
"float[]", options),
new float[] {});
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public FloatArrayPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new FloatArrayEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kFloatArray.getValue(),
typeString, properties, options),
new float[] {});
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public FloatArrayEntry getEntry(
float[] defaultValue,
PubSubOption... options) {
return new FloatArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kFloatArray.getValue(),
"float[]", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public FloatArrayEntry getEntryEx(
String typeString,
float[] defaultValue,
PubSubOption... options) {
return new FloatArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kFloatArray.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables Float entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface FloatEntry extends FloatSubscriber, FloatPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Float implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class FloatEntryImpl extends EntryBase implements FloatEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
FloatEntryImpl(FloatTopic topic, int handle, float defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public FloatTopic getTopic() {
return m_topic;
}
@Override
public float get() {
return NetworkTablesJNI.getFloat(m_handle, m_defaultValue);
}
@Override
public float get(float defaultValue) {
return NetworkTablesJNI.getFloat(m_handle, defaultValue);
}
@Override
public TimestampedFloat getAtomic() {
return NetworkTablesJNI.getAtomicFloat(m_handle, m_defaultValue);
}
@Override
public TimestampedFloat getAtomic(float defaultValue) {
return NetworkTablesJNI.getAtomicFloat(m_handle, defaultValue);
}
@Override
public TimestampedFloat[] readQueue() {
return NetworkTablesJNI.readQueueFloat(m_handle);
}
@Override
public float[] readQueueValues() {
return NetworkTablesJNI.readQueueValuesFloat(m_handle);
}
@Override
public void set(float value, long time) {
NetworkTablesJNI.setFloat(m_handle, time, value);
}
@Override
public void setDefault(float value) {
NetworkTablesJNI.setDefaultFloat(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final FloatTopic m_topic;
private final float m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import edu.wpi.first.util.function.FloatConsumer;
/** NetworkTables Float publisher. */
public interface FloatPublisher extends Publisher, FloatConsumer {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
FloatTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(float value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(float value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(float value);
@Override
default void accept(float value) {
set(value);
}
}

View File

@@ -0,0 +1,85 @@
// 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
package edu.wpi.first.networktables;
import edu.wpi.first.util.function.FloatSupplier;
/** NetworkTables Float subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface FloatSubscriber extends Subscriber, FloatSupplier {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
FloatTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
float get();
/**
* 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
*/
float get(float defaultValue);
@Override
default float getAsFloat() {
return get();
}
/**
* 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
*/
TimestampedFloat getAtomic();
/**
* 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
*/
TimestampedFloat getAtomic(float defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedFloat[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
float[] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Float topic. */
public final class FloatTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "float";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public FloatTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getFloatTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public FloatTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public FloatSubscriber subscribe(
float defaultValue,
PubSubOption... options) {
return new FloatEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kFloat.getValue(),
"float", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public FloatSubscriber subscribeEx(
String typeString,
float defaultValue,
PubSubOption... options) {
return new FloatEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kFloat.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public FloatPublisher publish(
PubSubOption... options) {
return new FloatEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kFloat.getValue(),
"float", options),
0);
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public FloatPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new FloatEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kFloat.getValue(),
typeString, properties, options),
0);
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public FloatEntry getEntry(
float defaultValue,
PubSubOption... options) {
return new FloatEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kFloat.getValue(),
"float", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public FloatEntry getEntryEx(
String typeString,
float defaultValue,
PubSubOption... options) {
return new FloatEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kFloat.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,815 @@
// 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
package edu.wpi.first.networktables;
import java.nio.ByteBuffer;
/** NetworkTables generic implementation. */
final class GenericEntryImpl extends EntryBase implements GenericEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
*/
GenericEntryImpl(Topic topic, int handle) {
super(handle);
m_topic = topic;
}
@Override
public Topic getTopic() {
return m_topic;
}
@Override
public NetworkTableValue get() {
return NetworkTablesJNI.getValue(m_handle);
}
/**
* Gets the entry's value as a boolean. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public boolean getBoolean(boolean defaultValue) {
return NetworkTablesJNI.getBoolean(m_handle, defaultValue);
}
/**
* Gets the entry's value as a long. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public long getInteger(long defaultValue) {
return NetworkTablesJNI.getInteger(m_handle, defaultValue);
}
/**
* Gets the entry's value as a float. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public float getFloat(float defaultValue) {
return NetworkTablesJNI.getFloat(m_handle, defaultValue);
}
/**
* Gets the entry's value as a double. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public double getDouble(double defaultValue) {
return NetworkTablesJNI.getDouble(m_handle, defaultValue);
}
/**
* Gets the entry's value as a String. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public String getString(String defaultValue) {
return NetworkTablesJNI.getString(m_handle, defaultValue);
}
/**
* Gets the entry's value as a byte[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public byte[] getRaw(byte[] defaultValue) {
return NetworkTablesJNI.getRaw(m_handle, defaultValue);
}
/**
* Gets the entry's value as a boolean[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public boolean[] getBooleanArray(boolean[] defaultValue) {
return NetworkTablesJNI.getBooleanArray(m_handle, defaultValue);
}
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public Boolean[] getBooleanArray(Boolean[] defaultValue) {
return NetworkTableValue.fromNativeBooleanArray(
getBooleanArray(NetworkTableValue.toNativeBooleanArray(defaultValue)));
}
/**
* Gets the entry's value as a long[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public long[] getIntegerArray(long[] defaultValue) {
return NetworkTablesJNI.getIntegerArray(m_handle, defaultValue);
}
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public Long[] getIntegerArray(Long[] defaultValue) {
return NetworkTableValue.fromNativeIntegerArray(
getIntegerArray(NetworkTableValue.toNativeIntegerArray(defaultValue)));
}
/**
* Gets the entry's value as a float[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public float[] getFloatArray(float[] defaultValue) {
return NetworkTablesJNI.getFloatArray(m_handle, defaultValue);
}
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public Float[] getFloatArray(Float[] defaultValue) {
return NetworkTableValue.fromNativeFloatArray(
getFloatArray(NetworkTableValue.toNativeFloatArray(defaultValue)));
}
/**
* Gets the entry's value as a double[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public double[] getDoubleArray(double[] defaultValue) {
return NetworkTablesJNI.getDoubleArray(m_handle, defaultValue);
}
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public Double[] getDoubleArray(Double[] defaultValue) {
return NetworkTableValue.fromNativeDoubleArray(
getDoubleArray(NetworkTableValue.toNativeDoubleArray(defaultValue)));
}
/**
* Gets the entry's value as a String[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
@Override
public String[] getStringArray(String[] defaultValue) {
return NetworkTablesJNI.getStringArray(m_handle, defaultValue);
}
@Override
public NetworkTableValue[] readQueue() {
return NetworkTablesJNI.readQueueValue(m_handle);
}
@Override
public boolean set(NetworkTableValue value) {
long time = value.getTime();
Object otherValue = value.getValue();
switch (value.getType()) {
case kBoolean:
return NetworkTablesJNI.setBoolean(m_handle, time, (Boolean) otherValue);
case kInteger:
return NetworkTablesJNI.setInteger(
m_handle, time, ((Number) otherValue).longValue());
case kFloat:
return NetworkTablesJNI.setFloat(
m_handle, time, ((Number) otherValue).floatValue());
case kDouble:
return NetworkTablesJNI.setDouble(
m_handle, time, ((Number) otherValue).doubleValue());
case kString:
return NetworkTablesJNI.setString(m_handle, time, (String) otherValue);
case kRaw:
return NetworkTablesJNI.setRaw(m_handle, time, (byte[]) otherValue);
case kBooleanArray:
return NetworkTablesJNI.setBooleanArray(m_handle, time, (boolean[]) otherValue);
case kIntegerArray:
return NetworkTablesJNI.setIntegerArray(m_handle, time, (long[]) otherValue);
case kFloatArray:
return NetworkTablesJNI.setFloatArray(m_handle, time, (float[]) otherValue);
case kDoubleArray:
return NetworkTablesJNI.setDoubleArray(m_handle, time, (double[]) otherValue);
case kStringArray:
return NetworkTablesJNI.setStringArray(m_handle, time, (String[]) otherValue);
default:
return true;
}
}
/**
* Sets the entry's value.
*
* @param value the value that will be assigned
* @return False if the table key already exists with a different type
* @throws IllegalArgumentException if the value is not a known type
*/
@Override
public boolean setValue(Object value, long time) {
if (value instanceof NetworkTableValue) {
return set((NetworkTableValue) value);
} else if (value instanceof Boolean) {
return setBoolean((Boolean) value, time);
} else if (value instanceof Long) {
return setInteger((Long) value, time);
} else if (value instanceof Float) {
return setFloat((Float) value, time);
} else if (value instanceof Number) {
return setNumber((Number) value, time);
} else if (value instanceof String) {
return setString((String) value, time);
} else if (value instanceof byte[]) {
return setRaw((byte[]) value, time);
} else if (value instanceof boolean[]) {
return setBooleanArray((boolean[]) value, time);
} else if (value instanceof long[]) {
return setIntegerArray((long[]) value, time);
} else if (value instanceof float[]) {
return setFloatArray((float[]) value, time);
} else if (value instanceof double[]) {
return setDoubleArray((double[]) value, time);
} else if (value instanceof Boolean[]) {
return setBooleanArray((Boolean[]) value, time);
} else if (value instanceof Long[]) {
return setIntegerArray((Long[]) value, time);
} else if (value instanceof Float[]) {
return setFloatArray((Float[]) value, time);
} else if (value instanceof Number[]) {
return setNumberArray((Number[]) value, time);
} else if (value instanceof String[]) {
return setStringArray((String[]) value, time);
} else {
throw new IllegalArgumentException(
"Value of type " + value.getClass().getName() + " cannot be put into a table");
}
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setBoolean(boolean value, long time) {
return NetworkTablesJNI.setBoolean(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setInteger(long value, long time) {
return NetworkTablesJNI.setInteger(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setFloat(float value, long time) {
return NetworkTablesJNI.setFloat(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDouble(double value, long time) {
return NetworkTablesJNI.setDouble(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setString(String value, long time) {
return NetworkTablesJNI.setString(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
* @return False if the entry exists with a different type
*/
@Override
public boolean setRaw(byte[] value, int start, int len, long time) {
return NetworkTablesJNI.setRaw(m_handle, time, value, start, len);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
* @return False if the entry exists with a different type
*/
@Override
public boolean setRaw(ByteBuffer value, int start, int len, long time) {
return NetworkTablesJNI.setRaw(m_handle, time, value, start, len);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setBooleanArray(boolean[] value, long time) {
return NetworkTablesJNI.setBooleanArray(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setBooleanArray(Boolean[] value, long time) {
return setBooleanArray(NetworkTableValue.toNativeBooleanArray(value), time);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setIntegerArray(long[] value, long time) {
return NetworkTablesJNI.setIntegerArray(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setIntegerArray(Long[] value, long time) {
return setIntegerArray(NetworkTableValue.toNativeIntegerArray(value), time);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setFloatArray(float[] value, long time) {
return NetworkTablesJNI.setFloatArray(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setFloatArray(Float[] value, long time) {
return setFloatArray(NetworkTableValue.toNativeFloatArray(value), time);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDoubleArray(double[] value, long time) {
return NetworkTablesJNI.setDoubleArray(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDoubleArray(Double[] value, long time) {
return setDoubleArray(NetworkTableValue.toNativeDoubleArray(value), time);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setStringArray(String[] value, long time) {
return NetworkTablesJNI.setStringArray(m_handle, time, value);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
public boolean setNumber(Number value, long time) {
return setDouble(value.doubleValue(), time);
}
/**
* Sets the entry's value.
*
* @param value the value to set
* @return False if the entry exists with a different type
*/
public boolean setNumberArray(Number[] value, long time) {
return setDoubleArray(NetworkTableValue.toNativeDoubleArray(value), time);
}
@Override
public boolean setDefault(NetworkTableValue defaultValue) {
long time = defaultValue.getTime();
Object otherValue = defaultValue.getValue();
switch (defaultValue.getType()) {
case kBoolean:
return NetworkTablesJNI.setDefaultBoolean(m_handle, time, (Boolean) otherValue);
case kInteger:
return NetworkTablesJNI.setDefaultInteger(
m_handle, time, ((Number) otherValue).longValue());
case kFloat:
return NetworkTablesJNI.setDefaultFloat(
m_handle, time, ((Number) otherValue).floatValue());
case kDouble:
return NetworkTablesJNI.setDefaultDouble(
m_handle, time, ((Number) otherValue).doubleValue());
case kString:
return NetworkTablesJNI.setDefaultString(m_handle, time, (String) otherValue);
case kRaw:
return NetworkTablesJNI.setDefaultRaw(m_handle, time, (byte[]) otherValue);
case kBooleanArray:
return NetworkTablesJNI.setDefaultBooleanArray(m_handle, time, (boolean[]) otherValue);
case kIntegerArray:
return NetworkTablesJNI.setDefaultIntegerArray(m_handle, time, (long[]) otherValue);
case kFloatArray:
return NetworkTablesJNI.setDefaultFloatArray(m_handle, time, (float[]) otherValue);
case kDoubleArray:
return NetworkTablesJNI.setDefaultDoubleArray(m_handle, time, (double[]) otherValue);
case kStringArray:
return NetworkTablesJNI.setDefaultStringArray(m_handle, time, (String[]) otherValue);
default:
return true;
}
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @throws IllegalArgumentException if the value is not a known type
*/
@Override
public boolean setDefaultValue(Object defaultValue) {
if (defaultValue instanceof NetworkTableValue) {
return setDefault((NetworkTableValue) defaultValue);
} else if (defaultValue instanceof Boolean) {
return setDefaultBoolean((Boolean) defaultValue);
} else if (defaultValue instanceof Integer) {
return setDefaultInteger((Integer) defaultValue);
} else if (defaultValue instanceof Float) {
return setDefaultFloat((Float) defaultValue);
} else if (defaultValue instanceof Number) {
return setDefaultNumber((Number) defaultValue);
} else if (defaultValue instanceof String) {
return setDefaultString((String) defaultValue);
} else if (defaultValue instanceof byte[]) {
return setDefaultRaw((byte[]) defaultValue);
} else if (defaultValue instanceof boolean[]) {
return setDefaultBooleanArray((boolean[]) defaultValue);
} else if (defaultValue instanceof long[]) {
return setDefaultIntegerArray((long[]) defaultValue);
} else if (defaultValue instanceof float[]) {
return setDefaultFloatArray((float[]) defaultValue);
} else if (defaultValue instanceof double[]) {
return setDefaultDoubleArray((double[]) defaultValue);
} else if (defaultValue instanceof Boolean[]) {
return setDefaultBooleanArray((Boolean[]) defaultValue);
} else if (defaultValue instanceof Long[]) {
return setDefaultIntegerArray((Long[]) defaultValue);
} else if (defaultValue instanceof Float[]) {
return setDefaultFloatArray((Float[]) defaultValue);
} else if (defaultValue instanceof Number[]) {
return setDefaultNumberArray((Number[]) defaultValue);
} else if (defaultValue instanceof String[]) {
return setDefaultStringArray((String[]) defaultValue);
} else {
throw new IllegalArgumentException(
"Value of type " + defaultValue.getClass().getName() + " cannot be put into a table");
}
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultBoolean(boolean defaultValue) {
return NetworkTablesJNI.setDefaultBoolean(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultInteger(long defaultValue) {
return NetworkTablesJNI.setDefaultInteger(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultFloat(float defaultValue) {
return NetworkTablesJNI.setDefaultFloat(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultDouble(double defaultValue) {
return NetworkTablesJNI.setDefaultDouble(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultString(String defaultValue) {
return NetworkTablesJNI.setDefaultString(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultRaw(byte[] defaultValue, int start, int len) {
return NetworkTablesJNI.setDefaultRaw(m_handle, 0, defaultValue, start, len);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultRaw(ByteBuffer defaultValue, int start, int len) {
return NetworkTablesJNI.setDefaultRaw(m_handle, 0, defaultValue, start, len);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultBooleanArray(boolean[] defaultValue) {
return NetworkTablesJNI.setDefaultBooleanArray(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultBooleanArray(Boolean[] defaultValue) {
return setDefaultBooleanArray(NetworkTableValue.toNativeBooleanArray(defaultValue));
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultIntegerArray(long[] defaultValue) {
return NetworkTablesJNI.setDefaultIntegerArray(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultIntegerArray(Long[] defaultValue) {
return setDefaultIntegerArray(NetworkTableValue.toNativeIntegerArray(defaultValue));
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultFloatArray(float[] defaultValue) {
return NetworkTablesJNI.setDefaultFloatArray(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultFloatArray(Float[] defaultValue) {
return setDefaultFloatArray(NetworkTableValue.toNativeFloatArray(defaultValue));
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultDoubleArray(double[] defaultValue) {
return NetworkTablesJNI.setDefaultDoubleArray(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultDoubleArray(Double[] defaultValue) {
return setDefaultDoubleArray(NetworkTableValue.toNativeDoubleArray(defaultValue));
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
@Override
public boolean setDefaultStringArray(String[] defaultValue) {
return NetworkTablesJNI.setDefaultStringArray(m_handle, 0, defaultValue);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
public boolean setDefaultNumber(Number defaultValue) {
return setDefaultDouble(defaultValue.doubleValue());
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
public boolean setDefaultNumberArray(Number[] defaultValue) {
return setDefaultDoubleArray(NetworkTableValue.toNativeDoubleArray(defaultValue));
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final Topic m_topic;
}

View File

@@ -0,0 +1,568 @@
// 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
package edu.wpi.first.networktables;
import java.nio.ByteBuffer;
import java.util.function.Consumer;
/** NetworkTables generic publisher. */
public interface GenericPublisher extends Publisher, Consumer<NetworkTableValue> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
Topic getTopic();
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
boolean set(NetworkTableValue value);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
* @throws IllegalArgumentException if the value is not a known type
*/
default boolean setValue(Object value) {
return setValue(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
* @throws IllegalArgumentException if the value is not a known type
*/
boolean setValue(Object value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setBoolean(boolean value) {
return setBoolean(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setBoolean(boolean value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setInteger(long value) {
return setInteger(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setInteger(long value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setFloat(float value) {
return setFloat(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setFloat(float value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setDouble(double value) {
return setDouble(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setDouble(double value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setString(String value) {
return setString(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setString(String value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setRaw(byte[] value) {
return setRaw(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setRaw(ByteBuffer value) {
return setRaw(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
default boolean setRaw(byte[] value, long time) {
return setRaw(value, 0, value.length, time);
}
/**
* Publish a new value.
*
* @param value value to publish; will send from value.position() to value.limit()
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
default boolean setRaw(ByteBuffer value, long time) {
int pos = value.position();
return setRaw(value, pos, value.limit() - pos, time);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
* @return False if the topic already exists with a different type
*/
default boolean setRaw(byte[] value, int start, int len) {
return setRaw(value, start, len, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setRaw(byte[] value, int start, int len, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
* @return False if the topic already exists with a different type
*/
default boolean setRaw(ByteBuffer value, int start, int len) {
return setRaw(value, start, len, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setRaw(ByteBuffer value, int start, int len, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setBooleanArray(boolean[] value) {
return setBooleanArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setBooleanArray(boolean[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setBooleanArray(Boolean[] value) {
return setBooleanArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setBooleanArray(Boolean[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setIntegerArray(long[] value) {
return setIntegerArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setIntegerArray(long[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setIntegerArray(Long[] value) {
return setIntegerArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setIntegerArray(Long[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setFloatArray(float[] value) {
return setFloatArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setFloatArray(float[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setFloatArray(Float[] value) {
return setFloatArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setFloatArray(Float[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setDoubleArray(double[] value) {
return setDoubleArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setDoubleArray(double[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setDoubleArray(Double[] value) {
return setDoubleArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setDoubleArray(Double[] value, long time);
/**
* Publish a new value.
*
* @param value value to publish
* @return False if the topic already exists with a different type
*/
default boolean setStringArray(String[] value) {
return setStringArray(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
* @return False if the topic already exists with a different type
*/
boolean setStringArray(String[] value, long time);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefault(NetworkTableValue defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @throws IllegalArgumentException if the value is not a known type
*/
boolean setDefaultValue(Object defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultBoolean(boolean defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultInteger(long defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultFloat(float defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultDouble(double defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultString(String defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
default boolean setDefaultRaw(byte[] defaultValue) {
return setDefaultRaw(defaultValue, 0, defaultValue.length);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set; will send from defaultValue.position() to
* defaultValue.limit()
* @return False if the entry exists with a different type
*/
default boolean setDefaultRaw(ByteBuffer defaultValue) {
int pos = defaultValue.position();
return setDefaultRaw(defaultValue, pos, defaultValue.limit() - pos);
}
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
* @return False if the entry exists with a different type
*/
boolean setDefaultRaw(byte[] defaultValue, int start, int len);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
* @return False if the entry exists with a different type
*/
boolean setDefaultRaw(ByteBuffer defaultValue, int start, int len);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultBooleanArray(boolean[] defaultValue);
boolean setDefaultBooleanArray(Boolean[] defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultIntegerArray(long[] defaultValue);
boolean setDefaultIntegerArray(Long[] defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultFloatArray(float[] defaultValue);
boolean setDefaultFloatArray(Float[] defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultDoubleArray(double[] defaultValue);
boolean setDefaultDoubleArray(Double[] defaultValue);
/**
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
*/
boolean setDefaultStringArray(String[] defaultValue);
@Override
default void accept(NetworkTableValue value) {
set(value);
}
}

View File

@@ -0,0 +1,176 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables generic subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface GenericSubscriber extends Subscriber, Supplier<NetworkTableValue> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
Topic getTopic();
/**
* Get the last published value.
* If no value has been published, returns a value with type NetworkTableType.kUnassigned.
*
* @return value
*/
NetworkTableValue get();
/**
* Gets the entry's value as a boolean. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
boolean getBoolean(boolean defaultValue);
/**
* Gets the entry's value as a long. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
long getInteger(long defaultValue);
/**
* Gets the entry's value as a float. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
float getFloat(float defaultValue);
/**
* Gets the entry's value as a double. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
double getDouble(double defaultValue);
/**
* Gets the entry's value as a String. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
String getString(String defaultValue);
/**
* Gets the entry's value as a byte[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
byte[] getRaw(byte[] defaultValue);
/**
* Gets the entry's value as a boolean[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
boolean[] getBooleanArray(boolean[] defaultValue);
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
Boolean[] getBooleanArray(Boolean[] defaultValue);
/**
* Gets the entry's value as a long[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
long[] getIntegerArray(long[] defaultValue);
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
Long[] getIntegerArray(Long[] defaultValue);
/**
* Gets the entry's value as a float[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
float[] getFloatArray(float[] defaultValue);
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
Float[] getFloatArray(Float[] defaultValue);
/**
* Gets the entry's value as a double[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
double[] getDoubleArray(double[] defaultValue);
/**
* Gets the entry's value as a boolean array. If the entry does not exist or is of different type,
* it will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
Double[] getDoubleArray(Double[] defaultValue);
/**
* Gets the entry's value as a String[]. If the entry does not exist or is of different type, it
* will return the default value.
*
* @param defaultValue the value to be returned if no value is found
* @return the entry's value or the given default value
*/
String[] getStringArray(String[] defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
NetworkTableValue[] readQueue();
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables IntegerArray entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface IntegerArrayEntry extends IntegerArraySubscriber, IntegerArrayPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables IntegerArray implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class IntegerArrayEntryImpl extends EntryBase implements IntegerArrayEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
IntegerArrayEntryImpl(IntegerArrayTopic topic, int handle, long[] defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public IntegerArrayTopic getTopic() {
return m_topic;
}
@Override
public long[] get() {
return NetworkTablesJNI.getIntegerArray(m_handle, m_defaultValue);
}
@Override
public long[] get(long[] defaultValue) {
return NetworkTablesJNI.getIntegerArray(m_handle, defaultValue);
}
@Override
public TimestampedIntegerArray getAtomic() {
return NetworkTablesJNI.getAtomicIntegerArray(m_handle, m_defaultValue);
}
@Override
public TimestampedIntegerArray getAtomic(long[] defaultValue) {
return NetworkTablesJNI.getAtomicIntegerArray(m_handle, defaultValue);
}
@Override
public TimestampedIntegerArray[] readQueue() {
return NetworkTablesJNI.readQueueIntegerArray(m_handle);
}
@Override
public long[][] readQueueValues() {
return NetworkTablesJNI.readQueueValuesIntegerArray(m_handle);
}
@Override
public void set(long[] value, long time) {
NetworkTablesJNI.setIntegerArray(m_handle, time, value);
}
@Override
public void setDefault(long[] value) {
NetworkTablesJNI.setDefaultIntegerArray(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final IntegerArrayTopic m_topic;
private final long[] m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Consumer;
/** NetworkTables IntegerArray publisher. */
public interface IntegerArrayPublisher extends Publisher, Consumer<long[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
IntegerArrayTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(long[] value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(long[] value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(long[] value);
@Override
default void accept(long[] value) {
set(value);
}
}

View File

@@ -0,0 +1,80 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables IntegerArray subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface IntegerArraySubscriber extends Subscriber, Supplier<long[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
IntegerArrayTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
long[] get();
/**
* 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
*/
long[] get(long[] defaultValue);
/**
* 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
*/
TimestampedIntegerArray getAtomic();
/**
* 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
*/
TimestampedIntegerArray getAtomic(long[] defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedIntegerArray[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
long[][] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables IntegerArray topic. */
public final class IntegerArrayTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "int[]";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public IntegerArrayTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getIntegerArrayTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public IntegerArrayTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public IntegerArraySubscriber subscribe(
long[] defaultValue,
PubSubOption... options) {
return new IntegerArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kIntegerArray.getValue(),
"int[]", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public IntegerArraySubscriber subscribeEx(
String typeString,
long[] defaultValue,
PubSubOption... options) {
return new IntegerArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kIntegerArray.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public IntegerArrayPublisher publish(
PubSubOption... options) {
return new IntegerArrayEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kIntegerArray.getValue(),
"int[]", options),
new long[] {});
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public IntegerArrayPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new IntegerArrayEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kIntegerArray.getValue(),
typeString, properties, options),
new long[] {});
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public IntegerArrayEntry getEntry(
long[] defaultValue,
PubSubOption... options) {
return new IntegerArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kIntegerArray.getValue(),
"int[]", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public IntegerArrayEntry getEntryEx(
String typeString,
long[] defaultValue,
PubSubOption... options) {
return new IntegerArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kIntegerArray.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables Integer entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface IntegerEntry extends IntegerSubscriber, IntegerPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Integer implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class IntegerEntryImpl extends EntryBase implements IntegerEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
IntegerEntryImpl(IntegerTopic topic, int handle, long defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public IntegerTopic getTopic() {
return m_topic;
}
@Override
public long get() {
return NetworkTablesJNI.getInteger(m_handle, m_defaultValue);
}
@Override
public long get(long defaultValue) {
return NetworkTablesJNI.getInteger(m_handle, defaultValue);
}
@Override
public TimestampedInteger getAtomic() {
return NetworkTablesJNI.getAtomicInteger(m_handle, m_defaultValue);
}
@Override
public TimestampedInteger getAtomic(long defaultValue) {
return NetworkTablesJNI.getAtomicInteger(m_handle, defaultValue);
}
@Override
public TimestampedInteger[] readQueue() {
return NetworkTablesJNI.readQueueInteger(m_handle);
}
@Override
public long[] readQueueValues() {
return NetworkTablesJNI.readQueueValuesInteger(m_handle);
}
@Override
public void set(long value, long time) {
NetworkTablesJNI.setInteger(m_handle, time, value);
}
@Override
public void setDefault(long value) {
NetworkTablesJNI.setDefaultInteger(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final IntegerTopic m_topic;
private final long m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.LongConsumer;
/** NetworkTables Integer publisher. */
public interface IntegerPublisher extends Publisher, LongConsumer {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
IntegerTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(long value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(long value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(long value);
@Override
default void accept(long value) {
set(value);
}
}

View File

@@ -0,0 +1,85 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.LongSupplier;
/** NetworkTables Integer subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface IntegerSubscriber extends Subscriber, LongSupplier {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
IntegerTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
long get();
/**
* 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
*/
long get(long defaultValue);
@Override
default long getAsLong() {
return get();
}
/**
* 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
*/
TimestampedInteger getAtomic();
/**
* 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
*/
TimestampedInteger getAtomic(long defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedInteger[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
long[] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables Integer topic. */
public final class IntegerTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "int";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public IntegerTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getIntegerTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public IntegerTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public IntegerSubscriber subscribe(
long defaultValue,
PubSubOption... options) {
return new IntegerEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kInteger.getValue(),
"int", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public IntegerSubscriber subscribeEx(
String typeString,
long defaultValue,
PubSubOption... options) {
return new IntegerEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kInteger.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public IntegerPublisher publish(
PubSubOption... options) {
return new IntegerEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kInteger.getValue(),
"int", options),
0);
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public IntegerPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new IntegerEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kInteger.getValue(),
typeString, properties, options),
0);
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public IntegerEntry getEntry(
long defaultValue,
PubSubOption... options) {
return new IntegerEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kInteger.getValue(),
"int", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public IntegerEntry getEntryEx(
String typeString,
long defaultValue,
PubSubOption... options) {
return new IntegerEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kInteger.getValue(),
typeString, options),
defaultValue);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,742 @@
// 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
package edu.wpi.first.networktables;
import java.util.Objects;
/** A network table entry value. */
@SuppressWarnings({"UnnecessaryParentheses", "PMD.MethodReturnsInternalArray"})
public final class NetworkTableValue {
NetworkTableValue(NetworkTableType type, Object value, long time, long serverTime) {
m_type = type;
m_value = value;
m_time = time;
m_serverTime = serverTime;
}
NetworkTableValue(NetworkTableType type, Object value, long time) {
this(type, value, time, time == 0 ? 0 : 1);
}
NetworkTableValue(NetworkTableType type, Object value) {
this(type, value, NetworkTablesJNI.now(), 1);
}
NetworkTableValue(int type, Object value, long time, long serverTime) {
this(NetworkTableType.getFromInt(type), value, time, serverTime);
}
/**
* Get the data type.
*
* @return The type.
*/
public NetworkTableType getType() {
return m_type;
}
/**
* Get the data value stored.
*
* @return The type.
*/
public Object getValue() {
return m_value;
}
/**
* Get the creation time of the value in local time.
*
* @return The time, in the units returned by NetworkTablesJNI.now().
*/
public long getTime() {
return m_time;
}
/**
* Get the creation time of the value in server time.
*
* @return The server time.
*/
public long getServerTime() {
return m_serverTime;
}
/*
* Type Checkers
*/
/**
* Determine if entry value contains a value or is unassigned.
*
* @return True if the entry value contains a value.
*/
public boolean isValid() {
return m_type != NetworkTableType.kUnassigned;
}
/**
* Determine if entry value contains a boolean.
*
* @return True if the entry value is of boolean type.
*/
public boolean isBoolean() {
return m_type == NetworkTableType.kBoolean;
}
/**
* Determine if entry value contains a long.
*
* @return True if the entry value is of long type.
*/
public boolean isInteger() {
return m_type == NetworkTableType.kInteger;
}
/**
* Determine if entry value contains a float.
*
* @return True if the entry value is of float type.
*/
public boolean isFloat() {
return m_type == NetworkTableType.kFloat;
}
/**
* Determine if entry value contains a double.
*
* @return True if the entry value is of double type.
*/
public boolean isDouble() {
return m_type == NetworkTableType.kDouble;
}
/**
* Determine if entry value contains a String.
*
* @return True if the entry value is of String type.
*/
public boolean isString() {
return m_type == NetworkTableType.kString;
}
/**
* Determine if entry value contains a byte[].
*
* @return True if the entry value is of byte[] type.
*/
public boolean isRaw() {
return m_type == NetworkTableType.kRaw;
}
/**
* Determine if entry value contains a boolean[].
*
* @return True if the entry value is of boolean[] type.
*/
public boolean isBooleanArray() {
return m_type == NetworkTableType.kBooleanArray;
}
/**
* Determine if entry value contains a long[].
*
* @return True if the entry value is of long[] type.
*/
public boolean isIntegerArray() {
return m_type == NetworkTableType.kIntegerArray;
}
/**
* Determine if entry value contains a float[].
*
* @return True if the entry value is of float[] type.
*/
public boolean isFloatArray() {
return m_type == NetworkTableType.kFloatArray;
}
/**
* Determine if entry value contains a double[].
*
* @return True if the entry value is of double[] type.
*/
public boolean isDoubleArray() {
return m_type == NetworkTableType.kDoubleArray;
}
/**
* Determine if entry value contains a String[].
*
* @return True if the entry value is of String[] type.
*/
public boolean isStringArray() {
return m_type == NetworkTableType.kStringArray;
}
/*
* Type-Safe Getters
*/
/**
* Get the boolean value.
*
* @return The boolean value.
* @throws ClassCastException if the entry value is not of boolean type.
*/
public boolean getBoolean() {
if (m_type != NetworkTableType.kBoolean) {
throw new ClassCastException("cannot convert " + m_type + " to boolean");
}
return (Boolean) m_value;
}
/**
* Get the long value.
*
* @return The long value.
* @throws ClassCastException if the entry value is not of long type.
*/
public long getInteger() {
if (m_type != NetworkTableType.kInteger) {
throw new ClassCastException("cannot convert " + m_type + " to long");
}
return ((Number) m_value).longValue();
}
/**
* Get the float value.
*
* @return The float value.
* @throws ClassCastException if the entry value is not of float type.
*/
public float getFloat() {
if (m_type != NetworkTableType.kFloat) {
throw new ClassCastException("cannot convert " + m_type + " to float");
}
return ((Number) m_value).floatValue();
}
/**
* Get the double value.
*
* @return The double value.
* @throws ClassCastException if the entry value is not of double type.
*/
public double getDouble() {
if (m_type != NetworkTableType.kDouble) {
throw new ClassCastException("cannot convert " + m_type + " to double");
}
return ((Number) m_value).doubleValue();
}
/**
* Get the String value.
*
* @return The String value.
* @throws ClassCastException if the entry value is not of String type.
*/
public String getString() {
if (m_type != NetworkTableType.kString) {
throw new ClassCastException("cannot convert " + m_type + " to String");
}
return (String) m_value;
}
/**
* Get the byte[] value.
*
* @return The byte[] value.
* @throws ClassCastException if the entry value is not of byte[] type.
*/
public byte[] getRaw() {
if (m_type != NetworkTableType.kRaw) {
throw new ClassCastException("cannot convert " + m_type + " to byte[]");
}
return (byte[]) m_value;
}
/**
* Get the boolean[] value.
*
* @return The boolean[] value.
* @throws ClassCastException if the entry value is not of boolean[] type.
*/
public boolean[] getBooleanArray() {
if (m_type != NetworkTableType.kBooleanArray) {
throw new ClassCastException("cannot convert " + m_type + " to boolean[]");
}
return (boolean[]) m_value;
}
/**
* Get the long[] value.
*
* @return The long[] value.
* @throws ClassCastException if the entry value is not of long[] type.
*/
public long[] getIntegerArray() {
if (m_type != NetworkTableType.kIntegerArray) {
throw new ClassCastException("cannot convert " + m_type + " to long[]");
}
return (long[]) m_value;
}
/**
* Get the float[] value.
*
* @return The float[] value.
* @throws ClassCastException if the entry value is not of float[] type.
*/
public float[] getFloatArray() {
if (m_type != NetworkTableType.kFloatArray) {
throw new ClassCastException("cannot convert " + m_type + " to float[]");
}
return (float[]) m_value;
}
/**
* Get the double[] value.
*
* @return The double[] value.
* @throws ClassCastException if the entry value is not of double[] type.
*/
public double[] getDoubleArray() {
if (m_type != NetworkTableType.kDoubleArray) {
throw new ClassCastException("cannot convert " + m_type + " to double[]");
}
return (double[]) m_value;
}
/**
* Get the String[] value.
*
* @return The String[] value.
* @throws ClassCastException if the entry value is not of String[] type.
*/
public String[] getStringArray() {
if (m_type != NetworkTableType.kStringArray) {
throw new ClassCastException("cannot convert " + m_type + " to String[]");
}
return (String[]) m_value;
}
/*
* Factory functions.
*/
/**
* Creates a boolean value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeBoolean(boolean value) {
return new NetworkTableValue(NetworkTableType.kBoolean, Boolean.valueOf(value));
}
/**
* Creates a boolean value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeBoolean(boolean value, long time) {
return new NetworkTableValue(NetworkTableType.kBoolean, Boolean.valueOf(value), time);
}
/**
* Creates a long value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeInteger(long value) {
return new NetworkTableValue(NetworkTableType.kInteger, Long.valueOf(value));
}
/**
* Creates a long value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeInteger(long value, long time) {
return new NetworkTableValue(NetworkTableType.kInteger, Long.valueOf(value), time);
}
/**
* Creates a float value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeFloat(float value) {
return new NetworkTableValue(NetworkTableType.kFloat, Float.valueOf(value));
}
/**
* Creates a float value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeFloat(float value, long time) {
return new NetworkTableValue(NetworkTableType.kFloat, Float.valueOf(value), time);
}
/**
* Creates a double value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeDouble(double value) {
return new NetworkTableValue(NetworkTableType.kDouble, Double.valueOf(value));
}
/**
* Creates a double value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeDouble(double value, long time) {
return new NetworkTableValue(NetworkTableType.kDouble, Double.valueOf(value), time);
}
/**
* Creates a String value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeString(String value) {
return new NetworkTableValue(NetworkTableType.kString, (value));
}
/**
* Creates a String value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeString(String value, long time) {
return new NetworkTableValue(NetworkTableType.kString, (value), time);
}
/**
* Creates a byte[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeRaw(byte[] value) {
return new NetworkTableValue(NetworkTableType.kRaw, (value));
}
/**
* Creates a byte[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeRaw(byte[] value, long time) {
return new NetworkTableValue(NetworkTableType.kRaw, (value), time);
}
/**
* Creates a boolean[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeBooleanArray(boolean[] value) {
return new NetworkTableValue(NetworkTableType.kBooleanArray, (value));
}
/**
* Creates a boolean[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeBooleanArray(boolean[] value, long time) {
return new NetworkTableValue(NetworkTableType.kBooleanArray, (value), time);
}
/**
* Creates a boolean[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeBooleanArray(Boolean[] value) {
return new NetworkTableValue(NetworkTableType.kBooleanArray, toNativeBooleanArray(value));
}
/**
* Creates a boolean[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeBooleanArray(Boolean[] value, long time) {
return new NetworkTableValue(NetworkTableType.kBooleanArray, toNativeBooleanArray(value), time);
}
/**
* Creates a long[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeIntegerArray(long[] value) {
return new NetworkTableValue(NetworkTableType.kIntegerArray, (value));
}
/**
* Creates a long[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeIntegerArray(long[] value, long time) {
return new NetworkTableValue(NetworkTableType.kIntegerArray, (value), time);
}
/**
* Creates a long[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeIntegerArray(Long[] value) {
return new NetworkTableValue(NetworkTableType.kIntegerArray, toNativeIntegerArray(value));
}
/**
* Creates a long[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeIntegerArray(Long[] value, long time) {
return new NetworkTableValue(NetworkTableType.kIntegerArray, toNativeIntegerArray(value), time);
}
/**
* Creates a float[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeFloatArray(float[] value) {
return new NetworkTableValue(NetworkTableType.kFloatArray, (value));
}
/**
* Creates a float[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeFloatArray(float[] value, long time) {
return new NetworkTableValue(NetworkTableType.kFloatArray, (value), time);
}
/**
* Creates a float[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeFloatArray(Float[] value) {
return new NetworkTableValue(NetworkTableType.kFloatArray, toNativeFloatArray(value));
}
/**
* Creates a float[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeFloatArray(Float[] value, long time) {
return new NetworkTableValue(NetworkTableType.kFloatArray, toNativeFloatArray(value), time);
}
/**
* Creates a double[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeDoubleArray(double[] value) {
return new NetworkTableValue(NetworkTableType.kDoubleArray, (value));
}
/**
* Creates a double[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeDoubleArray(double[] value, long time) {
return new NetworkTableValue(NetworkTableType.kDoubleArray, (value), time);
}
/**
* Creates a double[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeDoubleArray(Double[] value) {
return new NetworkTableValue(NetworkTableType.kDoubleArray, toNativeDoubleArray(value));
}
/**
* Creates a double[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeDoubleArray(Double[] value, long time) {
return new NetworkTableValue(NetworkTableType.kDoubleArray, toNativeDoubleArray(value), time);
}
/**
* Creates a String[] value.
*
* @param value the value
* @return The entry value
*/
public static NetworkTableValue makeStringArray(String[] value) {
return new NetworkTableValue(NetworkTableType.kStringArray, (value));
}
/**
* Creates a String[] value.
*
* @param value the value
* @param time the creation time to use (instead of the current time)
* @return The entry value
*/
public static NetworkTableValue makeStringArray(String[] value, long time) {
return new NetworkTableValue(NetworkTableType.kStringArray, (value), time);
}
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (!(other instanceof NetworkTableValue)) {
return false;
}
NetworkTableValue ntOther = (NetworkTableValue) other;
return m_type == ntOther.m_type && m_value.equals(ntOther.m_value);
}
@Override
public int hashCode() {
return Objects.hash(m_type, m_value);
}
// arraycopy() doesn't know how to unwrap boxed values; this is a false positive in PMD
// (see https://sourceforge.net/p/pmd/bugs/804/)
@SuppressWarnings("PMD.AvoidArrayLoops")
static boolean[] toNativeBooleanArray(Boolean[] arr) {
boolean[] out = new boolean[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i];
}
return out;
}
@SuppressWarnings("PMD.AvoidArrayLoops")
static double[] toNativeDoubleArray(Number[] arr) {
double[] out = new double[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i].doubleValue();
}
return out;
}
@SuppressWarnings("PMD.AvoidArrayLoops")
static long[] toNativeIntegerArray(Number[] arr) {
long[] out = new long[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i].longValue();
}
return out;
}
@SuppressWarnings("PMD.AvoidArrayLoops")
static float[] toNativeFloatArray(Number[] arr) {
float[] out = new float[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i].floatValue();
}
return out;
}
@SuppressWarnings("PMD.AvoidArrayLoops")
static Boolean[] fromNativeBooleanArray(boolean[] arr) {
Boolean[] out = new Boolean[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i];
}
return out;
}
@SuppressWarnings("PMD.AvoidArrayLoops")
static Long[] fromNativeIntegerArray(long[] arr) {
Long[] out = new Long[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i];
}
return out;
}
@SuppressWarnings("PMD.AvoidArrayLoops")
static Float[] fromNativeFloatArray(float[] arr) {
Float[] out = new Float[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i];
}
return out;
}
@SuppressWarnings("PMD.AvoidArrayLoops")
static Double[] fromNativeDoubleArray(double[] arr) {
Double[] out = new Double[arr.length];
for (int i = 0; i < arr.length; i++) {
out[i] = arr[i];
}
return out;
}
private NetworkTableType m_type;
private Object m_value;
private long m_time;
private long m_serverTime;
}

View File

@@ -0,0 +1,493 @@
// 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
package edu.wpi.first.networktables;
import edu.wpi.first.util.RuntimeLoader;
import edu.wpi.first.util.datalog.DataLog;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.EnumSet;
import java.util.OptionalLong;
import java.util.concurrent.atomic.AtomicBoolean;
public final class NetworkTablesJNI {
static boolean libraryLoaded = false;
static RuntimeLoader<NetworkTablesJNI> loader = null;
public static class Helper {
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
public static boolean getExtractOnStaticLoad() {
return extractOnStaticLoad.get();
}
public static void setExtractOnStaticLoad(boolean load) {
extractOnStaticLoad.set(load);
}
}
static {
if (Helper.getExtractOnStaticLoad()) {
try {
loader =
new RuntimeLoader<>(
"ntcorejni", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class);
loader.loadLibrary();
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
}
libraryLoaded = true;
}
}
/**
* Force load the library.
*
* @throws IOException if the library fails to load
*/
public static synchronized void forceLoad() throws IOException {
if (libraryLoaded) {
return;
}
loader =
new RuntimeLoader<>(
"ntcorejni", RuntimeLoader.getDefaultExtractionRoot(), NetworkTablesJNI.class);
loader.loadLibrary();
libraryLoaded = true;
}
private static PubSubOptions buildOptions(PubSubOption... options) {
if (options.length == 0) {
return null; // optimize common case (JNI checks for null)
}
return new PubSubOptions(options);
}
public static native int getDefaultInstance();
public static native int createInstance();
public static native void destroyInstance(int inst);
public static native int getInstanceFromHandle(int handle);
private static native int getEntryImpl(
int topic, int type, String typeStr, PubSubOptions options);
public static native int getEntry(int inst, String key);
public static int getEntry(
int topic, int type, String typeStr, PubSubOptions options) {
return getEntryImpl(topic, type, typeStr, options);
}
public static int getEntry(
int topic, int type, String typeStr, PubSubOption... options) {
return getEntryImpl(topic, type, typeStr, buildOptions(options));
}
public static native String getEntryName(int entry);
public static native long getEntryLastChange(int entry);
public static native int getType(int entry);
/* Topic functions */
public static native int[] getTopics(int inst, String prefix, int types);
public static native int[] getTopicsStr(int inst, String prefix, String[] types);
public static native TopicInfo[] getTopicInfos(
NetworkTableInstance instObject, int inst, String prefix, int types);
public static native TopicInfo[] getTopicInfosStr(
NetworkTableInstance instObject, int inst, String prefix, String[] types);
public static native int getTopic(int inst, String name);
public static native String getTopicName(int topic);
public static native int getTopicType(int topic);
public static native void setTopicPersistent(int topic, boolean value);
public static native boolean getTopicPersistent(int topic);
public static native void setTopicRetained(int topic, boolean value);
public static native boolean getTopicRetained(int topic);
public static native String getTopicTypeString(int topic);
public static native boolean getTopicExists(int topic);
public static native String getTopicProperty(int topic, String name);
public static native void setTopicProperty(int topic, String name, String value);
public static native void deleteTopicProperty(int topic, String name);
public static native String getTopicProperties(int topic);
public static native void setTopicProperties(int topic, String properties);
public static native int subscribe(
int topic, int type, String typeStr, PubSubOptions options);
public static int subscribe(
int topic, int type, String typeStr, PubSubOption... options) {
return subscribe(topic, type, typeStr, buildOptions(options));
}
public static native void unsubscribe(int sub);
public static native int publish(
int topic, int type, String typeStr, PubSubOptions options);
public static int publish(
int topic, int type, String typeStr, PubSubOption... options) {
return publish(topic, type, typeStr, buildOptions(options));
}
public static native int publishEx(
int topic, int type, String typeStr, String properties, PubSubOptions options);
public static int publishEx(
int topic, int type, String typeStr, String properties, PubSubOption... options) {
return publishEx(topic, type, typeStr, properties, buildOptions(options));
}
public static native void unpublish(int pubentry);
public static native void releaseEntry(int entry);
public static native void release(int pubsubentry);
public static native int getTopicFromHandle(int pubsubentry);
public static native int subscribeMultiple(int inst, String[] prefixes, PubSubOptions options);
public static int subscribeMultiple(int inst, String[] prefixes, PubSubOption... options) {
return subscribeMultiple(inst, prefixes, buildOptions(options));
}
public static native void unsubscribeMultiple(int sub);
public static native TimestampedBoolean getAtomicBoolean(
int subentry, boolean defaultValue);
public static native TimestampedBoolean[] readQueueBoolean(int subentry);
public static native boolean[] readQueueValuesBoolean(int subentry);
public static native boolean setBoolean(int entry, long time, boolean value);
public static native boolean getBoolean(int entry, boolean defaultValue);
public static native boolean setDefaultBoolean(int entry, long time, boolean defaultValue);
public static native TimestampedInteger getAtomicInteger(
int subentry, long defaultValue);
public static native TimestampedInteger[] readQueueInteger(int subentry);
public static native long[] readQueueValuesInteger(int subentry);
public static native boolean setInteger(int entry, long time, long value);
public static native long getInteger(int entry, long defaultValue);
public static native boolean setDefaultInteger(int entry, long time, long defaultValue);
public static native TimestampedFloat getAtomicFloat(
int subentry, float defaultValue);
public static native TimestampedFloat[] readQueueFloat(int subentry);
public static native float[] readQueueValuesFloat(int subentry);
public static native boolean setFloat(int entry, long time, float value);
public static native float getFloat(int entry, float defaultValue);
public static native boolean setDefaultFloat(int entry, long time, float defaultValue);
public static native TimestampedDouble getAtomicDouble(
int subentry, double defaultValue);
public static native TimestampedDouble[] readQueueDouble(int subentry);
public static native double[] readQueueValuesDouble(int subentry);
public static native boolean setDouble(int entry, long time, double value);
public static native double getDouble(int entry, double defaultValue);
public static native boolean setDefaultDouble(int entry, long time, double defaultValue);
public static native TimestampedString getAtomicString(
int subentry, String defaultValue);
public static native TimestampedString[] readQueueString(int subentry);
public static native String[] readQueueValuesString(int subentry);
public static native boolean setString(int entry, long time, String value);
public static native String getString(int entry, String defaultValue);
public static native boolean setDefaultString(int entry, long time, String defaultValue);
public static native TimestampedRaw getAtomicRaw(
int subentry, byte[] defaultValue);
public static native TimestampedRaw[] readQueueRaw(int subentry);
public static native byte[][] readQueueValuesRaw(int subentry);
public static boolean setRaw(int entry, long time, byte[] value) {
return setRaw(entry, time, value, 0, value.length);
}
public static native boolean setRaw(int entry, long time, byte[] value, int start, int len);
public static boolean setRaw(int entry, long time, ByteBuffer value) {
int pos = value.position();
return setRaw(entry, time, value, pos, value.capacity() - pos);
}
public static boolean setRaw(int entry, long time, ByteBuffer value, int start, int len) {
if (value.isDirect()) {
if (start < 0) {
throw new IndexOutOfBoundsException("start must be >= 0");
}
if (len < 0) {
throw new IndexOutOfBoundsException("len must be >= 0");
}
if ((start + len) > value.capacity()) {
throw new IndexOutOfBoundsException("start + len must be smaller than buffer capacity");
}
return setRawBuffer(entry, time, value, start, len);
} else if (value.hasArray()) {
return setRaw(entry, time, value.array(), value.arrayOffset() + start, len);
} else {
throw new UnsupportedOperationException("ByteBuffer must be direct or have a backing array");
}
}
private static native boolean setRawBuffer(int entry, long time, ByteBuffer value, int start, int len);
public static native byte[] getRaw(int entry, byte[] defaultValue);
public static boolean setDefaultRaw(int entry, long time, byte[] defaultValue) {
return setDefaultRaw(entry, time, defaultValue, 0, defaultValue.length);
}
public static native boolean setDefaultRaw(int entry, long time, byte[] defaultValue, int start, int len);
public static boolean setDefaultRaw(int entry, long time, ByteBuffer defaultValue) {
int pos = defaultValue.position();
return setDefaultRaw(entry, time, defaultValue, pos, defaultValue.limit() - pos);
}
public static boolean setDefaultRaw(int entry, long time, ByteBuffer defaultValue, int start, int len) {
if (defaultValue.isDirect()) {
if (start < 0) {
throw new IndexOutOfBoundsException("start must be >= 0");
}
if (len < 0) {
throw new IndexOutOfBoundsException("len must be >= 0");
}
if ((start + len) > defaultValue.capacity()) {
throw new IndexOutOfBoundsException("start + len must be smaller than buffer capacity");
}
return setDefaultRawBuffer(entry, time, defaultValue, start, len);
} else if (defaultValue.hasArray()) {
return setDefaultRaw(entry, time, defaultValue.array(), defaultValue.arrayOffset() + start, len);
} else {
throw new UnsupportedOperationException("ByteBuffer must be direct or have a backing array");
}
}
private static native boolean setDefaultRawBuffer(int entry, long time, ByteBuffer defaultValue, int start, int len);
public static native TimestampedBooleanArray getAtomicBooleanArray(
int subentry, boolean[] defaultValue);
public static native TimestampedBooleanArray[] readQueueBooleanArray(int subentry);
public static native boolean[][] readQueueValuesBooleanArray(int subentry);
public static native boolean setBooleanArray(int entry, long time, boolean[] value);
public static native boolean[] getBooleanArray(int entry, boolean[] defaultValue);
public static native boolean setDefaultBooleanArray(int entry, long time, boolean[] defaultValue);
public static native TimestampedIntegerArray getAtomicIntegerArray(
int subentry, long[] defaultValue);
public static native TimestampedIntegerArray[] readQueueIntegerArray(int subentry);
public static native long[][] readQueueValuesIntegerArray(int subentry);
public static native boolean setIntegerArray(int entry, long time, long[] value);
public static native long[] getIntegerArray(int entry, long[] defaultValue);
public static native boolean setDefaultIntegerArray(int entry, long time, long[] defaultValue);
public static native TimestampedFloatArray getAtomicFloatArray(
int subentry, float[] defaultValue);
public static native TimestampedFloatArray[] readQueueFloatArray(int subentry);
public static native float[][] readQueueValuesFloatArray(int subentry);
public static native boolean setFloatArray(int entry, long time, float[] value);
public static native float[] getFloatArray(int entry, float[] defaultValue);
public static native boolean setDefaultFloatArray(int entry, long time, float[] defaultValue);
public static native TimestampedDoubleArray getAtomicDoubleArray(
int subentry, double[] defaultValue);
public static native TimestampedDoubleArray[] readQueueDoubleArray(int subentry);
public static native double[][] readQueueValuesDoubleArray(int subentry);
public static native boolean setDoubleArray(int entry, long time, double[] value);
public static native double[] getDoubleArray(int entry, double[] defaultValue);
public static native boolean setDefaultDoubleArray(int entry, long time, double[] defaultValue);
public static native TimestampedStringArray getAtomicStringArray(
int subentry, String[] defaultValue);
public static native TimestampedStringArray[] readQueueStringArray(int subentry);
public static native String[][] readQueueValuesStringArray(int subentry);
public static native boolean setStringArray(int entry, long time, String[] value);
public static native String[] getStringArray(int entry, String[] defaultValue);
public static native boolean setDefaultStringArray(int entry, long time, String[] defaultValue);
public static native NetworkTableValue[] readQueueValue(int subentry);
public static native NetworkTableValue getValue(int entry);
public static native void setEntryFlags(int entry, int flags);
public static native int getEntryFlags(int entry);
public static native TopicInfo getTopicInfo(NetworkTableInstance inst, int topic);
public static native int createListenerPoller(int inst);
public static native void destroyListenerPoller(int poller);
private static int kindsToMask(EnumSet<NetworkTableEvent.Kind> kinds) {
int mask = 0;
for (NetworkTableEvent.Kind kind : kinds) {
mask |= kind.getValue();
}
return mask;
}
public static int addListener(int poller, String[] prefixes, EnumSet<NetworkTableEvent.Kind> kinds) {
return addListener(poller, prefixes, kindsToMask(kinds));
}
public static int addListener(int poller, int handle, EnumSet<NetworkTableEvent.Kind> kinds) {
return addListener(poller, handle, kindsToMask(kinds));
}
public static native int addListener(int poller, String[] prefixes, int mask);
public static native int addListener(int poller, int handle, int mask);
public static native NetworkTableEvent[] readListenerQueue(
NetworkTableInstance inst, int poller);
public static native void removeListener(int listener);
public static native int getNetworkMode(int inst);
public static native void startLocal(int inst);
public static native void stopLocal(int inst);
public static native void startServer(
int inst, String persistFilename, String listenAddress, int port3, int port4);
public static native void stopServer(int inst);
public static native void startClient3(int inst, String identity);
public static native void startClient4(int inst, String identity);
public static native void stopClient(int inst);
public static native void setServer(int inst, String serverName, int port);
public static native void setServer(int inst, String[] serverNames, int[] ports);
public static native void setServerTeam(int inst, int team, int port);
public static native void disconnect(int inst);
public static native void startDSClient(int inst, int port);
public static native void stopDSClient(int inst);
public static native void flushLocal(int inst);
public static native void flush(int inst);
public static native ConnectionInfo[] getConnections(int inst);
public static native boolean isConnected(int inst);
public static native OptionalLong getServerTimeOffset(int inst);
public static native long now();
private static native int startEntryDataLog(int inst, long log, String prefix, String logPrefix);
public static int startEntryDataLog(int inst, DataLog log, String prefix, String logPrefix) {
return startEntryDataLog(inst, log.getImpl(), prefix, logPrefix);
}
public static native void stopEntryDataLog(int logger);
private static native int startConnectionDataLog(int inst, long log, String name);
public static int startConnectionDataLog(int inst, DataLog log, String name) {
return startConnectionDataLog(inst, log.getImpl(), name);
}
public static native void stopConnectionDataLog(int logger);
public static native int addLogger(int poller, int minLevel, int maxLevel);
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables Raw entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface RawEntry extends RawSubscriber, RawPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,89 @@
// 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
package edu.wpi.first.networktables;
import java.nio.ByteBuffer;
/** NetworkTables Raw implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class RawEntryImpl extends EntryBase implements RawEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
RawEntryImpl(RawTopic topic, int handle, byte[] defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public RawTopic getTopic() {
return m_topic;
}
@Override
public byte[] get() {
return NetworkTablesJNI.getRaw(m_handle, m_defaultValue);
}
@Override
public byte[] get(byte[] defaultValue) {
return NetworkTablesJNI.getRaw(m_handle, defaultValue);
}
@Override
public TimestampedRaw getAtomic() {
return NetworkTablesJNI.getAtomicRaw(m_handle, m_defaultValue);
}
@Override
public TimestampedRaw getAtomic(byte[] defaultValue) {
return NetworkTablesJNI.getAtomicRaw(m_handle, defaultValue);
}
@Override
public TimestampedRaw[] readQueue() {
return NetworkTablesJNI.readQueueRaw(m_handle);
}
@Override
public byte[][] readQueueValues() {
return NetworkTablesJNI.readQueueValuesRaw(m_handle);
}
@Override
public void set(byte[] value, int start, int len, long time) {
NetworkTablesJNI.setRaw(m_handle, time, value, start, len);
}
@Override
public void set(ByteBuffer value, int start, int len, long time) {
NetworkTablesJNI.setRaw(m_handle, time, value, start, len);
}
@Override
public void setDefault(byte[] value, int start, int len) {
NetworkTablesJNI.setDefaultRaw(m_handle, 0, value, start, len);
}
@Override
public void setDefault(ByteBuffer value, int start, int len) {
NetworkTablesJNI.setDefaultRaw(m_handle, 0, value, start, len);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final RawTopic m_topic;
private final byte[] m_defaultValue;
}

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
package edu.wpi.first.networktables;
import java.nio.ByteBuffer;
import java.util.function.Consumer;
/** NetworkTables Raw publisher. */
public interface RawPublisher extends Publisher, Consumer<byte[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
RawTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(byte[] value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
default void set(byte[] value, long time) {
set(value, 0, value.length, time);
}
/**
* Publish a new value using current NT time.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
*/
default void set(byte[] value, int start, int len) {
set(value, start, len, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(byte[] value, int start, int len, long time);
/**
* Publish a new value using current NT time.
*
* @param value value to publish; will send from value.position() to value.limit()
*/
default void set(ByteBuffer value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish; will send from value.position() to value.limit()
* @param time timestamp; 0 indicates current NT time should be used
*/
default void set(ByteBuffer value, long time) {
int pos = value.position();
set(value, pos, value.limit() - pos, time);
}
/**
* Publish a new value using current NT time.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
*/
default void set(ByteBuffer value, int start, int len) {
set(value, start, len, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(ByteBuffer value, int start, int len, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
default void setDefault(byte[] value) {
setDefault(value, 0, value.length);
}
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.length - start)
*/
void setDefault(byte[] value, int start, int len);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value; will send from value.position() to value.limit()
*/
default void setDefault(ByteBuffer value) {
int pos = value.position();
setDefault(value, pos, value.limit() - pos);
}
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
* @param start Start position of data (in buffer)
* @param len Length of data (must be less than or equal to value.capacity() - start)
*/
void setDefault(ByteBuffer value, int start, int len);
@Override
default void accept(byte[] value) {
set(value);
}
}

View File

@@ -0,0 +1,80 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables Raw subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface RawSubscriber extends Subscriber, Supplier<byte[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
RawTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
byte[] get();
/**
* 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
*/
byte[] get(byte[] defaultValue);
/**
* 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
*/
TimestampedRaw getAtomic();
/**
* 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
*/
TimestampedRaw getAtomic(byte[] defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedRaw[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
byte[][] readQueueValues();
}

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
package edu.wpi.first.networktables;
/** NetworkTables Raw topic. */
public final class RawTopic extends Topic {
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public RawTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getRawTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public RawTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public RawSubscriber subscribe(
String typeString,
byte[] defaultValue,
PubSubOption... options) {
return new RawEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kRaw.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param typeString type string
* @param options publish options
* @return publisher
*/
public RawPublisher publish(
String typeString,
PubSubOption... options) {
return new RawEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kRaw.getValue(),
typeString, options),
new byte[] {});
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public RawPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new RawEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kRaw.getValue(),
typeString, properties, options),
new byte[] {});
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public RawEntry getEntry(
String typeString,
byte[] defaultValue,
PubSubOption... options) {
return new RawEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kRaw.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables StringArray entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface StringArrayEntry extends StringArraySubscriber, StringArrayPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables StringArray implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class StringArrayEntryImpl extends EntryBase implements StringArrayEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
StringArrayEntryImpl(StringArrayTopic topic, int handle, String[] defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public StringArrayTopic getTopic() {
return m_topic;
}
@Override
public String[] get() {
return NetworkTablesJNI.getStringArray(m_handle, m_defaultValue);
}
@Override
public String[] get(String[] defaultValue) {
return NetworkTablesJNI.getStringArray(m_handle, defaultValue);
}
@Override
public TimestampedStringArray getAtomic() {
return NetworkTablesJNI.getAtomicStringArray(m_handle, m_defaultValue);
}
@Override
public TimestampedStringArray getAtomic(String[] defaultValue) {
return NetworkTablesJNI.getAtomicStringArray(m_handle, defaultValue);
}
@Override
public TimestampedStringArray[] readQueue() {
return NetworkTablesJNI.readQueueStringArray(m_handle);
}
@Override
public String[][] readQueueValues() {
return NetworkTablesJNI.readQueueValuesStringArray(m_handle);
}
@Override
public void set(String[] value, long time) {
NetworkTablesJNI.setStringArray(m_handle, time, value);
}
@Override
public void setDefault(String[] value) {
NetworkTablesJNI.setDefaultStringArray(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final StringArrayTopic m_topic;
private final String[] m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Consumer;
/** NetworkTables StringArray publisher. */
public interface StringArrayPublisher extends Publisher, Consumer<String[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
StringArrayTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(String[] value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(String[] value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(String[] value);
@Override
default void accept(String[] value) {
set(value);
}
}

View File

@@ -0,0 +1,80 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables StringArray subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface StringArraySubscriber extends Subscriber, Supplier<String[]> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
StringArrayTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
String[] get();
/**
* 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
*/
String[] get(String[] defaultValue);
/**
* 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
*/
TimestampedStringArray getAtomic();
/**
* 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
*/
TimestampedStringArray getAtomic(String[] defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedStringArray[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
String[][] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables StringArray topic. */
public final class StringArrayTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "string[]";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public StringArrayTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getStringArrayTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public StringArrayTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public StringArraySubscriber subscribe(
String[] defaultValue,
PubSubOption... options) {
return new StringArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kStringArray.getValue(),
"string[]", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public StringArraySubscriber subscribeEx(
String typeString,
String[] defaultValue,
PubSubOption... options) {
return new StringArrayEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kStringArray.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public StringArrayPublisher publish(
PubSubOption... options) {
return new StringArrayEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kStringArray.getValue(),
"string[]", options),
new String[] {});
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public StringArrayPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new StringArrayEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kStringArray.getValue(),
typeString, properties, options),
new String[] {});
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public StringArrayEntry getEntry(
String[] defaultValue,
PubSubOption... options) {
return new StringArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kStringArray.getValue(),
"string[]", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public StringArrayEntry getEntryEx(
String typeString,
String[] defaultValue,
PubSubOption... options) {
return new StringArrayEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kStringArray.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,17 @@
// 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
package edu.wpi.first.networktables;
/**
* NetworkTables String entry.
*
* <p>Unlike NetworkTableEntry, the entry goes away when close() is called.
*/
public interface StringEntry extends StringSubscriber, StringPublisher {
/** Stops publishing the entry if it's published. */
void unpublish();
}

View File

@@ -0,0 +1,77 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables String implementation. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
final class StringEntryImpl extends EntryBase implements StringEntry {
/**
* Constructor.
*
* @param topic Topic
* @param handle Native handle
* @param defaultValue Default value for get()
*/
StringEntryImpl(StringTopic topic, int handle, String defaultValue) {
super(handle);
m_topic = topic;
m_defaultValue = defaultValue;
}
@Override
public StringTopic getTopic() {
return m_topic;
}
@Override
public String get() {
return NetworkTablesJNI.getString(m_handle, m_defaultValue);
}
@Override
public String get(String defaultValue) {
return NetworkTablesJNI.getString(m_handle, defaultValue);
}
@Override
public TimestampedString getAtomic() {
return NetworkTablesJNI.getAtomicString(m_handle, m_defaultValue);
}
@Override
public TimestampedString getAtomic(String defaultValue) {
return NetworkTablesJNI.getAtomicString(m_handle, defaultValue);
}
@Override
public TimestampedString[] readQueue() {
return NetworkTablesJNI.readQueueString(m_handle);
}
@Override
public String[] readQueueValues() {
return NetworkTablesJNI.readQueueValuesString(m_handle);
}
@Override
public void set(String value, long time) {
NetworkTablesJNI.setString(m_handle, time, value);
}
@Override
public void setDefault(String value) {
NetworkTablesJNI.setDefaultString(m_handle, 0, value);
}
@Override
public void unpublish() {
NetworkTablesJNI.unpublish(m_handle);
}
private final StringTopic m_topic;
private final String m_defaultValue;
}

View File

@@ -0,0 +1,52 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Consumer;
/** NetworkTables String publisher. */
public interface StringPublisher extends Publisher, Consumer<String> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
StringTopic getTopic();
/**
* Publish a new value using current NT time.
*
* @param value value to publish
*/
default void set(String value) {
set(value, 0);
}
/**
* Publish a new value.
*
* @param value value to publish
* @param time timestamp; 0 indicates current NT time should be used
*/
void set(String value, long time);
/**
* Publish a default value.
* On reconnect, a default value will never be used in preference to a
* published value.
*
* @param value value
*/
void setDefault(String value);
@Override
default void accept(String value) {
set(value);
}
}

View File

@@ -0,0 +1,80 @@
// 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
package edu.wpi.first.networktables;
import java.util.function.Supplier;
/** NetworkTables String subscriber. */
@SuppressWarnings("PMD.MissingOverride")
public interface StringSubscriber extends Subscriber, Supplier<String> {
/**
* Get the corresponding topic.
*
* @return Topic
*/
@Override
StringTopic getTopic();
/**
* Get the last published value.
* If no value has been published, returns the stored default value.
*
* @return value
*/
String get();
/**
* 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
*/
String get(String defaultValue);
/**
* 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
*/
TimestampedString getAtomic();
/**
* 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
*/
TimestampedString getAtomic(String defaultValue);
/**
* Get an array of all value changes since the last call to readQueue.
* Also provides a timestamp for each value.
*
* <p>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.
*/
TimestampedString[] readQueue();
/**
* Get an array of all value changes since the last call to readQueue.
*
* <p>The "poll storage" subscribe option can be used to set the queue
* depth.
*
* @return Array of values; empty array if no new changes have been
* published since the previous call.
*/
String[] readQueueValues();
}

View File

@@ -0,0 +1,206 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables String topic. */
public final class StringTopic extends Topic {
/** The default type string for this topic type. */
public static final String kTypeString = "string";
/**
* Construct from a generic topic.
*
* @param topic Topic
*/
public StringTopic(Topic topic) {
super(topic.m_inst, topic.m_handle);
}
/**
* Constructor; use NetworkTableInstance.getStringTopic() instead.
*
* @param inst Instance
* @param handle Native handle
*/
public StringTopic(NetworkTableInstance inst, int handle) {
super(inst, handle);
}
/**
* Create a new subscriber to the topic.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>Subscribers that do not match the published data type do not return
* any values. To determine if the data type matches, use the appropriate
* Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options subscribe options
* @return subscriber
*/
public StringSubscriber subscribe(
String defaultValue,
PubSubOption... options) {
return new StringEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kString.getValue(),
"string", options),
defaultValue);
}
/**
* Create a new subscriber to the topic, with specified type string.
*
* <p>The subscriber is only active as long as the returned object
* is not closed.
*
* <p>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
*/
public StringSubscriber subscribeEx(
String typeString,
String defaultValue,
PubSubOption... options) {
return new StringEntryImpl(
this,
NetworkTablesJNI.subscribe(
m_handle, NetworkTableType.kString.getValue(),
typeString, options),
defaultValue);
}
/**
* Create a new publisher to the topic.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>It is not possible to publish two different data types to the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored). To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param options publish options
* @return publisher
*/
public StringPublisher publish(
PubSubOption... options) {
return new StringEntryImpl(
this,
NetworkTablesJNI.publish(
m_handle, NetworkTableType.kString.getValue(),
"string", options),
"");
}
/**
* Create a new publisher to the topic, with type string and initial properties.
*
* <p>The publisher is only active as long as the returned object
* is not closed.
*
* <p>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
* @throws IllegalArgumentException if properties is not a JSON object
*/
public StringPublisher publishEx(
String typeString,
String properties,
PubSubOption... options) {
return new StringEntryImpl(
this,
NetworkTablesJNI.publishEx(
m_handle, NetworkTableType.kString.getValue(),
typeString, properties, options),
"");
}
/**
* Create a new entry for the topic.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>It is not possible to use two different data types with the same
* topic. Conflicts between publishers are typically resolved by the server on
* a first-come, first-served basis. Any published values that do not match
* the topic's data type are dropped (ignored), and the entry will show no new
* values if the data type does not match. To determine if the data type
* matches, use the appropriate Topic functions.
*
* @param defaultValue default value used when a default is not provided to a
* getter function
* @param options publish and/or subscribe options
* @return entry
*/
public StringEntry getEntry(
String defaultValue,
PubSubOption... options) {
return new StringEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kString.getValue(),
"string", options),
defaultValue);
}
/**
* Create a new entry for the topic, with specified type string.
*
* <p>Entries act as a combination of a subscriber and a weak publisher. The
* subscriber is active as long as the entry is not closed. The publisher is
* created when the entry is first written to, and remains active until either
* unpublish() is called or the entry is closed.
*
* <p>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
*/
public StringEntry getEntryEx(
String typeString,
String defaultValue,
PubSubOption... options) {
return new StringEntryImpl(
this,
NetworkTablesJNI.getEntry(
m_handle, NetworkTableType.kString.getValue(),
typeString, options),
defaultValue);
}
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped Boolean. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedBoolean {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedBoolean(long timestamp, long serverTime, boolean value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final boolean value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped BooleanArray. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedBooleanArray {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedBooleanArray(long timestamp, long serverTime, boolean[] value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final boolean[] value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped Double. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedDouble {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedDouble(long timestamp, long serverTime, double value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final double value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped DoubleArray. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedDoubleArray {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedDoubleArray(long timestamp, long serverTime, double[] value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final double[] value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped Float. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedFloat {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedFloat(long timestamp, long serverTime, float value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final float value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped FloatArray. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedFloatArray {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedFloatArray(long timestamp, long serverTime, float[] value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final float[] value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped Integer. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedInteger {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedInteger(long timestamp, long serverTime, long value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final long value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped IntegerArray. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedIntegerArray {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedIntegerArray(long timestamp, long serverTime, long[] value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final long[] value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped Raw. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedRaw {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedRaw(long timestamp, long serverTime, byte[] value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final byte[] value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped String. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedString {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedString(long timestamp, long serverTime, String value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final String value;
}

View File

@@ -0,0 +1,42 @@
// 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
package edu.wpi.first.networktables;
/** NetworkTables timestamped StringArray. */
@SuppressWarnings("PMD.ArrayIsStoredDirectly")
public final class TimestampedStringArray {
/**
* Create a timestamped value.
*
* @param timestamp timestamp in local time base
* @param serverTime timestamp in server time base
* @param value value
*/
public TimestampedStringArray(long timestamp, long serverTime, String[] value) {
this.timestamp = timestamp;
this.serverTime = serverTime;
this.value = value;
}
/**
* Timestamp in local time base.
*/
@SuppressWarnings("MemberName")
public final long timestamp;
/**
* Timestamp in server time base. May be 0 or 1 for locally set values.
*/
@SuppressWarnings("MemberName")
public final long serverTime;
/**
* Value.
*/
@SuppressWarnings("MemberName")
public final String[] value;
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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