WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
NetworkTable.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <functional>
8#include <memory>
9#include <span>
10#include <string>
11#include <string_view>
12#include <utility>
13#include <vector>
14
16#include "wpi/nt/Topic.hpp"
17#include "wpi/nt/ntcore_c.h"
19#include "wpi/util/mutex.hpp"
22
23namespace wpi::nt {
24
26class BooleanTopic;
28class DoubleTopic;
29class FloatArrayTopic;
30class FloatTopic;
32class IntegerTopic;
34template <wpi::util::ProtobufSerializable T>
35class ProtobufTopic;
36class RawTopic;
38class StringTopic;
39template <typename T, typename... I>
40 requires wpi::util::StructSerializable<T, I...>
42template <typename T, typename... I>
43 requires wpi::util::StructSerializable<T, I...>
44class StructTopic;
45class Topic;
46
47/**
48 * @defgroup ntcore_cpp_api ntcore C++ object-oriented API
49 *
50 * Recommended interface for C++, identical to Java API.
51 */
52
53/**
54 * A network table that knows its subtable path.
55 * @ingroup ntcore_cpp_api
56 */
57class NetworkTable final {
58 private:
59 NT_Inst m_inst;
60 std::string m_path;
61 mutable wpi::util::mutex m_mutex;
62 mutable wpi::util::StringMap<NT_Entry> m_entries;
63
64 struct private_init {};
66
67 public:
68 /**
69 * Gets the "base name" of a key. For example, "/foo/bar" becomes "bar".
70 * If the key has a trailing slash, returns an empty string.
71 *
72 * @param key key
73 * @return base name
74 */
75 static std::string_view BasenameKey(std::string_view key);
76
77 /**
78 * Normalizes an network table key to contain no consecutive slashes and
79 * optionally start with a leading slash. For example:
80 *
81 * <pre><code>
82 * normalizeKey("/foo/bar", true) == "/foo/bar"
83 * normalizeKey("foo/bar", true) == "/foo/bar"
84 * normalizeKey("/foo/bar", false) == "foo/bar"
85 * normalizeKey("foo//bar", false) == "foo/bar"
86 * </code></pre>
87 *
88 * @param key the key to normalize
89 * @param withLeadingSlash whether or not the normalized key should begin
90 * with a leading slash
91 * @return normalized key
92 */
93 static std::string NormalizeKey(std::string_view key,
94 bool withLeadingSlash = true);
95
96 static std::string_view NormalizeKey(std::string_view key,
98 bool withLeadingSlash = true);
99
100 /**
101 * Gets a list of the names of all the super tables of a given key. For
102 * example, the key "/foo/bar/baz" has a hierarchy of "/", "/foo",
103 * "/foo/bar", and "/foo/bar/baz".
104 *
105 * @param key the key
106 * @return List of super tables
107 */
108 static std::vector<std::string> GetHierarchy(std::string_view key);
109
110 /**
111 * Constructor. Use NetworkTableInstance::GetTable() or GetSubTable()
112 * instead.
113 */
114 NetworkTable(NT_Inst inst, std::string_view path, const private_init&);
116
117 /**
118 * Gets the instance for the table.
119 *
120 * @return Instance
121 */
123
124 /**
125 * The path separator for sub-tables and keys
126 */
127 static constexpr char PATH_SEPARATOR_CHAR = '/';
128
129 /**
130 * Gets the entry for a subkey.
131 *
132 * @param key the key name
133 * @return Network table entry.
134 */
135 NetworkTableEntry GetEntry(std::string_view key) const;
136
137 /**
138 * Get (generic) topic.
139 *
140 * @param name topic name
141 * @return Topic
142 */
143 Topic GetTopic(std::string_view name) const;
144
145 /**
146 * Get boolean topic.
147 *
148 * @param name topic name
149 * @return BooleanTopic
150 */
151 BooleanTopic GetBooleanTopic(std::string_view name) const;
152
153 /**
154 * Get integer topic.
155 *
156 * @param name topic name
157 * @return IntegerTopic
158 */
159 IntegerTopic GetIntegerTopic(std::string_view name) const;
160
161 /**
162 * Get float topic.
163 *
164 * @param name topic name
165 * @return FloatTopic
166 */
167 FloatTopic GetFloatTopic(std::string_view name) const;
168
169 /**
170 * Get double topic.
171 *
172 * @param name topic name
173 * @return DoubleTopic
174 */
175 DoubleTopic GetDoubleTopic(std::string_view name) const;
176
177 /**
178 * Get String topic.
179 *
180 * @param name topic name
181 * @return StringTopic
182 */
183 StringTopic GetStringTopic(std::string_view name) const;
184
185 /**
186 * Get raw topic.
187 *
188 * @param name topic name
189 * @return BooleanArrayTopic
190 */
191 RawTopic GetRawTopic(std::string_view name) const;
192
193 /**
194 * Get boolean[] topic.
195 *
196 * @param name topic name
197 * @return BooleanArrayTopic
198 */
200
201 /**
202 * Get integer[] topic.
203 *
204 * @param name topic name
205 * @return IntegerArrayTopic
206 */
208
209 /**
210 * Get float[] topic.
211 *
212 * @param name topic name
213 * @return FloatArrayTopic
214 */
215 FloatArrayTopic GetFloatArrayTopic(std::string_view name) const;
216
217 /**
218 * Get double[] topic.
219 *
220 * @param name topic name
221 * @return DoubleArrayTopic
222 */
224
225 /**
226 * Get String[] topic.
227 *
228 * @param name topic name
229 * @return StringArrayTopic
230 */
232
233 /**
234 * Gets a protobuf serialized value topic.
235 *
236 * @param name topic name
237 * @return Topic
238 */
239 template <wpi::util::ProtobufSerializable T>
240 ProtobufTopic<T> GetProtobufTopic(std::string_view name) const {
242 }
243
244 /**
245 * Gets a raw struct serialized value topic.
246 *
247 * @param name topic name
248 * @param info optional struct type info
249 * @return Topic
250 */
251 template <typename T, typename... I>
252 requires wpi::util::StructSerializable<T, I...>
253 StructTopic<T, I...> GetStructTopic(std::string_view name, I... info) const {
254 return StructTopic<T, I...>{GetTopic(name), std::move(info)...};
255 }
256
257 /**
258 * Gets a raw struct serialized array topic.
259 *
260 * @param name topic name
261 * @param info optional struct type info
262 * @return Topic
263 */
264 template <typename T, typename... I>
265 requires wpi::util::StructSerializable<T, I...>
266 StructArrayTopic<T, I...> GetStructArrayTopic(std::string_view name,
267 I... info) const {
268 return StructArrayTopic<T, I...>{GetTopic(name), std::move(info)...};
269 }
270
271 /**
272 * Returns the table at the specified key. If there is no table at the
273 * specified key, it will create a new table
274 *
275 * @param key the key name
276 * @return the networktable to be returned
277 */
278 std::shared_ptr<NetworkTable> GetSubTable(std::string_view key) const;
279
280 /**
281 * Determines whether the given key is in this table.
282 *
283 * @param key the key to search for
284 * @return true if the table as a value assigned to the given key
285 */
286 bool ContainsKey(std::string_view key) const;
287
288 /**
289 * Determines whether there exists a non-empty subtable for this key
290 * in this table.
291 *
292 * @param key the key to search for
293 * @return true if there is a subtable with the key which contains at least
294 * one key/subtable of its own
295 */
296 bool ContainsSubTable(std::string_view key) const;
297
298 /**
299 * Gets topic information for all keys in the table (not including
300 * sub-tables).
301 *
302 * @param types bitmask of types; 0 is treated as a "don't care".
303 * @return topic information for keys currently in the table
304 */
305 std::vector<TopicInfo> GetTopicInfo(int types = 0) const;
306
307 /**
308 * Gets all topics in the table (not including sub-tables).
309 *
310 * @param types bitmask of types; 0 is treated as a "don't care".
311 * @return topic for keys currently in the table
312 */
313 std::vector<Topic> GetTopics(int types = 0) const;
314
315 /**
316 * Gets all keys in the table (not including sub-tables).
317 *
318 * @param types bitmask of types; 0 is treated as a "don't care".
319 * @return keys currently in the table
320 */
321 std::vector<std::string> GetKeys(int types = 0) const;
322
323 /**
324 * Gets the names of all subtables in the table.
325 *
326 * @return subtables currently in the table
327 */
328 std::vector<std::string> GetSubTables() const;
329
330 /**
331 * Makes a key's value persistent through program restarts.
332 *
333 * @param key the key to make persistent
334 */
335 void SetPersistent(std::string_view key);
336
337 /**
338 * Stop making a key's value persistent through program restarts.
339 * The key cannot be null.
340 *
341 * @param key the key name
342 */
343 void ClearPersistent(std::string_view key);
344
345 /**
346 * Returns whether the value is persistent through program restarts.
347 * The key cannot be null.
348 *
349 * @param key the key name
350 */
351 bool IsPersistent(std::string_view key) const;
352
353 /**
354 * Put a number in the table
355 *
356 * @param key the key to be assigned to
357 * @param value the value that will be assigned
358 * @return False if the table key already exists with a different type
359 */
360 bool PutNumber(std::string_view key, double value);
361
362 /**
363 * Set Default Entry Value
364 *
365 * @param key the key
366 * @param defaultValue the default value to set if key doesn't exist.
367 * @returns True if the table key did not already exist, otherwise False
368 */
369 bool SetDefaultNumber(std::string_view key, double defaultValue);
370
371 /**
372 * Gets the number associated with the given name.
373 *
374 * @param key the key to look up
375 * @param defaultValue the value to be returned if no value is found
376 * @return the value associated with the given key or the given default value
377 * if there is no value associated with the key
378 */
379 double GetNumber(std::string_view key, double defaultValue) const;
380
381 /**
382 * Put a string in the table
383 *
384 * @param key the key to be assigned to
385 * @param value the value that will be assigned
386 * @return False if the table key already exists with a different type
387 */
388 bool PutString(std::string_view key, std::string_view value);
389
390 /**
391 * Set Default Entry Value
392 *
393 * @param key the key
394 * @param defaultValue the default value to set if key doesn't exist.
395 * @returns True if the table key did not already exist, otherwise False
396 */
397 bool SetDefaultString(std::string_view key, std::string_view defaultValue);
398
399 /**
400 * Gets the string associated with the given name. If the key does not
401 * exist or is of different type, it will return the default value.
402 *
403 * @param key the key to look up
404 * @param defaultValue the value to be returned if no value is found
405 * @return the value associated with the given key or the given default value
406 * if there is no value associated with the key
407 */
408 std::string GetString(std::string_view key,
409 std::string_view defaultValue) const;
410
411 /**
412 * Put a boolean in the table
413 *
414 * @param key the key to be assigned to
415 * @param value the value that will be assigned
416 * @return False if the table key already exists with a different type
417 */
418 bool PutBoolean(std::string_view key, bool value);
419
420 /**
421 * Set Default Entry Value
422 *
423 * @param key the key
424 * @param defaultValue the default value to set if key doesn't exist.
425 * @returns True if the table key did not already exist, otherwise False
426 */
427 bool SetDefaultBoolean(std::string_view key, bool defaultValue);
428
429 /**
430 * Gets the boolean associated with the given name. If the key does not
431 * exist or is of different type, it will return the default value.
432 *
433 * @param key the key to look up
434 * @param defaultValue the value to be returned if no value is found
435 * @return the value associated with the given key or the given default value
436 * if there is no value associated with the key
437 */
438 bool GetBoolean(std::string_view key, bool defaultValue) const;
439
440 /**
441 * Put a boolean array in the table
442 *
443 * @param key the key to be assigned to
444 * @param value the value that will be assigned
445 * @return False if the table key already exists with a different type
446 *
447 * @note The array must be of int's rather than of bool's because
448 * std::vector<bool> is special-cased in C++. 0 is false, any
449 * non-zero value is true.
450 */
451 bool PutBooleanArray(std::string_view key, std::span<const int> value);
452
453 /**
454 * Set Default Entry Value
455 *
456 * @param key the key
457 * @param defaultValue the default value to set if key doesn't exist.
458 * @return True if the table key did not already exist, otherwise False
459 */
460 bool SetDefaultBooleanArray(std::string_view key,
461 std::span<const int> defaultValue);
462
463 /**
464 * Returns the boolean array the key maps to. If the key does not exist or is
465 * of different type, it will return the default value.
466 *
467 * @param key the key to look up
468 * @param defaultValue the value to be returned if no value is found
469 * @return the value associated with the given key or the given default value
470 * if there is no value associated with the key
471 *
472 * @note This makes a copy of the array. If the overhead of this is a
473 * concern, use GetValue() instead.
474 *
475 * @note The returned array is std::vector<int> instead of std::vector<bool>
476 * because std::vector<bool> is special-cased in C++. 0 is false, any
477 * non-zero value is true.
478 */
479 std::vector<int> GetBooleanArray(std::string_view key,
480 std::span<const int> defaultValue) const;
481
482 /**
483 * Put a number array in the table
484 *
485 * @param key the key to be assigned to
486 * @param value the value that will be assigned
487 * @return False if the table key already exists with a different type
488 */
489 bool PutNumberArray(std::string_view key, std::span<const double> value);
490
491 /**
492 * Set Default Entry Value
493 *
494 * @param key the key
495 * @param defaultValue the default value to set if key doesn't exist.
496 * @returns True if the table key did not already exist, otherwise False
497 */
498 bool SetDefaultNumberArray(std::string_view key,
499 std::span<const double> defaultValue);
500
501 /**
502 * Returns the number array the key maps to. If the key does not exist or is
503 * of different type, it will return the default value.
504 *
505 * @param key the key to look up
506 * @param defaultValue the value to be returned if no value is found
507 * @return the value associated with the given key or the given default value
508 * if there is no value associated with the key
509 *
510 * @note This makes a copy of the array. If the overhead of this is a
511 * concern, use GetValue() instead.
512 */
513 std::vector<double> GetNumberArray(
514 std::string_view key, std::span<const double> defaultValue) const;
515
516 /**
517 * Put a string array in the table
518 *
519 * @param key the key to be assigned to
520 * @param value the value that will be assigned
521 * @return False if the table key already exists with a different type
522 */
523 bool PutStringArray(std::string_view key, std::span<const std::string> value);
524
525 /**
526 * Set Default Entry Value
527 *
528 * @param key the key
529 * @param defaultValue the default value to set if key doesn't exist.
530 * @returns True if the table key did not already exist, otherwise False
531 */
532 bool SetDefaultStringArray(std::string_view key,
533 std::span<const std::string> defaultValue);
534
535 /**
536 * Returns the string array the key maps to. If the key does not exist or is
537 * of different type, it will return the default value.
538 *
539 * @param key the key to look up
540 * @param defaultValue the value to be returned if no value is found
541 * @return the value associated with the given key or the given default value
542 * if there is no value associated with the key
543 *
544 * @note This makes a copy of the array. If the overhead of this is a
545 * concern, use GetValue() instead.
546 */
547 std::vector<std::string> GetStringArray(
548 std::string_view key, std::span<const std::string> defaultValue) const;
549
550 /**
551 * Put a raw value (byte array) in the table
552 *
553 * @param key the key to be assigned to
554 * @param value the value that will be assigned
555 * @return False if the table key already exists with a different type
556 */
557 bool PutRaw(std::string_view key, std::span<const uint8_t> value);
558
559 /**
560 * Set Default Entry Value
561 *
562 * @param key the key
563 * @param defaultValue the default value to set if key doesn't exist.
564 * @return True if the table key did not already exist, otherwise False
565 */
566 bool SetDefaultRaw(std::string_view key,
567 std::span<const uint8_t> defaultValue);
568
569 /**
570 * Returns the raw value (byte array) the key maps to. If the key does not
571 * exist or is of different type, it will return the default value.
572 *
573 * @param key the key to look up
574 * @param defaultValue the value to be returned if no value is found
575 * @return the value associated with the given key or the given default value
576 * if there is no value associated with the key
577 *
578 * @note This makes a copy of the raw contents. If the overhead of this is a
579 * concern, use GetValue() instead.
580 */
581 std::vector<uint8_t> GetRaw(std::string_view key,
582 std::span<const uint8_t> defaultValue) const;
583
584 /**
585 * Put a value in the table
586 *
587 * @param key the key to be assigned to
588 * @param value the value that will be assigned
589 * @return False if the table key already exists with a different type
590 */
591 bool PutValue(std::string_view key, const Value& value);
592
593 /**
594 * Set Default Entry Value.
595 *
596 * @param key the key
597 * @param defaultValue the default value to set if key doesn't exist.
598 * @return True if the table key did not already exist, otherwise False
599 */
600 bool SetDefaultValue(std::string_view key, const Value& defaultValue);
601
602 /**
603 * Gets the value associated with a key as an object
604 *
605 * @param key the key of the value to look up
606 * @return the value associated with the given key, or nullptr if the key
607 * does not exist
608 */
609 Value GetValue(std::string_view key) const;
610
611 /**
612 * Gets the full path of this table. Does not include the trailing "/".
613 *
614 * @return The path (e.g "", "/foo").
615 */
616 std::string_view GetPath() const;
617
618 /**
619 * Called when an event occurs on a topic in a {@link NetworkTable}.
620 *
621 * @param table the table the topic exists in
622 * @param key the key associated with the topic that changed
623 * @param event the event
624 */
625 using TableEventListener = std::function<void(
626 NetworkTable* table, std::string_view key, const Event& event)>;
627
628 /**
629 * Listen to topics only within this table.
630 *
631 * @param eventMask Bitmask of EventFlags values
632 * @param listener listener to add
633 * @return Listener handle
634 */
636
637 /**
638 * Listen to a single key.
639 *
640 * @param key the key name
641 * @param eventMask Bitmask of EventFlags values
642 * @param listener listener to add
643 * @return Listener handle
644 */
645 NT_Listener AddListener(std::string_view key, int eventMask,
646 TableEventListener listener);
647
648 /**
649 * Called when a new table is created within a NetworkTable.
650 *
651 * @param parent the parent of the table
652 * @param name the name of the new table
653 * @param table the new table
654 */
656 std::function<void(NetworkTable* parent, std::string_view name,
657 std::shared_ptr<NetworkTable> table)>;
658
659 /**
660 * Listen for sub-table creation. This calls the listener once for each newly
661 * created sub-table. It immediately calls the listener for any existing
662 * sub-tables.
663 *
664 * @param listener listener to add
665 * @return Listener handle
666 */
668
669 /**
670 * Remove a listener.
671 *
672 * @param listener listener handle
673 */
675};
676
677} // namespace wpi::nt
@ name
Definition base.h:690
NetworkTables BooleanArray topic.
Definition BooleanArrayTopic.hpp:296
NetworkTables Boolean topic.
Definition BooleanTopic.hpp:235
NetworkTables DoubleArray topic.
Definition DoubleArrayTopic.hpp:296
NetworkTables Double topic.
Definition DoubleTopic.hpp:235
NetworkTables event.
Definition ntcore_cpp.hpp:215
NetworkTables FloatArray topic.
Definition FloatArrayTopic.hpp:296
NetworkTables Float topic.
Definition FloatTopic.hpp:235
NetworkTables IntegerArray topic.
Definition IntegerArrayTopic.hpp:296
NetworkTables Integer topic.
Definition IntegerTopic.hpp:235
NetworkTables Entry.
Definition NetworkTableEntry.hpp:31
IntegerArrayTopic GetIntegerArrayTopic(std::string_view name) const
Get integer[] topic.
std::vector< int > GetBooleanArray(std::string_view key, std::span< const int > defaultValue) const
Returns the boolean array the key maps to.
NT_Listener AddListener(std::string_view key, int eventMask, TableEventListener listener)
Listen to a single key.
StructTopic< T, I... > GetStructTopic(std::string_view name, I... info) const
Gets a raw struct serialized value topic.
Definition NetworkTable.hpp:253
std::function< void( NetworkTable *table, std::string_view key, const Event &event)> TableEventListener
Called when an event occurs on a topic in a NetworkTable.
Definition NetworkTable.hpp:625
bool SetDefaultString(std::string_view key, std::string_view defaultValue)
Set Default Entry Value.
std::function< void(NetworkTable *parent, std::string_view name, std::shared_ptr< NetworkTable > table)> SubTableListener
Called when a new table is created within a NetworkTable.
Definition NetworkTable.hpp:655
IntegerTopic GetIntegerTopic(std::string_view name) const
Get integer topic.
bool SetDefaultBoolean(std::string_view key, bool defaultValue)
Set Default Entry Value.
static std::string NormalizeKey(std::string_view key, bool withLeadingSlash=true)
Normalizes an network table key to contain no consecutive slashes and optionally start with a leading...
void ClearPersistent(std::string_view key)
Stop making a key's value persistent through program restarts.
RawTopic GetRawTopic(std::string_view name) const
Get raw topic.
bool PutNumberArray(std::string_view key, std::span< const double > value)
Put a number array in the table.
std::vector< double > GetNumberArray(std::string_view key, std::span< const double > defaultValue) const
Returns the number array the key maps to.
static std::string_view NormalizeKey(std::string_view key, wpi::util::SmallVectorImpl< char > &buf, bool withLeadingSlash=true)
bool PutBooleanArray(std::string_view key, std::span< const int > value)
Put a boolean array in the table.
std::vector< std::string > GetStringArray(std::string_view key, std::span< const std::string > defaultValue) const
Returns the string array the key maps to.
Topic GetTopic(std::string_view name) const
Get (generic) topic.
std::vector< TopicInfo > GetTopicInfo(int types=0) const
Gets topic information for all keys in the table (not including sub-tables).
std::vector< std::string > GetSubTables() const
Gets the names of all subtables in the table.
ProtobufTopic< T > GetProtobufTopic(std::string_view name) const
Gets a protobuf serialized value topic.
Definition NetworkTable.hpp:240
std::string_view GetPath() const
Gets the full path of this table.
bool SetDefaultRaw(std::string_view key, std::span< const uint8_t > defaultValue)
Set Default Entry Value.
static constexpr char PATH_SEPARATOR_CHAR
The path separator for sub-tables and keys.
Definition NetworkTable.hpp:127
static std::string_view BasenameKey(std::string_view key)
Gets the "base name" of a key.
DoubleTopic GetDoubleTopic(std::string_view name) const
Get double topic.
std::string GetString(std::string_view key, std::string_view defaultValue) const
Gets the string associated with the given name.
StructArrayTopic< T, I... > GetStructArrayTopic(std::string_view name, I... info) const
Gets a raw struct serialized array topic.
Definition NetworkTable.hpp:266
static std::vector< std::string > GetHierarchy(std::string_view key)
Gets a list of the names of all the super tables of a given key.
bool SetDefaultNumberArray(std::string_view key, std::span< const double > defaultValue)
Set Default Entry Value.
FloatTopic GetFloatTopic(std::string_view name) const
Get float topic.
void RemoveListener(NT_Listener listener)
Remove a listener.
NetworkTableEntry GetEntry(std::string_view key) const
Gets the entry for a subkey.
friend class NetworkTableInstance
Definition NetworkTable.hpp:65
NT_Listener AddSubTableListener(SubTableListener listener)
Listen for sub-table creation.
bool PutStringArray(std::string_view key, std::span< const std::string > value)
Put a string array in the table.
Value GetValue(std::string_view key) const
Gets the value associated with a key as an object.
DoubleArrayTopic GetDoubleArrayTopic(std::string_view name) const
Get double[] topic.
NT_Listener AddListener(int eventMask, TableEventListener listener)
Listen to topics only within this table.
bool SetDefaultBooleanArray(std::string_view key, std::span< const int > defaultValue)
Set Default Entry Value.
std::vector< Topic > GetTopics(int types=0) const
Gets all topics in the table (not including sub-tables).
bool PutString(std::string_view key, std::string_view value)
Put a string in the table.
bool PutBoolean(std::string_view key, bool value)
Put a boolean in the table.
bool PutRaw(std::string_view key, std::span< const uint8_t > value)
Put a raw value (byte array) in the table.
NetworkTable(NT_Inst inst, std::string_view path, const private_init &)
Constructor.
FloatArrayTopic GetFloatArrayTopic(std::string_view name) const
Get float[] topic.
std::shared_ptr< NetworkTable > GetSubTable(std::string_view key) const
Returns the table at the specified key.
std::vector< uint8_t > GetRaw(std::string_view key, std::span< const uint8_t > defaultValue) const
Returns the raw value (byte array) the key maps to.
bool SetDefaultValue(std::string_view key, const Value &defaultValue)
Set Default Entry Value.
NetworkTableInstance GetInstance() const
Gets the instance for the table.
bool SetDefaultNumber(std::string_view key, double defaultValue)
Set Default Entry Value.
BooleanTopic GetBooleanTopic(std::string_view name) const
Get boolean topic.
bool ContainsKey(std::string_view key) const
Determines whether the given key is in this table.
bool ContainsSubTable(std::string_view key) const
Determines whether there exists a non-empty subtable for this key in this table.
bool PutValue(std::string_view key, const Value &value)
Put a value in the table.
BooleanArrayTopic GetBooleanArrayTopic(std::string_view name) const
Get boolean[] topic.
std::vector< std::string > GetKeys(int types=0) const
Gets all keys in the table (not including sub-tables).
bool GetBoolean(std::string_view key, bool defaultValue) const
Gets the boolean associated with the given name.
void SetPersistent(std::string_view key)
Makes a key's value persistent through program restarts.
double GetNumber(std::string_view key, double defaultValue) const
Gets the number associated with the given name.
StringArrayTopic GetStringArrayTopic(std::string_view name) const
Get String[] topic.
bool PutNumber(std::string_view key, double value)
Put a number in the table.
StringTopic GetStringTopic(std::string_view name) const
Get String topic.
bool SetDefaultStringArray(std::string_view key, std::span< const std::string > defaultValue)
Set Default Entry Value.
bool IsPersistent(std::string_view key) const
Returns whether the value is persistent through program restarts.
NetworkTables Instance.
Definition NetworkTableInstance.hpp:67
NetworkTables protobuf-encoded value topic.
Definition ProtobufTopic.hpp:336
NetworkTables Raw topic.
Definition RawTopic.hpp:296
NetworkTables StringArray topic.
Definition StringArrayTopic.hpp:235
NetworkTables String topic.
Definition StringTopic.hpp:298
NetworkTables struct-encoded value array topic.
Definition StructArrayTopic.hpp:466
NetworkTables struct-encoded value topic.
Definition StructTopic.hpp:372
NetworkTables Topic.
Definition Topic.hpp:27
A network table entry value.
Definition NetworkTableValue.hpp:35
Definition BooleanTopic.hpp:24
StringMap is a sorted associative container that contains key-value pairs with unique string keys.
Definition StringMap.hpp:26
Specifies that a type is capable of raw struct serialization and deserialization.
Definition Struct.hpp:69
NT_Handle NT_Listener
Definition ntcore_c.h:39
NT_Handle NT_Inst
Definition ntcore_c.h:38
NetworkTables (ntcore) namespace.
Definition NTSendable.hpp:9
::std::mutex mutex
Definition mutex.hpp:17