WPILibC++ 2024.1.1-beta-4
ntcore_cpp_types.h
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// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
6
7#pragma once
8
9#include <stdint.h>
10
11#include <span>
12#include <string>
13#include <string_view>
14#include <utility>
15#include <vector>
16
17#include "ntcore_c.h"
18
19namespace wpi {
20template <typename T>
21class SmallVectorImpl;
22} // namespace wpi
23
24namespace nt {
25/**
26 * Timestamped value.
27 * @ingroup ntcore_cpp_handle_api
28 */
29template <typename T>
31 Timestamped() = default;
32 Timestamped(int64_t time, int64_t serverTime, T value)
34
35 /**
36 * Time in local time base.
37 */
38 int64_t time = 0;
39
40 /**
41 * Time in server time base. May be 0 or 1 for locally set values.
42 */
43 int64_t serverTime = 0;
44
45 /**
46 * Value.
47 */
48 T value = {};
49};
50
51/**
52 * Timestamped Boolean.
53 * @ingroup ntcore_cpp_handle_api
54 */
56
57/**
58 * @defgroup ntcore_Boolean_func Boolean Functions
59 * @ingroup ntcore_cpp_handle_api
60 * @{
61 */
62
63/**
64 * Publish a new value.
65 *
66 * @param pubentry publisher or entry handle
67 * @param value value to publish
68 * @param time timestamp; 0 indicates current NT time should be used
69 */
70bool SetBoolean(NT_Handle pubentry, bool value, int64_t time = 0);
71
72/**
73 * Publish a default value.
74 * On reconnect, a default value will never be used in preference to a
75 * published value.
76 *
77 * @param pubentry publisher or entry handle
78 * @param defaultValue default value
79 */
80bool SetDefaultBoolean(NT_Handle pubentry, bool defaultValue);
81
82/**
83 * Get the last published value.
84 * If no value has been published, returns the passed defaultValue.
85 *
86 * @param subentry subscriber or entry handle
87 * @param defaultValue default value to return if no value has been published
88 * @return value
89 */
90bool GetBoolean(NT_Handle subentry, bool defaultValue);
91
92/**
93 * Get the last published value along with its timestamp.
94 * If no value has been published, returns the passed defaultValue and a
95 * timestamp of 0.
96 *
97 * @param subentry subscriber or entry handle
98 * @param defaultValue default value to return if no value has been published
99 * @return timestamped value
100 */
101TimestampedBoolean GetAtomicBoolean(NT_Handle subentry, bool defaultValue);
102
103/**
104 * Get an array of all value changes since the last call to ReadQueue.
105 * Also provides a timestamp for each value.
106 *
107 * @note The "poll storage" subscribe option can be used to set the queue
108 * depth.
109 *
110 * @param subentry subscriber or entry handle
111 * @return Array of timestamped values; empty array if no new changes have
112 * been published since the previous call.
113 */
114std::vector<TimestampedBoolean> ReadQueueBoolean(NT_Handle subentry);
115
116/**
117 * Get an array of all value changes since the last call to ReadQueue.
118 *
119 * @note The "poll storage" subscribe option can be used to set the queue
120 * depth.
121 *
122 * @param subentry subscriber or entry handle
123 * @return Array of values; empty array if no new changes have
124 * been published since the previous call.
125 */
126std::vector<int> ReadQueueValuesBoolean(NT_Handle subentry);
127
128/** @} */
129
130/**
131 * Timestamped Integer.
132 * @ingroup ntcore_cpp_handle_api
133 */
135
136/**
137 * @defgroup ntcore_Integer_func Integer Functions
138 * @ingroup ntcore_cpp_handle_api
139 * @{
140 */
141
142/**
143 * Publish a new value.
144 *
145 * @param pubentry publisher or entry handle
146 * @param value value to publish
147 * @param time timestamp; 0 indicates current NT time should be used
148 */
149bool SetInteger(NT_Handle pubentry, int64_t value, int64_t time = 0);
150
151/**
152 * Publish a default value.
153 * On reconnect, a default value will never be used in preference to a
154 * published value.
155 *
156 * @param pubentry publisher or entry handle
157 * @param defaultValue default value
158 */
159bool SetDefaultInteger(NT_Handle pubentry, int64_t defaultValue);
160
161/**
162 * Get the last published value.
163 * If no value has been published, returns the passed defaultValue.
164 *
165 * @param subentry subscriber or entry handle
166 * @param defaultValue default value to return if no value has been published
167 * @return value
168 */
169int64_t GetInteger(NT_Handle subentry, int64_t defaultValue);
170
171/**
172 * Get the last published value along with its timestamp.
173 * If no value has been published, returns the passed defaultValue and a
174 * timestamp of 0.
175 *
176 * @param subentry subscriber or entry handle
177 * @param defaultValue default value to return if no value has been published
178 * @return timestamped value
179 */
180TimestampedInteger GetAtomicInteger(NT_Handle subentry, int64_t defaultValue);
181
182/**
183 * Get an array of all value changes since the last call to ReadQueue.
184 * Also provides a timestamp for each value.
185 *
186 * @note The "poll storage" subscribe option can be used to set the queue
187 * depth.
188 *
189 * @param subentry subscriber or entry handle
190 * @return Array of timestamped values; empty array if no new changes have
191 * been published since the previous call.
192 */
193std::vector<TimestampedInteger> ReadQueueInteger(NT_Handle subentry);
194
195/**
196 * Get an array of all value changes since the last call to ReadQueue.
197 *
198 * @note The "poll storage" subscribe option can be used to set the queue
199 * depth.
200 *
201 * @param subentry subscriber or entry handle
202 * @return Array of values; empty array if no new changes have
203 * been published since the previous call.
204 */
205std::vector<int64_t> ReadQueueValuesInteger(NT_Handle subentry);
206
207/** @} */
208
209/**
210 * Timestamped Float.
211 * @ingroup ntcore_cpp_handle_api
212 */
214
215/**
216 * @defgroup ntcore_Float_func Float Functions
217 * @ingroup ntcore_cpp_handle_api
218 * @{
219 */
220
221/**
222 * Publish a new value.
223 *
224 * @param pubentry publisher or entry handle
225 * @param value value to publish
226 * @param time timestamp; 0 indicates current NT time should be used
227 */
228bool SetFloat(NT_Handle pubentry, float value, int64_t time = 0);
229
230/**
231 * Publish a default value.
232 * On reconnect, a default value will never be used in preference to a
233 * published value.
234 *
235 * @param pubentry publisher or entry handle
236 * @param defaultValue default value
237 */
238bool SetDefaultFloat(NT_Handle pubentry, float defaultValue);
239
240/**
241 * Get the last published value.
242 * If no value has been published, returns the passed defaultValue.
243 *
244 * @param subentry subscriber or entry handle
245 * @param defaultValue default value to return if no value has been published
246 * @return value
247 */
248float GetFloat(NT_Handle subentry, float defaultValue);
249
250/**
251 * Get the last published value along with its timestamp.
252 * If no value has been published, returns the passed defaultValue and a
253 * timestamp of 0.
254 *
255 * @param subentry subscriber or entry handle
256 * @param defaultValue default value to return if no value has been published
257 * @return timestamped value
258 */
259TimestampedFloat GetAtomicFloat(NT_Handle subentry, float defaultValue);
260
261/**
262 * Get an array of all value changes since the last call to ReadQueue.
263 * Also provides a timestamp for each value.
264 *
265 * @note The "poll storage" subscribe option can be used to set the queue
266 * depth.
267 *
268 * @param subentry subscriber or entry handle
269 * @return Array of timestamped values; empty array if no new changes have
270 * been published since the previous call.
271 */
272std::vector<TimestampedFloat> ReadQueueFloat(NT_Handle subentry);
273
274/**
275 * Get an array of all value changes since the last call to ReadQueue.
276 *
277 * @note The "poll storage" subscribe option can be used to set the queue
278 * depth.
279 *
280 * @param subentry subscriber or entry handle
281 * @return Array of values; empty array if no new changes have
282 * been published since the previous call.
283 */
284std::vector<float> ReadQueueValuesFloat(NT_Handle subentry);
285
286/** @} */
287
288/**
289 * Timestamped Double.
290 * @ingroup ntcore_cpp_handle_api
291 */
293
294/**
295 * @defgroup ntcore_Double_func Double Functions
296 * @ingroup ntcore_cpp_handle_api
297 * @{
298 */
299
300/**
301 * Publish a new value.
302 *
303 * @param pubentry publisher or entry handle
304 * @param value value to publish
305 * @param time timestamp; 0 indicates current NT time should be used
306 */
307bool SetDouble(NT_Handle pubentry, double value, int64_t time = 0);
308
309/**
310 * Publish a default value.
311 * On reconnect, a default value will never be used in preference to a
312 * published value.
313 *
314 * @param pubentry publisher or entry handle
315 * @param defaultValue default value
316 */
317bool SetDefaultDouble(NT_Handle pubentry, double defaultValue);
318
319/**
320 * Get the last published value.
321 * If no value has been published, returns the passed defaultValue.
322 *
323 * @param subentry subscriber or entry handle
324 * @param defaultValue default value to return if no value has been published
325 * @return value
326 */
327double GetDouble(NT_Handle subentry, double defaultValue);
328
329/**
330 * Get the last published value along with its timestamp.
331 * If no value has been published, returns the passed defaultValue and a
332 * timestamp of 0.
333 *
334 * @param subentry subscriber or entry handle
335 * @param defaultValue default value to return if no value has been published
336 * @return timestamped value
337 */
338TimestampedDouble GetAtomicDouble(NT_Handle subentry, double defaultValue);
339
340/**
341 * Get an array of all value changes since the last call to ReadQueue.
342 * Also provides a timestamp for each value.
343 *
344 * @note The "poll storage" subscribe option can be used to set the queue
345 * depth.
346 *
347 * @param subentry subscriber or entry handle
348 * @return Array of timestamped values; empty array if no new changes have
349 * been published since the previous call.
350 */
351std::vector<TimestampedDouble> ReadQueueDouble(NT_Handle subentry);
352
353/**
354 * Get an array of all value changes since the last call to ReadQueue.
355 *
356 * @note The "poll storage" subscribe option can be used to set the queue
357 * depth.
358 *
359 * @param subentry subscriber or entry handle
360 * @return Array of values; empty array if no new changes have
361 * been published since the previous call.
362 */
363std::vector<double> ReadQueueValuesDouble(NT_Handle subentry);
364
365/** @} */
366
367/**
368 * Timestamped String.
369 * @ingroup ntcore_cpp_handle_api
370 */
372
373/**
374 * Timestamped String view (for SmallVector-taking functions).
375 * @ingroup ntcore_cpp_handle_api
376 */
378
379/**
380 * @defgroup ntcore_String_func String Functions
381 * @ingroup ntcore_cpp_handle_api
382 * @{
383 */
384
385/**
386 * Publish a new value.
387 *
388 * @param pubentry publisher or entry handle
389 * @param value value to publish
390 * @param time timestamp; 0 indicates current NT time should be used
391 */
392bool SetString(NT_Handle pubentry, std::string_view value, int64_t time = 0);
393
394/**
395 * Publish a default value.
396 * On reconnect, a default value will never be used in preference to a
397 * published value.
398 *
399 * @param pubentry publisher or entry handle
400 * @param defaultValue default value
401 */
402bool SetDefaultString(NT_Handle pubentry, std::string_view defaultValue);
403
404/**
405 * Get the last published value.
406 * If no value has been published, returns the passed defaultValue.
407 *
408 * @param subentry subscriber or entry handle
409 * @param defaultValue default value to return if no value has been published
410 * @return value
411 */
412std::string GetString(NT_Handle subentry, std::string_view defaultValue);
413
414/**
415 * Get the last published value along with its timestamp.
416 * If no value has been published, returns the passed defaultValue and a
417 * timestamp of 0.
418 *
419 * @param subentry subscriber or entry handle
420 * @param defaultValue default value to return if no value has been published
421 * @return timestamped value
422 */
424
425/**
426 * Get an array of all value changes since the last call to ReadQueue.
427 * Also provides a timestamp for each value.
428 *
429 * @note The "poll storage" subscribe option can be used to set the queue
430 * depth.
431 *
432 * @param subentry subscriber or entry handle
433 * @return Array of timestamped values; empty array if no new changes have
434 * been published since the previous call.
435 */
436std::vector<TimestampedString> ReadQueueString(NT_Handle subentry);
437
438/**
439 * Get an array of all value changes since the last call to ReadQueue.
440 *
441 * @note The "poll storage" subscribe option can be used to set the queue
442 * depth.
443 *
444 * @param subentry subscriber or entry handle
445 * @return Array of values; empty array if no new changes have
446 * been published since the previous call.
447 */
448std::vector<std::string> ReadQueueValuesString(NT_Handle subentry);
449
451
453 NT_Handle subentry,
455 std::string_view defaultValue);
456
457/** @} */
458
459/**
460 * Timestamped Raw.
461 * @ingroup ntcore_cpp_handle_api
462 */
464
465/**
466 * Timestamped Raw view (for SmallVector-taking functions).
467 * @ingroup ntcore_cpp_handle_api
468 */
470
471/**
472 * @defgroup ntcore_Raw_func Raw Functions
473 * @ingroup ntcore_cpp_handle_api
474 * @{
475 */
476
477/**
478 * Publish a new value.
479 *
480 * @param pubentry publisher or entry handle
481 * @param value value to publish
482 * @param time timestamp; 0 indicates current NT time should be used
483 */
484bool SetRaw(NT_Handle pubentry, std::span<const uint8_t> value, int64_t time = 0);
485
486/**
487 * Publish a default value.
488 * On reconnect, a default value will never be used in preference to a
489 * published value.
490 *
491 * @param pubentry publisher or entry handle
492 * @param defaultValue default value
493 */
494bool SetDefaultRaw(NT_Handle pubentry, std::span<const uint8_t> defaultValue);
495
496/**
497 * Get the last published value.
498 * If no value has been published, returns the passed defaultValue.
499 *
500 * @param subentry subscriber or entry handle
501 * @param defaultValue default value to return if no value has been published
502 * @return value
503 */
504std::vector<uint8_t> GetRaw(NT_Handle subentry, std::span<const uint8_t> defaultValue);
505
506/**
507 * Get the last published value along with its timestamp.
508 * If no value has been published, returns the passed defaultValue and a
509 * timestamp of 0.
510 *
511 * @param subentry subscriber or entry handle
512 * @param defaultValue default value to return if no value has been published
513 * @return timestamped value
514 */
515TimestampedRaw GetAtomicRaw(NT_Handle subentry, std::span<const uint8_t> defaultValue);
516
517/**
518 * Get an array of all value changes since the last call to ReadQueue.
519 * Also provides a timestamp for each value.
520 *
521 * @note The "poll storage" subscribe option can be used to set the queue
522 * depth.
523 *
524 * @param subentry subscriber or entry handle
525 * @return Array of timestamped values; empty array if no new changes have
526 * been published since the previous call.
527 */
528std::vector<TimestampedRaw> ReadQueueRaw(NT_Handle subentry);
529
530/**
531 * Get an array of all value changes since the last call to ReadQueue.
532 *
533 * @note The "poll storage" subscribe option can be used to set the queue
534 * depth.
535 *
536 * @param subentry subscriber or entry handle
537 * @return Array of values; empty array if no new changes have
538 * been published since the previous call.
539 */
540std::vector<std::vector<uint8_t>> ReadQueueValuesRaw(NT_Handle subentry);
541
542std::span<uint8_t> GetRaw(NT_Handle subentry, wpi::SmallVectorImpl<uint8_t>& buf, std::span<const uint8_t> defaultValue);
543
545 NT_Handle subentry,
547 std::span<const uint8_t> defaultValue);
548
549/** @} */
550
551/**
552 * Timestamped BooleanArray.
553 * @ingroup ntcore_cpp_handle_api
554 */
556
557/**
558 * Timestamped BooleanArray view (for SmallVector-taking functions).
559 * @ingroup ntcore_cpp_handle_api
560 */
562
563/**
564 * @defgroup ntcore_BooleanArray_func BooleanArray Functions
565 * @ingroup ntcore_cpp_handle_api
566 * @{
567 */
568
569/**
570 * Publish a new value.
571 *
572 * @param pubentry publisher or entry handle
573 * @param value value to publish
574 * @param time timestamp; 0 indicates current NT time should be used
575 */
576bool SetBooleanArray(NT_Handle pubentry, std::span<const int> value, int64_t time = 0);
577
578/**
579 * Publish a default value.
580 * On reconnect, a default value will never be used in preference to a
581 * published value.
582 *
583 * @param pubentry publisher or entry handle
584 * @param defaultValue default value
585 */
586bool SetDefaultBooleanArray(NT_Handle pubentry, std::span<const int> defaultValue);
587
588/**
589 * Get the last published value.
590 * If no value has been published, returns the passed defaultValue.
591 *
592 * @param subentry subscriber or entry handle
593 * @param defaultValue default value to return if no value has been published
594 * @return value
595 */
596std::vector<int> GetBooleanArray(NT_Handle subentry, std::span<const int> defaultValue);
597
598/**
599 * Get the last published value along with its timestamp.
600 * If no value has been published, returns the passed defaultValue and a
601 * timestamp of 0.
602 *
603 * @param subentry subscriber or entry handle
604 * @param defaultValue default value to return if no value has been published
605 * @return timestamped value
606 */
607TimestampedBooleanArray GetAtomicBooleanArray(NT_Handle subentry, std::span<const int> defaultValue);
608
609/**
610 * Get an array of all value changes since the last call to ReadQueue.
611 * Also provides a timestamp for each value.
612 *
613 * @note The "poll storage" subscribe option can be used to set the queue
614 * depth.
615 *
616 * @param subentry subscriber or entry handle
617 * @return Array of timestamped values; empty array if no new changes have
618 * been published since the previous call.
619 */
620std::vector<TimestampedBooleanArray> ReadQueueBooleanArray(NT_Handle subentry);
621
622/**
623 * Get an array of all value changes since the last call to ReadQueue.
624 *
625 * @note The "poll storage" subscribe option can be used to set the queue
626 * depth.
627 *
628 * @param subentry subscriber or entry handle
629 * @return Array of values; empty array if no new changes have
630 * been published since the previous call.
631 */
632std::vector<std::vector<int>> ReadQueueValuesBooleanArray(NT_Handle subentry);
633
634std::span<int> GetBooleanArray(NT_Handle subentry, wpi::SmallVectorImpl<int>& buf, std::span<const int> defaultValue);
635
637 NT_Handle subentry,
639 std::span<const int> defaultValue);
640
641/** @} */
642
643/**
644 * Timestamped IntegerArray.
645 * @ingroup ntcore_cpp_handle_api
646 */
648
649/**
650 * Timestamped IntegerArray view (for SmallVector-taking functions).
651 * @ingroup ntcore_cpp_handle_api
652 */
654
655/**
656 * @defgroup ntcore_IntegerArray_func IntegerArray Functions
657 * @ingroup ntcore_cpp_handle_api
658 * @{
659 */
660
661/**
662 * Publish a new value.
663 *
664 * @param pubentry publisher or entry handle
665 * @param value value to publish
666 * @param time timestamp; 0 indicates current NT time should be used
667 */
668bool SetIntegerArray(NT_Handle pubentry, std::span<const int64_t> value, int64_t time = 0);
669
670/**
671 * Publish a default value.
672 * On reconnect, a default value will never be used in preference to a
673 * published value.
674 *
675 * @param pubentry publisher or entry handle
676 * @param defaultValue default value
677 */
678bool SetDefaultIntegerArray(NT_Handle pubentry, std::span<const int64_t> defaultValue);
679
680/**
681 * Get the last published value.
682 * If no value has been published, returns the passed defaultValue.
683 *
684 * @param subentry subscriber or entry handle
685 * @param defaultValue default value to return if no value has been published
686 * @return value
687 */
688std::vector<int64_t> GetIntegerArray(NT_Handle subentry, std::span<const int64_t> defaultValue);
689
690/**
691 * Get the last published value along with its timestamp.
692 * If no value has been published, returns the passed defaultValue and a
693 * timestamp of 0.
694 *
695 * @param subentry subscriber or entry handle
696 * @param defaultValue default value to return if no value has been published
697 * @return timestamped value
698 */
699TimestampedIntegerArray GetAtomicIntegerArray(NT_Handle subentry, std::span<const int64_t> defaultValue);
700
701/**
702 * Get an array of all value changes since the last call to ReadQueue.
703 * Also provides a timestamp for each value.
704 *
705 * @note The "poll storage" subscribe option can be used to set the queue
706 * depth.
707 *
708 * @param subentry subscriber or entry handle
709 * @return Array of timestamped values; empty array if no new changes have
710 * been published since the previous call.
711 */
712std::vector<TimestampedIntegerArray> ReadQueueIntegerArray(NT_Handle subentry);
713
714/**
715 * Get an array of all value changes since the last call to ReadQueue.
716 *
717 * @note The "poll storage" subscribe option can be used to set the queue
718 * depth.
719 *
720 * @param subentry subscriber or entry handle
721 * @return Array of values; empty array if no new changes have
722 * been published since the previous call.
723 */
724std::vector<std::vector<int64_t>> ReadQueueValuesIntegerArray(NT_Handle subentry);
725
726std::span<int64_t> GetIntegerArray(NT_Handle subentry, wpi::SmallVectorImpl<int64_t>& buf, std::span<const int64_t> defaultValue);
727
729 NT_Handle subentry,
731 std::span<const int64_t> defaultValue);
732
733/** @} */
734
735/**
736 * Timestamped FloatArray.
737 * @ingroup ntcore_cpp_handle_api
738 */
740
741/**
742 * Timestamped FloatArray view (for SmallVector-taking functions).
743 * @ingroup ntcore_cpp_handle_api
744 */
746
747/**
748 * @defgroup ntcore_FloatArray_func FloatArray Functions
749 * @ingroup ntcore_cpp_handle_api
750 * @{
751 */
752
753/**
754 * Publish a new value.
755 *
756 * @param pubentry publisher or entry handle
757 * @param value value to publish
758 * @param time timestamp; 0 indicates current NT time should be used
759 */
760bool SetFloatArray(NT_Handle pubentry, std::span<const float> value, int64_t time = 0);
761
762/**
763 * Publish a default value.
764 * On reconnect, a default value will never be used in preference to a
765 * published value.
766 *
767 * @param pubentry publisher or entry handle
768 * @param defaultValue default value
769 */
770bool SetDefaultFloatArray(NT_Handle pubentry, std::span<const float> defaultValue);
771
772/**
773 * Get the last published value.
774 * If no value has been published, returns the passed defaultValue.
775 *
776 * @param subentry subscriber or entry handle
777 * @param defaultValue default value to return if no value has been published
778 * @return value
779 */
780std::vector<float> GetFloatArray(NT_Handle subentry, std::span<const float> defaultValue);
781
782/**
783 * Get the last published value along with its timestamp.
784 * If no value has been published, returns the passed defaultValue and a
785 * timestamp of 0.
786 *
787 * @param subentry subscriber or entry handle
788 * @param defaultValue default value to return if no value has been published
789 * @return timestamped value
790 */
791TimestampedFloatArray GetAtomicFloatArray(NT_Handle subentry, std::span<const float> defaultValue);
792
793/**
794 * Get an array of all value changes since the last call to ReadQueue.
795 * Also provides a timestamp for each value.
796 *
797 * @note The "poll storage" subscribe option can be used to set the queue
798 * depth.
799 *
800 * @param subentry subscriber or entry handle
801 * @return Array of timestamped values; empty array if no new changes have
802 * been published since the previous call.
803 */
804std::vector<TimestampedFloatArray> ReadQueueFloatArray(NT_Handle subentry);
805
806/**
807 * Get an array of all value changes since the last call to ReadQueue.
808 *
809 * @note The "poll storage" subscribe option can be used to set the queue
810 * depth.
811 *
812 * @param subentry subscriber or entry handle
813 * @return Array of values; empty array if no new changes have
814 * been published since the previous call.
815 */
816std::vector<std::vector<float>> ReadQueueValuesFloatArray(NT_Handle subentry);
817
818std::span<float> GetFloatArray(NT_Handle subentry, wpi::SmallVectorImpl<float>& buf, std::span<const float> defaultValue);
819
821 NT_Handle subentry,
823 std::span<const float> defaultValue);
824
825/** @} */
826
827/**
828 * Timestamped DoubleArray.
829 * @ingroup ntcore_cpp_handle_api
830 */
832
833/**
834 * Timestamped DoubleArray view (for SmallVector-taking functions).
835 * @ingroup ntcore_cpp_handle_api
836 */
838
839/**
840 * @defgroup ntcore_DoubleArray_func DoubleArray Functions
841 * @ingroup ntcore_cpp_handle_api
842 * @{
843 */
844
845/**
846 * Publish a new value.
847 *
848 * @param pubentry publisher or entry handle
849 * @param value value to publish
850 * @param time timestamp; 0 indicates current NT time should be used
851 */
852bool SetDoubleArray(NT_Handle pubentry, std::span<const double> value, int64_t time = 0);
853
854/**
855 * Publish a default value.
856 * On reconnect, a default value will never be used in preference to a
857 * published value.
858 *
859 * @param pubentry publisher or entry handle
860 * @param defaultValue default value
861 */
862bool SetDefaultDoubleArray(NT_Handle pubentry, std::span<const double> defaultValue);
863
864/**
865 * Get the last published value.
866 * If no value has been published, returns the passed defaultValue.
867 *
868 * @param subentry subscriber or entry handle
869 * @param defaultValue default value to return if no value has been published
870 * @return value
871 */
872std::vector<double> GetDoubleArray(NT_Handle subentry, std::span<const double> defaultValue);
873
874/**
875 * Get the last published value along with its timestamp.
876 * If no value has been published, returns the passed defaultValue and a
877 * timestamp of 0.
878 *
879 * @param subentry subscriber or entry handle
880 * @param defaultValue default value to return if no value has been published
881 * @return timestamped value
882 */
883TimestampedDoubleArray GetAtomicDoubleArray(NT_Handle subentry, std::span<const double> defaultValue);
884
885/**
886 * Get an array of all value changes since the last call to ReadQueue.
887 * Also provides a timestamp for each value.
888 *
889 * @note The "poll storage" subscribe option can be used to set the queue
890 * depth.
891 *
892 * @param subentry subscriber or entry handle
893 * @return Array of timestamped values; empty array if no new changes have
894 * been published since the previous call.
895 */
896std::vector<TimestampedDoubleArray> ReadQueueDoubleArray(NT_Handle subentry);
897
898/**
899 * Get an array of all value changes since the last call to ReadQueue.
900 *
901 * @note The "poll storage" subscribe option can be used to set the queue
902 * depth.
903 *
904 * @param subentry subscriber or entry handle
905 * @return Array of values; empty array if no new changes have
906 * been published since the previous call.
907 */
908std::vector<std::vector<double>> ReadQueueValuesDoubleArray(NT_Handle subentry);
909
910std::span<double> GetDoubleArray(NT_Handle subentry, wpi::SmallVectorImpl<double>& buf, std::span<const double> defaultValue);
911
913 NT_Handle subentry,
915 std::span<const double> defaultValue);
916
917/** @} */
918
919/**
920 * Timestamped StringArray.
921 * @ingroup ntcore_cpp_handle_api
922 */
924
925/**
926 * @defgroup ntcore_StringArray_func StringArray Functions
927 * @ingroup ntcore_cpp_handle_api
928 * @{
929 */
930
931/**
932 * Publish a new value.
933 *
934 * @param pubentry publisher or entry handle
935 * @param value value to publish
936 * @param time timestamp; 0 indicates current NT time should be used
937 */
938bool SetStringArray(NT_Handle pubentry, std::span<const std::string> value, int64_t time = 0);
939
940/**
941 * Publish a default value.
942 * On reconnect, a default value will never be used in preference to a
943 * published value.
944 *
945 * @param pubentry publisher or entry handle
946 * @param defaultValue default value
947 */
948bool SetDefaultStringArray(NT_Handle pubentry, std::span<const std::string> defaultValue);
949
950/**
951 * Get the last published value.
952 * If no value has been published, returns the passed defaultValue.
953 *
954 * @param subentry subscriber or entry handle
955 * @param defaultValue default value to return if no value has been published
956 * @return value
957 */
958std::vector<std::string> GetStringArray(NT_Handle subentry, std::span<const std::string> defaultValue);
959
960/**
961 * Get the last published value along with its timestamp.
962 * If no value has been published, returns the passed defaultValue and a
963 * timestamp of 0.
964 *
965 * @param subentry subscriber or entry handle
966 * @param defaultValue default value to return if no value has been published
967 * @return timestamped value
968 */
969TimestampedStringArray GetAtomicStringArray(NT_Handle subentry, std::span<const std::string> defaultValue);
970
971/**
972 * Get an array of all value changes since the last call to ReadQueue.
973 * Also provides a timestamp for each value.
974 *
975 * @note The "poll storage" subscribe option can be used to set the queue
976 * depth.
977 *
978 * @param subentry subscriber or entry handle
979 * @return Array of timestamped values; empty array if no new changes have
980 * been published since the previous call.
981 */
982std::vector<TimestampedStringArray> ReadQueueStringArray(NT_Handle subentry);
983
984/**
985 * Get an array of all value changes since the last call to ReadQueue.
986 *
987 * @note The "poll storage" subscribe option can be used to set the queue
988 * depth.
989 *
990 * @param subentry subscriber or entry handle
991 * @return Array of values; empty array if no new changes have
992 * been published since the previous call.
993 */
994std::vector<std::vector<std::string>> ReadQueueValuesStringArray(NT_Handle subentry);
995
996/** @} */
997
998} // namespace nt
basic_string_view< char > string_view
Definition: core.h:501
bool SetBoolean(NT_Handle pubentry, bool value, int64_t time=0)
Publish a new value.
std::vector< int > ReadQueueValuesBoolean(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
std::vector< TimestampedBoolean > ReadQueueBoolean(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
TimestampedBoolean GetAtomicBoolean(NT_Handle subentry, bool defaultValue)
Get the last published value along with its timestamp.
bool SetDefaultBoolean(NT_Handle pubentry, bool defaultValue)
Publish a default value.
bool GetBoolean(NT_Handle subentry, bool defaultValue)
Get the last published value.
std::vector< std::vector< int > > ReadQueueValuesBooleanArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetBooleanArray(NT_Handle pubentry, std::span< const int > value, int64_t time=0)
Publish a new value.
TimestampedBooleanArray GetAtomicBooleanArray(NT_Handle subentry, std::span< const int > defaultValue)
Get the last published value along with its timestamp.
bool SetDefaultBooleanArray(NT_Handle pubentry, std::span< const int > defaultValue)
Publish a default value.
std::vector< int > GetBooleanArray(NT_Handle subentry, std::span< const int > defaultValue)
Get the last published value.
std::vector< TimestampedBooleanArray > ReadQueueBooleanArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetDefaultDouble(NT_Handle pubentry, double defaultValue)
Publish a default value.
TimestampedDouble GetAtomicDouble(NT_Handle subentry, double defaultValue)
Get the last published value along with its timestamp.
double GetDouble(NT_Handle subentry, double defaultValue)
Get the last published value.
bool SetDouble(NT_Handle pubentry, double value, int64_t time=0)
Publish a new value.
std::vector< double > ReadQueueValuesDouble(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
std::vector< TimestampedDouble > ReadQueueDouble(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
std::vector< TimestampedDoubleArray > ReadQueueDoubleArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetDoubleArray(NT_Handle pubentry, std::span< const double > value, int64_t time=0)
Publish a new value.
std::vector< std::vector< double > > ReadQueueValuesDoubleArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetDefaultDoubleArray(NT_Handle pubentry, std::span< const double > defaultValue)
Publish a default value.
std::vector< double > GetDoubleArray(NT_Handle subentry, std::span< const double > defaultValue)
Get the last published value.
TimestampedDoubleArray GetAtomicDoubleArray(NT_Handle subentry, std::span< const double > defaultValue)
Get the last published value along with its timestamp.
bool SetDefaultFloat(NT_Handle pubentry, float defaultValue)
Publish a default value.
std::vector< float > ReadQueueValuesFloat(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
TimestampedFloat GetAtomicFloat(NT_Handle subentry, float defaultValue)
Get the last published value along with its timestamp.
float GetFloat(NT_Handle subentry, float defaultValue)
Get the last published value.
bool SetFloat(NT_Handle pubentry, float value, int64_t time=0)
Publish a new value.
std::vector< TimestampedFloat > ReadQueueFloat(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
std::vector< float > GetFloatArray(NT_Handle subentry, std::span< const float > defaultValue)
Get the last published value.
bool SetDefaultFloatArray(NT_Handle pubentry, std::span< const float > defaultValue)
Publish a default value.
std::vector< TimestampedFloatArray > ReadQueueFloatArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetFloatArray(NT_Handle pubentry, std::span< const float > value, int64_t time=0)
Publish a new value.
std::vector< std::vector< float > > ReadQueueValuesFloatArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
TimestampedFloatArray GetAtomicFloatArray(NT_Handle subentry, std::span< const float > defaultValue)
Get the last published value along with its timestamp.
int64_t GetInteger(NT_Handle subentry, int64_t defaultValue)
Get the last published value.
bool SetDefaultInteger(NT_Handle pubentry, int64_t defaultValue)
Publish a default value.
std::vector< TimestampedInteger > ReadQueueInteger(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
TimestampedInteger GetAtomicInteger(NT_Handle subentry, int64_t defaultValue)
Get the last published value along with its timestamp.
bool SetInteger(NT_Handle pubentry, int64_t value, int64_t time=0)
Publish a new value.
std::vector< int64_t > ReadQueueValuesInteger(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetIntegerArray(NT_Handle pubentry, std::span< const int64_t > value, int64_t time=0)
Publish a new value.
std::vector< int64_t > GetIntegerArray(NT_Handle subentry, std::span< const int64_t > defaultValue)
Get the last published value.
std::vector< TimestampedIntegerArray > ReadQueueIntegerArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetDefaultIntegerArray(NT_Handle pubentry, std::span< const int64_t > defaultValue)
Publish a default value.
std::vector< std::vector< int64_t > > ReadQueueValuesIntegerArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
TimestampedIntegerArray GetAtomicIntegerArray(NT_Handle subentry, std::span< const int64_t > defaultValue)
Get the last published value along with its timestamp.
bool SetDefaultRaw(NT_Handle pubentry, std::span< const uint8_t > defaultValue)
Publish a default value.
std::vector< uint8_t > GetRaw(NT_Handle subentry, std::span< const uint8_t > defaultValue)
Get the last published value.
std::vector< std::vector< uint8_t > > ReadQueueValuesRaw(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
std::vector< TimestampedRaw > ReadQueueRaw(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetRaw(NT_Handle pubentry, std::span< const uint8_t > value, int64_t time=0)
Publish a new value.
TimestampedRaw GetAtomicRaw(NT_Handle subentry, std::span< const uint8_t > defaultValue)
Get the last published value along with its timestamp.
std::string GetString(NT_Handle subentry, std::string_view defaultValue)
Get the last published value.
std::vector< TimestampedString > ReadQueueString(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetDefaultString(NT_Handle pubentry, std::string_view defaultValue)
Publish a default value.
bool SetString(NT_Handle pubentry, std::string_view value, int64_t time=0)
Publish a new value.
std::vector< std::string > ReadQueueValuesString(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
TimestampedString GetAtomicString(NT_Handle subentry, std::string_view defaultValue)
Get the last published value along with its timestamp.
bool SetDefaultStringArray(NT_Handle pubentry, std::span< const std::string > defaultValue)
Publish a default value.
std::vector< TimestampedStringArray > ReadQueueStringArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
bool SetStringArray(NT_Handle pubentry, std::span< const std::string > value, int64_t time=0)
Publish a new value.
TimestampedStringArray GetAtomicStringArray(NT_Handle subentry, std::span< const std::string > defaultValue)
Get the last published value along with its timestamp.
std::vector< std::vector< std::string > > ReadQueueValuesStringArray(NT_Handle subentry)
Get an array of all value changes since the last call to ReadQueue.
std::vector< std::string > GetStringArray(NT_Handle subentry, std::span< const std::string > defaultValue)
Get the last published value.
unsigned int NT_Handle
Definition: ntcore_c.h:32
NetworkTables (ntcore) namespace.
Definition: MultiSubscriber.h:13
Definition: array.h:89
Definition: ntcore_cpp.h:26
Timestamped value.
Definition: ntcore_cpp_types.h:30
int64_t time
Time in local time base.
Definition: ntcore_cpp_types.h:38
int64_t serverTime
Time in server time base.
Definition: ntcore_cpp_types.h:43
Timestamped(int64_t time, int64_t serverTime, T value)
Definition: ntcore_cpp_types.h:32
Timestamped()=default
T value
Value.
Definition: ntcore_cpp_types.h:48