YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
AllJoyData.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6// Autogenerated by Thrift Compiler (0.14.1-yarped)
7//
8// This is an automatically generated file.
9// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
10
11#include <yarp/dev/AllJoyData.h>
12
13namespace yarp::dev {
14
15// Constructor with field values
16AllJoyData::AllJoyData(const std::vector<double>& ButtonDataVal,
17 const std::vector<double>& AxisDataVal,
18 const std::vector<std::int8_t>& HatsDataVal,
19 const std::vector<MultipleTouches>& TouchDataVal,
20 const std::vector<yarp::dev::StickData>& StickDataVal,
21 const std::vector<yarp::dev::TrackballData>& TrackballDataVal) :
22 WirePortable(),
23 ButtonDataVal(ButtonDataVal),
24 AxisDataVal(AxisDataVal),
25 HatsDataVal(HatsDataVal),
26 TouchDataVal(TouchDataVal),
27 StickDataVal(StickDataVal),
28 TrackballDataVal(TrackballDataVal)
29{
30}
31
32// Read structure on a Wire
34{
35 if (!read_ButtonDataVal(reader)) {
36 return false;
37 }
38 if (!read_AxisDataVal(reader)) {
39 return false;
40 }
41 if (!read_HatsDataVal(reader)) {
42 return false;
43 }
44 if (!read_TouchDataVal(reader)) {
45 return false;
46 }
47 if (!read_StickDataVal(reader)) {
48 return false;
49 }
50 if (!read_TrackballDataVal(reader)) {
51 return false;
52 }
53 if (reader.isError()) {
54 return false;
55 }
56 return true;
57}
58
59// Read structure on a Connection
61{
62 yarp::os::idl::WireReader reader(connection);
63 if (!reader.readListHeader(6)) {
64 return false;
65 }
66 if (!read(reader)) {
67 return false;
68 }
69 return true;
70}
71
72// Write structure on a Wire
74{
75 if (!write_ButtonDataVal(writer)) {
76 return false;
77 }
78 if (!write_AxisDataVal(writer)) {
79 return false;
80 }
81 if (!write_HatsDataVal(writer)) {
82 return false;
83 }
84 if (!write_TouchDataVal(writer)) {
85 return false;
86 }
87 if (!write_StickDataVal(writer)) {
88 return false;
89 }
90 if (!write_TrackballDataVal(writer)) {
91 return false;
92 }
93 if (writer.isError()) {
94 return false;
95 }
96 return true;
97}
98
99// Write structure on a Connection
101{
102 yarp::os::idl::WireWriter writer(connection);
103 if (!writer.writeListHeader(6)) {
104 return false;
105 }
106 if (!write(writer)) {
107 return false;
108 }
109 return true;
110}
111
112// Convert to a printable string
113std::string AllJoyData::toString() const
114{
116 if (!yarp::os::Portable::copyPortable(*this, b)) {
117 return {};
118 }
119 return b.toString();
120}
121
122// read ButtonDataVal field
123bool AllJoyData::read_ButtonDataVal(yarp::os::idl::WireReader& reader)
124{
125 if (reader.noMore()) {
126 reader.fail();
127 return false;
128 }
129 {
130 size_t _csize;
132 reader.readListBegin(_etype, _csize);
133 // WireReader removes BOTTLE_TAG_LIST from the tag
134 constexpr int expected_tag = ((BOTTLE_TAG_FLOAT64) & (~BOTTLE_TAG_LIST));
135 if constexpr (expected_tag != 0) {
136 if (_csize != 0 && _etype.code != expected_tag) {
137 return false;
138 }
139 }
140 ButtonDataVal.resize(_csize);
141 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(ButtonDataVal.data()), ButtonDataVal.size() * sizeof(double))) {
142 return false;
143 }
144 reader.readListEnd();
145 }
146 return true;
147}
148
149// write ButtonDataVal field
150bool AllJoyData::write_ButtonDataVal(const yarp::os::idl::WireWriter& writer) const
151{
152 if (!writer.writeListBegin(BOTTLE_TAG_FLOAT64, ButtonDataVal.size())) {
153 return false;
154 }
155 if (!writer.writeBlock(reinterpret_cast<const char*>(ButtonDataVal.data()), ButtonDataVal.size() * sizeof(double))) {
156 return false;
157 }
158 if (!writer.writeListEnd()) {
159 return false;
160 }
161 return true;
162}
163
164// read (nested) ButtonDataVal field
165bool AllJoyData::nested_read_ButtonDataVal(yarp::os::idl::WireReader& reader)
166{
167 if (reader.noMore()) {
168 reader.fail();
169 return false;
170 }
171 {
172 size_t _csize;
174 reader.readListBegin(_etype, _csize);
175 // WireReader removes BOTTLE_TAG_LIST from the tag
176 constexpr int expected_tag = ((BOTTLE_TAG_FLOAT64) & (~BOTTLE_TAG_LIST));
177 if constexpr (expected_tag != 0) {
178 if (_csize != 0 && _etype.code != expected_tag) {
179 return false;
180 }
181 }
182 ButtonDataVal.resize(_csize);
183 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(ButtonDataVal.data()), ButtonDataVal.size() * sizeof(double))) {
184 return false;
185 }
186 reader.readListEnd();
187 }
188 return true;
189}
190
191// write (nested) ButtonDataVal field
192bool AllJoyData::nested_write_ButtonDataVal(const yarp::os::idl::WireWriter& writer) const
193{
194 if (!writer.writeListBegin(BOTTLE_TAG_FLOAT64, ButtonDataVal.size())) {
195 return false;
196 }
197 if (!writer.writeBlock(reinterpret_cast<const char*>(ButtonDataVal.data()), ButtonDataVal.size() * sizeof(double))) {
198 return false;
199 }
200 if (!writer.writeListEnd()) {
201 return false;
202 }
203 return true;
204}
205
206// read AxisDataVal field
207bool AllJoyData::read_AxisDataVal(yarp::os::idl::WireReader& reader)
208{
209 if (reader.noMore()) {
210 reader.fail();
211 return false;
212 }
213 {
214 size_t _csize;
216 reader.readListBegin(_etype, _csize);
217 // WireReader removes BOTTLE_TAG_LIST from the tag
218 constexpr int expected_tag = ((BOTTLE_TAG_FLOAT64) & (~BOTTLE_TAG_LIST));
219 if constexpr (expected_tag != 0) {
220 if (_csize != 0 && _etype.code != expected_tag) {
221 return false;
222 }
223 }
224 AxisDataVal.resize(_csize);
225 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(AxisDataVal.data()), AxisDataVal.size() * sizeof(double))) {
226 return false;
227 }
228 reader.readListEnd();
229 }
230 return true;
231}
232
233// write AxisDataVal field
234bool AllJoyData::write_AxisDataVal(const yarp::os::idl::WireWriter& writer) const
235{
236 if (!writer.writeListBegin(BOTTLE_TAG_FLOAT64, AxisDataVal.size())) {
237 return false;
238 }
239 if (!writer.writeBlock(reinterpret_cast<const char*>(AxisDataVal.data()), AxisDataVal.size() * sizeof(double))) {
240 return false;
241 }
242 if (!writer.writeListEnd()) {
243 return false;
244 }
245 return true;
246}
247
248// read (nested) AxisDataVal field
249bool AllJoyData::nested_read_AxisDataVal(yarp::os::idl::WireReader& reader)
250{
251 if (reader.noMore()) {
252 reader.fail();
253 return false;
254 }
255 {
256 size_t _csize;
258 reader.readListBegin(_etype, _csize);
259 // WireReader removes BOTTLE_TAG_LIST from the tag
260 constexpr int expected_tag = ((BOTTLE_TAG_FLOAT64) & (~BOTTLE_TAG_LIST));
261 if constexpr (expected_tag != 0) {
262 if (_csize != 0 && _etype.code != expected_tag) {
263 return false;
264 }
265 }
266 AxisDataVal.resize(_csize);
267 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(AxisDataVal.data()), AxisDataVal.size() * sizeof(double))) {
268 return false;
269 }
270 reader.readListEnd();
271 }
272 return true;
273}
274
275// write (nested) AxisDataVal field
276bool AllJoyData::nested_write_AxisDataVal(const yarp::os::idl::WireWriter& writer) const
277{
278 if (!writer.writeListBegin(BOTTLE_TAG_FLOAT64, AxisDataVal.size())) {
279 return false;
280 }
281 if (!writer.writeBlock(reinterpret_cast<const char*>(AxisDataVal.data()), AxisDataVal.size() * sizeof(double))) {
282 return false;
283 }
284 if (!writer.writeListEnd()) {
285 return false;
286 }
287 return true;
288}
289
290// read HatsDataVal field
291bool AllJoyData::read_HatsDataVal(yarp::os::idl::WireReader& reader)
292{
293 if (reader.noMore()) {
294 reader.fail();
295 return false;
296 }
297 {
298 size_t _csize;
300 reader.readListBegin(_etype, _csize);
301 // WireReader removes BOTTLE_TAG_LIST from the tag
302 constexpr int expected_tag = ((BOTTLE_TAG_INT8) & (~BOTTLE_TAG_LIST));
303 if constexpr (expected_tag != 0) {
304 if (_csize != 0 && _etype.code != expected_tag) {
305 return false;
306 }
307 }
308 HatsDataVal.resize(_csize);
309 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(HatsDataVal.data()), HatsDataVal.size() * sizeof(std::int8_t))) {
310 return false;
311 }
312 reader.readListEnd();
313 }
314 return true;
315}
316
317// write HatsDataVal field
318bool AllJoyData::write_HatsDataVal(const yarp::os::idl::WireWriter& writer) const
319{
320 if (!writer.writeListBegin(BOTTLE_TAG_INT8, HatsDataVal.size())) {
321 return false;
322 }
323 if (!writer.writeBlock(reinterpret_cast<const char*>(HatsDataVal.data()), HatsDataVal.size() * sizeof(std::int8_t))) {
324 return false;
325 }
326 if (!writer.writeListEnd()) {
327 return false;
328 }
329 return true;
330}
331
332// read (nested) HatsDataVal field
333bool AllJoyData::nested_read_HatsDataVal(yarp::os::idl::WireReader& reader)
334{
335 if (reader.noMore()) {
336 reader.fail();
337 return false;
338 }
339 {
340 size_t _csize;
342 reader.readListBegin(_etype, _csize);
343 // WireReader removes BOTTLE_TAG_LIST from the tag
344 constexpr int expected_tag = ((BOTTLE_TAG_INT8) & (~BOTTLE_TAG_LIST));
345 if constexpr (expected_tag != 0) {
346 if (_csize != 0 && _etype.code != expected_tag) {
347 return false;
348 }
349 }
350 HatsDataVal.resize(_csize);
351 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(HatsDataVal.data()), HatsDataVal.size() * sizeof(std::int8_t))) {
352 return false;
353 }
354 reader.readListEnd();
355 }
356 return true;
357}
358
359// write (nested) HatsDataVal field
360bool AllJoyData::nested_write_HatsDataVal(const yarp::os::idl::WireWriter& writer) const
361{
362 if (!writer.writeListBegin(BOTTLE_TAG_INT8, HatsDataVal.size())) {
363 return false;
364 }
365 if (!writer.writeBlock(reinterpret_cast<const char*>(HatsDataVal.data()), HatsDataVal.size() * sizeof(std::int8_t))) {
366 return false;
367 }
368 if (!writer.writeListEnd()) {
369 return false;
370 }
371 return true;
372}
373
374// read TouchDataVal field
375bool AllJoyData::read_TouchDataVal(yarp::os::idl::WireReader& reader)
376{
377 if (reader.noMore()) {
378 reader.fail();
379 return false;
380 }
381 {
382 size_t _csize;
384 reader.readListBegin(_etype, _csize);
385 // WireReader removes BOTTLE_TAG_LIST from the tag
386 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
387 if constexpr (expected_tag != 0) {
388 if (_csize != 0 && _etype.code != expected_tag) {
389 return false;
390 }
391 }
392 TouchDataVal.resize(_csize);
393 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
394 if (reader.noMore()) {
395 reader.fail();
396 return false;
397 }
398 if (!reader.readNested(TouchDataVal[_i0])) {
399 reader.fail();
400 return false;
401 }
402 }
403 reader.readListEnd();
404 }
405 return true;
406}
407
408// write TouchDataVal field
409bool AllJoyData::write_TouchDataVal(const yarp::os::idl::WireWriter& writer) const
410{
411 if (!writer.writeListBegin(BOTTLE_TAG_LIST, TouchDataVal.size())) {
412 return false;
413 }
414 for (const auto& _item : TouchDataVal) {
415 if (!writer.writeNested(_item)) {
416 return false;
417 }
418 }
419 if (!writer.writeListEnd()) {
420 return false;
421 }
422 return true;
423}
424
425// read (nested) TouchDataVal field
426bool AllJoyData::nested_read_TouchDataVal(yarp::os::idl::WireReader& reader)
427{
428 if (reader.noMore()) {
429 reader.fail();
430 return false;
431 }
432 {
433 size_t _csize;
435 reader.readListBegin(_etype, _csize);
436 // WireReader removes BOTTLE_TAG_LIST from the tag
437 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
438 if constexpr (expected_tag != 0) {
439 if (_csize != 0 && _etype.code != expected_tag) {
440 return false;
441 }
442 }
443 TouchDataVal.resize(_csize);
444 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
445 if (reader.noMore()) {
446 reader.fail();
447 return false;
448 }
449 if (!reader.readNested(TouchDataVal[_i0])) {
450 reader.fail();
451 return false;
452 }
453 }
454 reader.readListEnd();
455 }
456 return true;
457}
458
459// write (nested) TouchDataVal field
460bool AllJoyData::nested_write_TouchDataVal(const yarp::os::idl::WireWriter& writer) const
461{
462 if (!writer.writeListBegin(BOTTLE_TAG_LIST, TouchDataVal.size())) {
463 return false;
464 }
465 for (const auto& _item : TouchDataVal) {
466 if (!writer.writeNested(_item)) {
467 return false;
468 }
469 }
470 if (!writer.writeListEnd()) {
471 return false;
472 }
473 return true;
474}
475
476// read StickDataVal field
477bool AllJoyData::read_StickDataVal(yarp::os::idl::WireReader& reader)
478{
479 if (reader.noMore()) {
480 reader.fail();
481 return false;
482 }
483 {
484 size_t _csize;
486 reader.readListBegin(_etype, _csize);
487 // WireReader removes BOTTLE_TAG_LIST from the tag
488 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
489 if constexpr (expected_tag != 0) {
490 if (_csize != 0 && _etype.code != expected_tag) {
491 return false;
492 }
493 }
494 StickDataVal.resize(_csize);
495 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
496 if (reader.noMore()) {
497 reader.fail();
498 return false;
499 }
500 if (!reader.readNested(StickDataVal[_i0])) {
501 reader.fail();
502 return false;
503 }
504 }
505 reader.readListEnd();
506 }
507 return true;
508}
509
510// write StickDataVal field
511bool AllJoyData::write_StickDataVal(const yarp::os::idl::WireWriter& writer) const
512{
513 if (!writer.writeListBegin(BOTTLE_TAG_LIST, StickDataVal.size())) {
514 return false;
515 }
516 for (const auto& _item : StickDataVal) {
517 if (!writer.writeNested(_item)) {
518 return false;
519 }
520 }
521 if (!writer.writeListEnd()) {
522 return false;
523 }
524 return true;
525}
526
527// read (nested) StickDataVal field
528bool AllJoyData::nested_read_StickDataVal(yarp::os::idl::WireReader& reader)
529{
530 if (reader.noMore()) {
531 reader.fail();
532 return false;
533 }
534 {
535 size_t _csize;
537 reader.readListBegin(_etype, _csize);
538 // WireReader removes BOTTLE_TAG_LIST from the tag
539 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
540 if constexpr (expected_tag != 0) {
541 if (_csize != 0 && _etype.code != expected_tag) {
542 return false;
543 }
544 }
545 StickDataVal.resize(_csize);
546 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
547 if (reader.noMore()) {
548 reader.fail();
549 return false;
550 }
551 if (!reader.readNested(StickDataVal[_i0])) {
552 reader.fail();
553 return false;
554 }
555 }
556 reader.readListEnd();
557 }
558 return true;
559}
560
561// write (nested) StickDataVal field
562bool AllJoyData::nested_write_StickDataVal(const yarp::os::idl::WireWriter& writer) const
563{
564 if (!writer.writeListBegin(BOTTLE_TAG_LIST, StickDataVal.size())) {
565 return false;
566 }
567 for (const auto& _item : StickDataVal) {
568 if (!writer.writeNested(_item)) {
569 return false;
570 }
571 }
572 if (!writer.writeListEnd()) {
573 return false;
574 }
575 return true;
576}
577
578// read TrackballDataVal field
579bool AllJoyData::read_TrackballDataVal(yarp::os::idl::WireReader& reader)
580{
581 if (reader.noMore()) {
582 reader.fail();
583 return false;
584 }
585 {
586 size_t _csize;
588 reader.readListBegin(_etype, _csize);
589 // WireReader removes BOTTLE_TAG_LIST from the tag
590 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
591 if constexpr (expected_tag != 0) {
592 if (_csize != 0 && _etype.code != expected_tag) {
593 return false;
594 }
595 }
596 TrackballDataVal.resize(_csize);
597 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
598 if (reader.noMore()) {
599 reader.fail();
600 return false;
601 }
602 if (!reader.readNested(TrackballDataVal[_i0])) {
603 reader.fail();
604 return false;
605 }
606 }
607 reader.readListEnd();
608 }
609 return true;
610}
611
612// write TrackballDataVal field
613bool AllJoyData::write_TrackballDataVal(const yarp::os::idl::WireWriter& writer) const
614{
615 if (!writer.writeListBegin(BOTTLE_TAG_LIST, TrackballDataVal.size())) {
616 return false;
617 }
618 for (const auto& _item : TrackballDataVal) {
619 if (!writer.writeNested(_item)) {
620 return false;
621 }
622 }
623 if (!writer.writeListEnd()) {
624 return false;
625 }
626 return true;
627}
628
629// read (nested) TrackballDataVal field
630bool AllJoyData::nested_read_TrackballDataVal(yarp::os::idl::WireReader& reader)
631{
632 if (reader.noMore()) {
633 reader.fail();
634 return false;
635 }
636 {
637 size_t _csize;
639 reader.readListBegin(_etype, _csize);
640 // WireReader removes BOTTLE_TAG_LIST from the tag
641 constexpr int expected_tag = ((BOTTLE_TAG_LIST) & (~BOTTLE_TAG_LIST));
642 if constexpr (expected_tag != 0) {
643 if (_csize != 0 && _etype.code != expected_tag) {
644 return false;
645 }
646 }
647 TrackballDataVal.resize(_csize);
648 for (size_t _i0 = 0; _i0 < _csize; ++_i0) {
649 if (reader.noMore()) {
650 reader.fail();
651 return false;
652 }
653 if (!reader.readNested(TrackballDataVal[_i0])) {
654 reader.fail();
655 return false;
656 }
657 }
658 reader.readListEnd();
659 }
660 return true;
661}
662
663// write (nested) TrackballDataVal field
664bool AllJoyData::nested_write_TrackballDataVal(const yarp::os::idl::WireWriter& writer) const
665{
666 if (!writer.writeListBegin(BOTTLE_TAG_LIST, TrackballDataVal.size())) {
667 return false;
668 }
669 for (const auto& _item : TrackballDataVal) {
670 if (!writer.writeNested(_item)) {
671 return false;
672 }
673 }
674 if (!writer.writeListEnd()) {
675 return false;
676 }
677 return true;
678}
679
680} // namespace yarp::dev
#define BOTTLE_TAG_INT8
Definition Bottle.h:19
#define BOTTLE_TAG_FLOAT64
Definition Bottle.h:26
#define BOTTLE_TAG_LIST
Definition Bottle.h:29
bool write(const yarp::os::idl::WireWriter &writer) const override
std::vector< double > ButtonDataVal
Definition AllJoyData.h:27
std::vector< yarp::dev::StickData > StickDataVal
Definition AllJoyData.h:31
std::vector< yarp::dev::TrackballData > TrackballDataVal
Definition AllJoyData.h:32
std::string toString() const
std::vector< double > AxisDataVal
Definition AllJoyData.h:28
std::vector< std::int8_t > HatsDataVal
Definition AllJoyData.h:29
std::vector< MultipleTouches > TouchDataVal
Definition AllJoyData.h:30
bool read(yarp::os::idl::WireReader &reader) override
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:217
An interface for reading from a network connection.
An interface for writing to a network connection.
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition Portable.cpp:16
IDL-friendly connection reader.
Definition WireReader.h:27
bool readNested(WirePortable &obj)
void readListBegin(yarp::os::idl::WireState &nstate, size_t &len)
bool readBlock(char *const data, size_t len)
IDL-friendly state.
Definition WireState.h:17
IDL-friendly connection writer.
Definition WireWriter.h:28
bool writeListHeader(int len) const
bool writeBlock(const char *data, size_t len) const
bool writeNested(const WirePortable &obj) const
bool writeListBegin(int tag, size_t len) const
For streams capable of holding different kinds of content, check what they actually have.