YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
main.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#include <yarp/os/all.h>
7#include <Demo.h>
8#include <DemoStructList.h>
9#include <DemoStructMap.h>
10#include <DemoStructExt.h>
11#include <SurfaceMeshWithBoundingBox.h>
12#include <Wrapping.h>
13#include <TestAnnotatedTypes.h>
14#include <TestSomeMoreTypes.h>
15#include <TestSomeLists.h>
16#include <TestSomeMaps.h>
17#include <MapOfLists.h>
18#if defined(THRIFT_INCLUDE_PREFIX) && defined(THRIFT_NO_NAMESPACE_PREFIX)
19# include <sub/directory/ClockServer.h>
20#elif defined(THRIFT_INCLUDE_PREFIX)
21# include <sub/directory/testing/ClockServer.h>
22#elif defined(THRIFT_NO_NAMESPACE_PREFIX)
23# include <ClockServer.h>
24#else
25# include <testing/ClockServer.h>
26#endif
27#include <Settings.h>
28
29#include <catch2/catch_amalgamated.hpp>
30
31using namespace yarp::os;
32using namespace yarp::os::impl;
33
34
35class Server : public Demo
36{
37private:
38 bool running;
39 bool closing;
40public:
42 running = false;
43 closing = false;
44 }
45
46 int32_t get_answer() override {
47 return 42;
48 }
49
50 int32_t add_one(const int32_t x) override {
51 INFO("adding 1 to " << x);
52 return x+1;
53 }
54
55 int32_t add_pair(const int32_t x, const int32_t y) override {
56 INFO("adding " << x << " and " << y);
57 return x+y;
58 }
59
60 void test_void(const int32_t x) override {
61 INFO("test void with " << x);
62 }
63
64 void test_1way(const int32_t x) override {
65 INFO("test oneway with " << x);
66 }
67
68 bool test_defaults(const int32_t x) override {
69 INFO("test defaults with " << x);
70 return (x==42);
71 }
72
73 std::vector<DemoEnum> test_enum_vector(const std::vector<DemoEnum> & x) override {
74 INFO("test_enum_vector");
75 std::vector<DemoEnum> result = x;
76 result.push_back(ENUM1);
77 return result;
78 }
79
81 const std::vector<int32_t> & lst,
82 const int32_t y) override {
83 INFO("test_partial with " << x << " and " << y);
84 YARP_UNUSED(lst);
85 return x+y;
86 }
87
89 if (x==ENUM1) {
90 return 42;
91 }
92 return 999;
93 }
94
95 int32_t test_longer_tail_defaults(const int32_t ignore, const DemoEnum _enum, const int32_t _int, const std::string& _string) override {
97 if (_enum==ENUM2 && _int==42 && _string=="Space Monkey from the Planet: Space") {
98 return 999;
99 }
100 return _int;
101 }
102
103
104
105 void do_start_a_service() override {
106 running = true;
107 while (!closing) {
108 INFO("Operating...");
109 Time::delay(0.1);
110 }
111 running = false;
112 }
113
114 bool do_check_for_service() override {
115 return running;
116 }
117
118 void do_stop_a_service() override {
119 closing = true;
120 while (running) {
121 Time::delay(0.1);
122 }
123 closing = false;
124 }
125
128 demoStructMap.mapValues["map_0"] = {0, 10};
129 demoStructMap.mapValues["map_1"] = {1, 11};
130 demoStructMap.mapValues["map_2"] = {2, 12};
131 demoStructMap.mapValues["map_3"] = {3, 13};
132 return demoStructMap;
133 }
134
135 bool this_is_a_const_method() const override {
136 return true;
137 }
138};
139
140
141class BrokenServer : public Demo
142{
143public:
144 int32_t get_answer() override {
145 return 42;
146 }
147};
148
149
150class WrappingServer : public Wrapping
151{
152public:
153 int32_t check(const yarp::os::Value& param) override {
154 if (param.isInt32()) {
155 return param.asInt32()+1;
156 }
157 if (param.asString()=="6*7") {
158 return 42;
159 }
160 return 9;
161 }
162
163 Bottle getBottle() override {
164 Bottle b("this is a test (bottle)");
165 return b;
166 }
167};
168
169class DemoStructCallbacks : public DemoStruct::Editor
170{
171public:
172 int wsx, dsx, wsy, dsy;
173
175 wsx = dsx = wsy = dsy = 0;
176 }
177
178 bool will_set_x() override {
179 INFO("will_set_x called, x is " << get_x());
180 wsx = get_x();
181 return true;
182 }
183 bool will_set_y() override {
184 INFO("will_set_y called, y is " << get_y());
185 wsy = get_y();
186 return true;
187 }
188 bool did_set_x() override {
189 INFO("did_set_x called, x is " << get_x());
190 dsx = get_x();
191 return true;
192 }
193 bool did_set_y() override {
194 INFO("did_set_y called, y is " << get_y());
195 dsy = get_y();
196 return true;
197 }
198};
199
200class ClientPeek : public PortReader
201{
202public:
203 bool read(ConnectionReader& con) override {
204 Bottle bot;
205 bot.read(con);
206 INFO("Got " << bot.toString());
207 return true;
208 }
209};
210
211class SettingsReceiver : public Settings::Editor
212{
213public:
216
218 reset();
219 }
220
221 void reset() {
222 called_will_set_id = false;
223 called_did_set_id = false;
224 }
225
226 bool will_set_id() override {
227 called_will_set_id = true;
228 return false;
229 }
230
231 bool did_set_id() override {
232 called_did_set_id = true;
233 return false;
234 }
235};
236
237
238
239TEST_CASE("IdlThriftTest", "[yarp::idl::thrift]")
240{
242
243 SECTION("add one")
244 {
246 Demo client;
247 client.yarp().attachAsClient(client_peek);
248 client.add_one(14);
249
251 Bottle bot("[add] [one] 14");
252 DummyConnector con;
253 bot.write(con.getWriter());
254 server.read(con.getReader());
255 bot.read(con.getReader());
256 INFO("Result is " << bot.toString());
257 CHECK(bot.get(0).asInt32() == 15);
258
259 bot.fromString("[add] [one] 15");
261 bot.write(con2.getWriter());
262 server.read(con2.getReader());
263 bot.read(con2.getReader());
264 INFO("Result is " << bot.toString());
265
266 CHECK(bot.get(0).asInt32() == 16);
267 }
268
269 SECTION("test void")
270 {
272 Demo client;
273 client.yarp().attachAsClient(client_peek);
274 client.test_void(14);
275 client.test_1way(14);
276
278 Bottle bot("[test] [void] 14");
279 DummyConnector con;
280 bot.write(con.getWriter());
281 server.read(con.getReader());
282 bot.read(con.getReader());
283 INFO("Result is " << bot.toString() << " (should be blank)");
284
285 CHECK(bot.size() == 0);
286 CHECK(!bot.isNull());
287 }
288
289 SECTION("test live")
290 {
291 Demo client;
293
296 REQUIRE(client_port.open("/client"));
297 REQUIRE(server_port.open("/server"));
300
301 int x = 0;
302 client.yarp().attachAsClient(client_port);
303 server.yarp().attachAsServer(server_port);
304 x = client.add_one(99);
305 INFO("Result " << x);
306 client.test_void(200);
307 client.test_void(201);
308 x = client.add_one(100);
309 INFO("Result " << x);
310 client.test_1way(200);
311 client.test_1way(201);
312 x = client.add_one(101);
313 INFO("Result " << x);
314
315 CHECK(x == 102);
316 }
317
318 SECTION("test live rpc")
319 {
320 Demo client;
322
325 REQUIRE(client_port.open("/client"));
326 REQUIRE(server_port.open("/server"));
329
330 client.yarp().attachAsClient(client_port);
331 server.yarp().attachAsServer(server_port);
332
333 // Check regular RPC works, even with oneways
334
335 Bottle cmd;
336 Bottle reply;
337
338 cmd.fromString("[add] [one] 5");
339 reply.clear();
340 client_port.write(cmd,reply);
341 INFO("cmd " << cmd.toString() << " reply " << reply.toString());
342
343 CHECK(reply.get(0).asInt32() == 6);
344
345 cmd.fromString("[test] [void] 5");
346 reply.clear();
347 client_port.write(cmd,reply);
348 INFO("cmd " << cmd.toString() << " reply " << reply.toString());
349
350 cmd.fromString("[add] [one] 6");
351 reply.clear();
352 client_port.write(cmd,reply);
353 INFO("cmd " << cmd.toString() << " reply " << reply.toString());
354
355 CHECK(reply.get(0).asInt32() == 7);
356
357 cmd.fromString("[test] [1way] 5");
358 reply.clear();
359 client_port.write(cmd,reply);
360 INFO("cmd " << cmd.toString() << " reply " << reply.toString() << " (reply will be empty)");
361
362 cmd.fromString("[add] [one] 7");
363 reply.clear();
364 client_port.write(cmd,reply);
365 INFO("cmd " << cmd.toString() << " reply " << reply.toString());
366
367 CHECK(reply.get(0).asInt32() == 8);
368 }
369
370 SECTION("test enums")
371 {
372 Demo client;
374
377 REQUIRE(client_port.open("/client"));
378 REQUIRE(server_port.open("/server"));
381 client.yarp().attachAsClient(client_port);
382 server.yarp().attachAsServer(server_port);
383
384 std::vector<DemoEnum> lst1;
385 lst1.push_back(ENUM1);
386 lst1.push_back(ENUM2);
387 std::vector<DemoEnum> lst2 = client.test_enum_vector(lst1);
388 INFO("lst1 " << lst1.size() << " lst2 " << lst2.size());
389
390 CHECK(lst2.size() == 3);
391 CHECK(lst1[0] == lst2[0]);
392 CHECK(lst1[1] == lst2[1]);
393 }
394
395 SECTION("test defaults")
396 {
397 Demo client;
399
402 client_port.open("/client");
403 REQUIRE(server_port.open("/server"));
406 client.yarp().attachAsClient(client_port);
407 server.yarp().attachAsServer(server_port);
408
409 CHECK(client.test_defaults());
410 CHECK_FALSE(client.test_defaults(14));
411 }
412
413 SECTION("test partial")
414 {
416
419 CHECK(client_port.open("/client"));
420 REQUIRE(server_port.open("/server"));
423 server.yarp().attachAsServer(server_port);
424
425 Bottle msg;
426 Bottle reply;
427 msg.fromString("add pair 4 3");
428 client_port.write(msg,reply);
429 INFO(msg.toString() << " -> " << reply.toString());
430
431 CHECK(reply.get(0).asInt32() == 7);
432
433 msg.fromString("add pair 4");
434 client_port.write(msg,reply);
435 INFO("(incomplete) " << msg.toString() << " -> " << reply.toString());
436 CHECK(reply.get(0).asVocab32() == yarp::os::createVocab32('f','a','i','l'));
437
438 msg.fromString("add pair");
439 reply.fromString("0");
440 client_port.write(msg,reply);
441 INFO("(incomplete) " << msg.toString() << " -> " << reply.toString());
442 CHECK(reply.get(0).asVocab32() == yarp::os::createVocab32('f','a','i','l'));
443
444 msg.fromString("add");
445 reply.fromString("0");
446 client_port.write(msg,reply);
447 INFO("(incomplete) " << msg.toString() << " -> " << reply.toString());
448 CHECK(reply.get(0).asVocab32() == yarp::os::createVocab32('f','a','i','l'));
449
450 msg.fromString("");
451 reply.fromString("0");
452 client_port.write(msg,reply);
453 INFO("(incomplete) " << msg.toString() << " -> " << reply.toString());
454 CHECK(reply.get(0).asVocab32() == yarp::os::createVocab32('f','a','i','l'));
455
456 msg.fromString("add pair 10 20");
457 reply.fromString("0");
458 client_port.write(msg,reply);
459 INFO(msg.toString() << " -> " << reply.toString());
460 CHECK(reply.get(0).asInt32() == 30);
461
462 msg.fromString("test partial 10 (40 50 60) 5");
463 reply.fromString("0");
464 client_port.write(msg,reply);
465 INFO(msg.toString() << " -> " << reply.toString());
466 CHECK(reply.get(0).asInt32() == 15);
467
468 msg.fromString("test partial 10 (40 50)");
469 reply.fromString("0");
470 client_port.write(msg,reply);
471 INFO(msg.toString() << " -> " << reply.toString());
472 CHECK(reply.get(0).asVocab32() == yarp::os::createVocab32('f','a','i','l'));
473 }
474
475 SECTION("test defaults with rpc")
476 {
478
481 REQUIRE(client_port.open("/client"));
482 REQUIRE(server_port.open("/server"));
485 server.yarp().attachAsServer(server_port);
486
487 Bottle msg;
488 Bottle reply;
489 msg.fromString("test_tail_defaults");
490 client_port.write(msg,reply);
491 INFO(msg.toString() << " -> " << reply.toString());
492 CHECK(reply.get(0).asInt32() == 42);
493
494 msg.fromString("test_tail_defaults 55");
495 client_port.write(msg,reply);
496 INFO(msg.toString() << " -> " << reply.toString());
497 CHECK(reply.get(0).asInt32() == 999);
498
499 msg.fromString("test longer tail defaults");
500 client_port.write(msg,reply);
501 INFO(msg.toString() << " -> " << reply.toString());
502 CHECK(reply.get(0).asVocab32() == yarp::os::createVocab32('f','a','i','l'));
503
504 msg.fromString("test longer tail defaults 888");
505 client_port.write(msg,reply);
506 INFO(msg.toString() << " -> " << reply.toString());
507 CHECK(reply.get(0).asInt32() == 999);
508
509 msg.fromString("test longer tail defaults 888 ENUM2 47");
510 client_port.write(msg,reply);
511 INFO(msg.toString() << " -> " << reply.toString());
512 CHECK(reply.get(0).asInt32() == 47);
513 }
514
515 SECTION("test names with spaces")
516 {
518
521 REQUIRE(client_port.open("/client"));
522 REQUIRE(server_port.open("/server"));
525 server.yarp().attachAsServer(server_port);
526
527 Bottle msg;
528 Bottle reply;
529 msg.fromString("add_one 42");
530 client_port.write(msg,reply);
531 INFO(msg.toString() << " -> " << reply.toString());
532 CHECK(reply.get(0).asInt32() == 43);
533
534 msg.fromString("add one 52");
535 client_port.write(msg,reply);
536 INFO(msg.toString() << " -> " << reply.toString());
537 CHECK(reply.get(0).asInt32() == 53);
538
539 msg.fromString("get_answer");
540 client_port.write(msg,reply);
541 INFO(msg.toString() << " -> " << reply.toString());
542 CHECK(reply.get(0).asInt32() == 42);
543
544 msg.fromString("get answer");
545 client_port.write(msg,reply);
546 INFO(msg.toString() << " -> " << reply.toString());
547 CHECK(reply.get(0).asInt32() == 42);
548 }
549
550 SECTION("test surface mesh")
551 {
553 Box3D bb;
554 mesh.meshName = "testing";
555 bb.corners.push_back(PointXYZ(1,2,3));
557
558 Bottle bot;
559 bot.read(obj);
560
562 bot.write(obj2);
563 Bottle bot2;
564 bot2.read(obj2);
565
566 INFO("mesh copy: " << bot.toString() << " -> " << bot2.toString());
567
568 CHECK(obj2.mesh.meshName == obj.mesh.meshName);
569 CHECK(obj2.boundingBox.corners.size() == obj.boundingBox.corners.size());
570 CHECK(bot == bot2);
571 }
572
573 SECTION("test wrapping")
574 {
575 Wrapping client;
577
580 REQUIRE(client_port.open("/client"));
581 REQUIRE(server_port.open("/server"));
584
585 int x = 0;
586 client.yarp().attachAsClient(client_port);
587 server.yarp().attachAsServer(server_port);
588 x = client.check(Value(99));
589 INFO("Result " << x);
590 CHECK(x == 100);
591 x = client.check(Value("6*7"));
592 INFO("Result " << x);
593 CHECK(x == 42);
594 x = client.check(Value("test"));
595 INFO("Result " << x);
596 CHECK(x == 9);
597
598 Bottle b = client.getBottle();
599 INFO("Bottle is " << b.toString());
600 CHECK(b.size() == 5);
601
602 Bottle cmd;
603 Bottle reply;
604 cmd.fromString("getBottle");
605 client_port.write(cmd,reply);
606 INFO("Bottle is " << reply.get(0).toString());
607 CHECK(reply.size() == 5);
608 }
609
610 SECTION("test_missing_method")
611 {
612 Demo client;
614
617 REQUIRE(client_port.open("/client"));
618 REQUIRE(server_port.open("/server"));
621
622 int x = 0;
623 client.yarp().attachAsClient(client_port);
624 server.yarp().attachAsServer(server_port);
625 x = client.get_answer();
626 INFO("Answer " << x);
627 CHECK(x == 42);
628
629 x = client.add_one(88);
630 INFO("AddOne gives " << x);
631 CHECK(x != 89);
632 }
633
634 SECTION("test unwrap")
635 {
637 s.lst.push_back(DemoStruct(5,10));
638 s.lst.push_back(DemoStruct(9,900));
639 Bottle b;
640 b.read(s);
641 INFO("Wrapped: " << b.toString());
642 CHECK(b.size() == 1);
643
644 DemoStructList::unwrapped s2;
645 s2.content.lst = s.lst;
646 b.read(s2);
647 INFO("Wrapped: " << b.toString());
648 CHECK(b.size() == 2);
649 }
650
651 SECTION("test tostring")
652 {
654 s.lst.push_back(DemoStruct(5,10));
655 s.lst.push_back(DemoStruct(9,900));
656 INFO("String: " << s.toString());
657 CHECK(s.toString() == "((5 10) (9 900))");
658
659 DemoStruct d;
660 d.x = 10;
661 d.y = 20;
662 INFO("String: " << d.toString());
663 CHECK(d.toString() == "10 20");
664 }
665
666 SECTION("test editor")
667 {
668 DemoStruct d;
669 d.x = 0;
670 d.y = 0;
671 DemoStruct::Editor e;
672 e.edit(d,false);
673 e.set_x(15);
674 Bottle b;
675 b.read(e);
676 INFO(">>> set_x -> " << b.toString());
677 CHECK(b.size() == 2);
678 REQUIRE(b.get(1).asList() != nullptr);
679 CHECK(b.get(1).asList()->get(0).asString() == "set");
680 CHECK(b.get(1).asList()->get(1).asString() == "x");
681 CHECK(b.get(1).asList()->get(2).asInt32() == 15);
682
683 e.clean();
684 e.set_y(30);
685 b.read(e);
686 INFO(">>> set_y -> " << b.toString());
687 CHECK(b.size() == 2);
688 REQUIRE(b.get(1).asList() != nullptr);
689 CHECK(b.get(1).asList()->get(1).asString() == "y");
690 CHECK(b.get(1).asList()->get(2).asInt32() ==30);
691
692 e.clean();
693 e.set_x(1);
694 e.set_y(2);
695 b.read(e);
696 INFO(">>> set_x set_y -> " << b.toString());
697 CHECK(b.size() == 3);
698 REQUIRE(b.get(1).asList() != nullptr);
699 REQUIRE(b.get(2).asList() != nullptr);
700 CHECK(b.get(1).asList()->get(1).asString() == "x");
701 CHECK(b.get(1).asList()->get(2).asInt32() == 1);
702 CHECK(b.get(2).asList()->get(1).asString() == "y");
703 CHECK(b.get(2).asList()->get(2).asInt32() == 2);
704
705 DemoStruct d2;
706 DemoStruct::Editor e2;
707 e2.edit(d2,false);
708 d2.x = 99;
709 d2.y = 99;
710 e.clean();
711 e.set_y(30);
713 CHECK(d2.x == 99);
714 CHECK(d2.y == 30);
715
717 c.edit(d2,false);
718 d2.x = 99;
719 d2.y = 99;
720 c.clean();
721 c.set_y(30);
722 CHECK(c.wsy == 99);
723 CHECK(c.dsy == 30);
724
725 DemoStruct d3;
726 d3.x = 0;
727 d3.y = 0;
729 c2.edit(d3,false);
731 CHECK(c2.wsy == 0);
732 CHECK(c2.dsy == 30);
733 }
734
735
736 SECTION("test list editor")
737 {
739 d.int_list.resize(5);
740 DemoStructExt::Editor e;
741 e.edit(d,false);
742 e.set_int_list(4,15);
743 Bottle b;
744 b.read(e);
745 INFO(">>> set_int_list -> " << b.toString());
746 CHECK(b.size() == 2);
747 REQUIRE(b.get(1).asList() != nullptr);
748 CHECK(b.get(1).asList()->get(1).asString() == "int_list");
749 REQUIRE(b.get(1).asList()->get(2).asList() != nullptr);
750 CHECK(b.get(1).asList()->get(2).asList()->get(4).asInt32() == 15);
751 }
752
753 SECTION("test general help")
754 {
756 Bottle bot("[help]");
757 DummyConnector con;
758 bot.write(con.getWriter());
759 server.read(con.getReader());
760 bot.read(con.getReader());
761 INFO("Service general help is " << bot.toString());
762 std::string help = bot.toString();
763 CHECK(help.find("get_answer") != std::string::npos);
764 }
765
766 SECTION("test specific help")
767 {
769 Bottle bot("[help] get_answer");
770 DummyConnector con;
771 bot.write(con.getWriter());
772 server.read(con.getReader());
773 bot.read(con.getReader());
774 INFO("Service specific help is " << bot.toString());
775 std::string help = bot.toString();
776 CHECK(help.find("gets the answer") != std::string::npos);
777 }
778
779 SECTION("test structure general help")
780 {
781 DemoStruct d;
782 DemoStruct::Editor e;
783 e.edit(d,false);
784 Bottle bot("help");
785 DummyConnector con;
786
787 bot.write(con.getWriter());
788 e.read(con.getReader());
789 bot.read(con.getReader());
790 INFO("Structure general help is " << bot.toString());
791 std::string help = bot.toString();
792 CHECK(help.find('x') != std::string::npos);
793 }
794
795 SECTION("test structure specific help")
796 {
797 DemoStruct d;
798 DemoStruct::Editor e;
799 e.edit(d,false);
800 Bottle bot("help x");
801 DummyConnector con;
802
803 bot.write(con.getWriter());
804 e.read(con.getReader());
805 bot.read(con.getReader());
806 INFO("Structure specific help is " << bot.toString());
807 std::string help = bot.toString();
808 CHECK(help.find("this is the \\\"x\\\" part") != std::string::npos);
809 }
810
811 SECTION("test primitives")
812 {
815 Bottle tmp;
816 a.a_bool = true;
817 a.a_i8 = 8;
818 a.a_i16 = 16;
819 a.a_i32 = 32;
820 a.a_i64 = 64;
821 a.a_double = 0.64;
822 a.a_string = "A string";
823
824 REQUIRE(tmp.read(a));
825 REQUIRE(tmp.write(b));
826
827 CHECK(a.a_bool == b.a_bool);
828 CHECK(a.a_i16 == b.a_i16);
829 CHECK(a.a_i32 == b.a_i32);
830 CHECK(a.a_i64 == b.a_i64);
831 CHECK(a.a_double == b.a_double);
832 CHECK(a.a_string == b.a_string);
833
834 }
835
836 SECTION("test lists")
837 {
840 Bottle tmp;
841
842 a.a_list_of_bool = std::vector<bool>({true, false});
843 a.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
844 a.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
845 a.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
846 a.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
847 a.a_list_of_double = std::vector<double>({-0.64, 0.64});
848 a.a_list_of_string = std::vector<std::string>({"A string", "Another string"});
849 a.a_list_of_binary.resize(2);
850 a.a_list_of_binary[0].resize(6);
851 memset(a.a_list_of_binary[0].data(), 0, a.a_list_of_binary[0].size());
852 a.a_list_of_binary[0][a.a_list_of_binary[0].size() - 1] = 'C';
853 a.a_list_of_binary[1].resize(12);
854 memset(a.a_list_of_binary[1].data(), 0, a.a_list_of_binary[1].size());
855 a.a_list_of_binary[1][a.a_list_of_binary[1].size() - 1] = 'D';
856
857 a.a_list_of_list_of_double.resize(2);
858 a.a_list_of_list_of_double[0] = std::vector<double>({-0.64, 0.64});
859 a.a_list_of_list_of_double[1] = std::vector<double>({-0.32, 0.32});
860
861 REQUIRE(tmp.read(a));
862 REQUIRE(tmp.write(b));
863
864 CHECK(b.a_list_of_bool.size() == a.a_list_of_bool.size());
865 CHECK(b.a_list_of_bool[0] == a.a_list_of_bool[0]);
866 CHECK(b.a_list_of_bool[1] == a.a_list_of_bool[1]);
867 CHECK(b.a_list_of_i8.size() == a.a_list_of_i8.size());
868 CHECK(b.a_list_of_i8[0] == a.a_list_of_i8[0]);
869 CHECK(b.a_list_of_i8[1] == a.a_list_of_i8[1]);
870 CHECK(b.a_list_of_i16.size() == a.a_list_of_i16.size());
871 CHECK(b.a_list_of_i16[0] == a.a_list_of_i16[0]);
872 CHECK(b.a_list_of_i16[1] == a.a_list_of_i16[1]);
873 CHECK(b.a_list_of_i32.size() == a.a_list_of_i32.size());
874 CHECK(b.a_list_of_i32[0] == a.a_list_of_i32[0]);
875 CHECK(b.a_list_of_i32[1] == a.a_list_of_i32[1]);
876 CHECK(b.a_list_of_i64.size() == a.a_list_of_i64.size());
877 CHECK(b.a_list_of_i64[0] == a.a_list_of_i64[0]);
878 CHECK(b.a_list_of_i64[1] == a.a_list_of_i64[1]);
879 CHECK(b.a_list_of_double.size() == a.a_list_of_double.size());
880 CHECK(b.a_list_of_double[0] == a.a_list_of_double[0]);
881 CHECK(b.a_list_of_double[1] == a.a_list_of_double[1]);
882 CHECK(b.a_list_of_string.size() == a.a_list_of_string.size());
883 CHECK(b.a_list_of_string[0] == a.a_list_of_string[0]);
884 CHECK(b.a_list_of_string[1] == a.a_list_of_string[1]);
885 CHECK(b.a_list_of_binary.size() == a.a_list_of_binary.size());
886 CHECK(b.a_list_of_binary[0].size() == 6);
887 CHECK(b.a_list_of_binary[1].size() == 12);
888 CHECK(b.a_list_of_binary[0][5] == 'C');
889 CHECK(b.a_list_of_binary[1][11] == 'D');
890
891 CHECK(b.a_list_of_list_of_double.size() == a.a_list_of_list_of_double.size());
892 CHECK(b.a_list_of_list_of_double[0].size() == a.a_list_of_list_of_double[0].size());
893 CHECK(b.a_list_of_list_of_double[0][0] == a.a_list_of_list_of_double[0][0]);
894 CHECK(b.a_list_of_list_of_double[0][1] == a.a_list_of_list_of_double[0][1]);
895 CHECK(b.a_list_of_list_of_double[1].size() == a.a_list_of_list_of_double[1].size());
896 CHECK(b.a_list_of_list_of_double[1][0] == a.a_list_of_list_of_double[1][0]);
897 CHECK(b.a_list_of_list_of_double[1][1] == a.a_list_of_list_of_double[1][1]);
898 }
899
900 SECTION("test some maps")
901 {
902 TestSomeMaps a;
903 TestSomeMaps b;
904 Bottle tmp;
905
906 a.a_map_of_list_of_double["first"] = std::vector<double>({-0.64, 0.64});
907 a.a_map_of_list_of_double["second"] = std::vector<double>({-0.32, 0.32});
908 a.a_map_of_list_of_list_of_double["first"].push_back(std::vector<double>({-0.16, 0.16}));
909 a.a_map_of_list_of_list_of_double["first"].push_back(std::vector<double>({-0.08, 0.08}));
910 a.a_map_of_list_of_list_of_double["second"].push_back(std::vector<double>({-0.04, 0.04}));
911 a.a_map_of_list_of_list_of_double["second"].push_back(std::vector<double>({-0.02, 0.02}));
912
913 a.a_list_of_maps_of_doubles.push_back(std::map<std::string, double>({{"0first", 0.1}, {"0second", 0.2}}));
914 a.a_list_of_maps_of_doubles.push_back(std::map<std::string, double>({{"1first", 1.1}, {"1second", 1.2}}));
915
916 REQUIRE(tmp.read(a));
917 REQUIRE(tmp.write(b));
918
919 CHECK(b.a_map_of_list_of_double.size() == a.a_map_of_list_of_double.size());
920 CHECK(b.a_map_of_list_of_double["first"].size() == a.a_map_of_list_of_double["first"].size());
921 CHECK(b.a_map_of_list_of_double["first"][0] == a.a_map_of_list_of_double["first"][0]);
922 CHECK(b.a_map_of_list_of_double["first"][1] == a.a_map_of_list_of_double["first"][1]);
923 CHECK(b.a_map_of_list_of_double["second"].size() == a.a_map_of_list_of_double["second"].size());
924 CHECK(b.a_map_of_list_of_double["second"][0] == a.a_map_of_list_of_double["second"][0]);
925 CHECK(b.a_map_of_list_of_double["second"][1] == a.a_map_of_list_of_double["second"][1]);
926
927 CHECK(b.a_map_of_list_of_list_of_double.size() == a.a_map_of_list_of_list_of_double.size());
928 CHECK(b.a_map_of_list_of_list_of_double["first"].size() == a.a_map_of_list_of_list_of_double["first"].size());
929 CHECK(b.a_map_of_list_of_list_of_double["first"][0].size() == a.a_map_of_list_of_list_of_double["first"][0].size());
930 CHECK(b.a_map_of_list_of_list_of_double["first"][0][0] == a.a_map_of_list_of_list_of_double["first"][0][0]);
931 CHECK(b.a_map_of_list_of_list_of_double["first"][0][1] == a.a_map_of_list_of_list_of_double["first"][0][1]);
932 CHECK(b.a_map_of_list_of_list_of_double["first"][1].size() == a.a_map_of_list_of_list_of_double["first"][1].size());
933 CHECK(b.a_map_of_list_of_list_of_double["first"][1][0] == a.a_map_of_list_of_list_of_double["first"][1][0]);
934 CHECK(b.a_map_of_list_of_list_of_double["first"][1][1] == a.a_map_of_list_of_list_of_double["first"][1][1]);
935 CHECK(b.a_map_of_list_of_list_of_double["second"].size() == a.a_map_of_list_of_list_of_double["second"].size());
936 CHECK(b.a_map_of_list_of_list_of_double["second"][0].size() == a.a_map_of_list_of_list_of_double["second"][0].size());
937 CHECK(b.a_map_of_list_of_list_of_double["second"][0][0] == a.a_map_of_list_of_list_of_double["second"][0][0]);
938 CHECK(b.a_map_of_list_of_list_of_double["second"][0][1] == a.a_map_of_list_of_list_of_double["second"][0][1]);
939 CHECK(b.a_map_of_list_of_list_of_double["second"][1].size() == a.a_map_of_list_of_list_of_double["second"][1].size());
940 CHECK(b.a_map_of_list_of_list_of_double["second"][1][0] == a.a_map_of_list_of_list_of_double["second"][1][0]);
941 CHECK(b.a_map_of_list_of_list_of_double["second"][1][1] == a.a_map_of_list_of_list_of_double["second"][1][1]);
942
943 CHECK(b.a_list_of_maps_of_doubles.size() == a.a_list_of_maps_of_doubles.size());
944 CHECK(b.a_list_of_maps_of_doubles[0]["0first"] == a.a_list_of_maps_of_doubles[0]["0first"]);
945 CHECK(b.a_list_of_maps_of_doubles[0]["0second"] == a.a_list_of_maps_of_doubles[0]["0second"]);
946 CHECK(b.a_list_of_maps_of_doubles[1]["1first"] == a.a_list_of_maps_of_doubles[1]["1first"]);
947 CHECK(b.a_list_of_maps_of_doubles[1]["1second"] == a.a_list_of_maps_of_doubles[1]["1second"]);
948 }
949
950 SECTION("test lists with previous data")
951 {
954 Bottle tmp;
955
956 a.a_list_of_bool = std::vector<bool>({true, false});
957 a.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
958 a.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
959 a.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
960 a.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
961 a.a_list_of_double = std::vector<double>({-0.64, 0.64});
962 a.a_list_of_string = std::vector<std::string>({"A string", "Another string"});
963 a.a_list_of_binary.resize(2);
964 a.a_list_of_binary[0].resize(6);
965 memset(a.a_list_of_binary[0].data(), 0, a.a_list_of_binary[0].size());
966 a.a_list_of_binary[0][a.a_list_of_binary[0].size() - 1] = 'C';
967 a.a_list_of_binary[1].resize(12);
968 memset(a.a_list_of_binary[1].data(), 0, a.a_list_of_binary[1].size());
969 a.a_list_of_binary[1][a.a_list_of_binary[1].size() - 1] = 'D';
970
971 b.a_list_of_bool = std::vector<bool>({false, true, false});
972 b.a_list_of_i8 = std::vector<std::int8_t>({8, -8, 8});
973 b.a_list_of_i16 = std::vector<std::int16_t>({16, -16, 16});
974 b.a_list_of_i32 = std::vector<std::int32_t>({32, -32, 32});
975 b.a_list_of_i64 = std::vector<std::int64_t>({64, -64, 64});
976 b.a_list_of_double = std::vector<double>({0.64, -0.64, 0.64});
977 b.a_list_of_string = std::vector<std::string>({"The string", "A string", "Another string"});
978 b.a_list_of_binary.resize(3);
979 b.a_list_of_binary[0].resize(12);
980 memset(b.a_list_of_binary[0].data(), 0, b.a_list_of_binary[0].size());
981 b.a_list_of_binary[0][b.a_list_of_binary[0].size() - 1] = 'E';
982 b.a_list_of_binary[1].resize(6);
983 memset(b.a_list_of_binary[1].data(), 0, b.a_list_of_binary[1].size());
984 b.a_list_of_binary[1][b.a_list_of_binary[1].size() - 1] = 'F';
985 b.a_list_of_binary[2].resize(12);
986 memset(b.a_list_of_binary[2].data(), 0, b.a_list_of_binary[2].size());
987 b.a_list_of_binary[2][b.a_list_of_binary[2].size() - 1] = 'G';
988
989 REQUIRE(tmp.read(a));
990 REQUIRE(tmp.write(b));
991
992 CHECK(b.a_list_of_bool.size() == a.a_list_of_bool.size());
993 CHECK(b.a_list_of_bool[0] == a.a_list_of_bool[0]);
994 CHECK(b.a_list_of_bool[1] == a.a_list_of_bool[1]);
995 CHECK(b.a_list_of_i8.size() == a.a_list_of_i8.size());
996 CHECK(b.a_list_of_i8[0] == a.a_list_of_i8[0]);
997 CHECK(b.a_list_of_i8[1] == a.a_list_of_i8[1]);
998 CHECK(b.a_list_of_i16.size() == a.a_list_of_i16.size());
999 CHECK(b.a_list_of_i16[0] == a.a_list_of_i16[0]);
1000 CHECK(b.a_list_of_i16[1] == a.a_list_of_i16[1]);
1001 CHECK(b.a_list_of_i32.size() == a.a_list_of_i32.size());
1002 CHECK(b.a_list_of_i32[0] == a.a_list_of_i32[0]);
1003 CHECK(b.a_list_of_i32[1] == a.a_list_of_i32[1]);
1004 CHECK(b.a_list_of_i64.size() == a.a_list_of_i64.size());
1005 CHECK(b.a_list_of_i64[0] == a.a_list_of_i64[0]);
1006 CHECK(b.a_list_of_i64[1] == a.a_list_of_i64[1]);
1007 CHECK(b.a_list_of_double.size() == a.a_list_of_double.size());
1008 CHECK(b.a_list_of_double[0] == a.a_list_of_double[0]);
1009 CHECK(b.a_list_of_double[1] == a.a_list_of_double[1]);
1010 CHECK(b.a_list_of_string.size() == a.a_list_of_string.size());
1011 CHECK(b.a_list_of_string[0] == a.a_list_of_string[0]);
1012 CHECK(b.a_list_of_string[1] == a.a_list_of_string[1]);
1013 CHECK(b.a_list_of_binary.size() == a.a_list_of_binary.size());
1014 CHECK(b.a_list_of_binary[0].size() == 6);
1015 CHECK(b.a_list_of_binary[1].size() == 12);
1016 CHECK(b.a_list_of_binary[0][5] == 'C');
1017 CHECK(b.a_list_of_binary[1][11] == 'D');
1018 }
1019
1020 SECTION("test empty lists")
1021 {
1022 TestSomeLists a;
1023 TestSomeLists b;
1024 Bottle tmp;
1025
1026 // Fill b with random stuff
1027 b.a_list_of_bool = std::vector<bool>({true, false});
1028 b.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
1029 b.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
1030 b.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
1031 b.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
1032 b.a_list_of_double = std::vector<double>({-0.64, 0.64});
1033 b.a_list_of_string = std::vector<std::string>({"A string", "Another string"});
1034 b.a_list_of_binary.resize(2);
1035 b.a_list_of_binary[0].resize(6);
1036 memset(b.a_list_of_binary[0].data(), 0, b.a_list_of_binary[0].size());
1037 b.a_list_of_binary[0][b.a_list_of_binary[0].size() - 1] = 'C';
1038 b.a_list_of_binary[1].resize(12);
1039 memset(b.a_list_of_binary[1].data(), 0, b.a_list_of_binary[1].size());
1040 b.a_list_of_binary[1][b.a_list_of_binary[1].size() - 1] = 'D';
1041
1042 REQUIRE(tmp.read(a));
1043 REQUIRE(tmp.write(b));
1044
1045 CHECK(b.a_list_of_bool.empty());
1046 CHECK(b.a_list_of_i8.empty());
1047 CHECK(b.a_list_of_i16.empty());
1048 CHECK(b.a_list_of_i32.empty());
1049 CHECK(b.a_list_of_i64.empty());
1050 CHECK(b.a_list_of_double.empty());
1051 CHECK(b.a_list_of_string.empty());
1052 CHECK(b.a_list_of_binary.empty());
1053 }
1054
1055 SECTION("test annotated types")
1056 {
1059 Bottle tmp;
1060 a.a_vocab = yarp::os::createVocab32('d', 'e', 'm', 'o');
1061 a.a_ui8 = 0xff;
1062 a.a_ui16 = 0xffff;
1063 a.a_ui32 = 0xffffffff;
1064 a.a_ui64 = 0xffffffffffffffff;
1065 a.a_float32 = 0.32;
1066 a.a_float64 = 0.64;
1067 a.a_size = sizeof(TestAnnotatedTypes);
1068
1069 REQUIRE(tmp.read(a));
1070 REQUIRE(tmp.write(b));
1071
1072 CHECK(a.a_vocab == b.a_vocab);
1073 CHECK(a.a_ui8 == b.a_ui8);
1074 CHECK(a.a_ui16 == b.a_ui16);
1075 CHECK(a.a_ui32 == b.a_ui32);
1076 CHECK(a.a_ui64 == b.a_ui64);
1077 CHECK(a.a_float32 == b.a_float32);
1078 CHECK(a.a_float64 == b.a_float64);
1079 }
1080
1081 SECTION("test settings")
1082 {
1083 Settings::Editor settings;
1084 SettingsReceiver receiver;
1085
1088
1089 settings.yarp().attachAsClient(sender_port);
1090 receiver.yarp().attachAsServer(receiver_port);
1091
1092 REQUIRE(sender_port.open("/sender"));
1093 REQUIRE(receiver_port.open("/receiver"));
1095 REQUIRE(b_conn);
1096
1097 settings.set_id(5);
1098 CHECK(receiver.state().id == 5); // int assignment
1099
1100 settings.set_name("hello");
1101 CHECK(receiver.state().name == "hello"); // string assignment
1102
1103 settings.start_editing();
1104 settings.set_id(6);
1105 CHECK(receiver.state().id == 5); // not too early
1106
1107 settings.set_name("world");
1108 CHECK(receiver.state().name == "hello"); // string not too early
1109 settings.stop_editing();
1110 CHECK(receiver.state().id == 6); // int group
1111 CHECK(receiver.state().name == "world"); // string group
1112
1113 yarp::os::Bottle cmd;
1114 yarp::os::Bottle reply;
1115 cmd.fromString("patch (set id 3) (set name frog)");
1116 sender_port.write(cmd,reply);
1117 CHECK(reply.toString() == "[ok]"); // return on success
1118 CHECK(receiver.state().id == 3); // id ok
1119 CHECK(receiver.state().name == "frog"); // name ok
1120
1121 cmd.fromString("set id 9");
1122 reply.clear();
1123 sender_port.write(cmd,reply);
1124 CHECK(receiver.state().id == 9); // set id ok
1125
1126 cmd.fromString("set id 99 name \"Space Monkey\"");
1127 reply.clear();
1128 sender_port.write(cmd,reply);
1129 CHECK(receiver.state().id == 99); // multi set ok
1130 CHECK(receiver.state().name == "Space Monkey"); // multi set ok
1131
1132 cmd.fromString("set id 99 name \"Space Monkey\" id 101");
1133 reply.clear();
1134 sender_port.write(cmd,reply);
1135 CHECK(receiver.state().id == 101); // triple set ok
1136 }
1137
1138 SECTION("test start/stop")
1139 {
1140 Demo client;
1141 Server server;
1144 REQUIRE(client_port.open("/client"));
1145 REQUIRE(server_port.open("/server"));
1147 REQUIRE(b_conn);
1148 client.yarp().attachAsClient(client_port);
1149 server.yarp().attachAsServer(server_port);
1150
1151 INFO("Starting a long operation");
1152 client.do_start_a_service();
1153 Time::delay(1);
1154 INFO("Stopping a long operation");
1155 client.do_stop_a_service();
1156 }
1157
1158 SECTION("test map types")
1159 {
1160 Demo client;
1161 Server server;
1164 REQUIRE(client_port.open("/client"));
1165 REQUIRE(server_port.open("/server"));
1167 REQUIRE(b_conn);
1168 client.yarp().attachAsClient(client_port);
1169 server.yarp().attachAsServer(server_port);
1170
1171 INFO("Requesting a map type");
1172 DemoStructMap demoStructMap = client.get_demo_map_struct();
1173 CHECK(demoStructMap.mapValues.size() == 4);
1174 CHECK(demoStructMap.mapValues["map_0"].x == 0);
1175 CHECK(demoStructMap.mapValues["map_0"].y == 10);
1176 CHECK(demoStructMap.mapValues["map_1"].x == 1);
1177 CHECK(demoStructMap.mapValues["map_1"].y == 11);
1178 CHECK(demoStructMap.mapValues["map_2"].x == 2);
1179 CHECK(demoStructMap.mapValues["map_2"].y == 12);
1180 CHECK(demoStructMap.mapValues["map_3"].x == 3);
1181 CHECK(demoStructMap.mapValues["map_3"].y == 13);
1182 }
1183
1184 SECTION("test const")
1185 {
1186 Demo client;
1187 Server server;
1190 REQUIRE(client_port.open("/client"));
1191 REQUIRE(server_port.open("/server"));
1193 REQUIRE(b_conn);
1194 client.yarp().attachAsClient(client_port);
1195 server.yarp().attachAsServer(server_port);
1196
1197 INFO("calling a const method");
1198 CHECK(const_cast<const Demo&>(client).this_is_a_const_method());
1199 }
1200
1202}
1203
1204int main(int argc, char* argv[])
1205{
1206 Network yarp;
1207 return Catch::Session().run(argc, argv);
1208}
1209
1210TEST_CASE("Nested map values", "[idl::thrift]")
1211{
1213 original.nestedVectors["outer"]["first"] = {1.25, 2.5};
1214 original.nestedVectors["outer"]["second"] = {-3.75};
1215 original.nestedVectors["empty"] = {};
1216 original.mapOfVectors["outer"] = {
1217 {{"first", {4.5, 5.75}}, {"second", {-6.25}}},
1218 {{"third", {7.5}}}
1219 };
1220 original.mapOfVectors["empty"] = {};
1221
1222 SECTION("Binary")
1223 {
1224 DummyConnector connector;
1225 REQUIRE(original.write(connector.getWriter()));
1227 REQUIRE(restored.read(connector.getReader()));
1228 CHECK(restored.nestedVectors == original.nestedVectors);
1229 CHECK(restored.mapOfVectors == original.mapOfVectors);
1230 }
1231
1232 SECTION("Text")
1233 {
1234 DummyConnector connector;
1235 connector.setTextMode(true);
1236 REQUIRE(original.write(connector.getWriter()));
1238 REQUIRE(restored.read(connector.getReader()));
1239 CHECK(restored.nestedVectors == original.nestedVectors);
1240 CHECK(restored.mapOfVectors == original.mapOfVectors);
1241 }
1242}
int32_t get_answer() override
Definition main.cpp:144
bool read(ConnectionReader &con) override
Read this object from a network connection.
Definition main.cpp:203
bool will_set_y() override
Definition main.cpp:183
bool did_set_y() override
Definition main.cpp:193
bool will_set_x() override
Definition main.cpp:178
bool did_set_x() override
Definition main.cpp:188
int32_t get_answer() override
Definition main.cpp:46
void do_stop_a_service() override
Definition main.cpp:118
int32_t add_one(const int32_t x) override
Definition main.cpp:50
bool do_check_for_service() override
Definition main.cpp:114
void do_start_a_service() override
Definition main.cpp:105
void test_void(const int32_t x) override
Definition main.cpp:60
void test_1way(const int32_t x) override
Definition main.cpp:64
int32_t test_tail_defaults(const DemoEnum x) override
Definition main.cpp:88
bool this_is_a_const_method() const override
Definition main.cpp:135
int32_t add_pair(const int32_t x, const int32_t y) override
Definition main.cpp:55
Server()
Definition main.cpp:41
int32_t test_longer_tail_defaults(const int32_t ignore, const DemoEnum _enum, const int32_t _int, const std::string &_string) override
Definition main.cpp:95
DemoStructMap get_demo_map_struct() override
Definition main.cpp:126
std::vector< DemoEnum > test_enum_vector(const std::vector< DemoEnum > &x) override
Definition main.cpp:73
bool test_defaults(const int32_t x) override
Definition main.cpp:68
int32_t test_partial(const int32_t x, const std::vector< int32_t > &lst, const int32_t y) override
Definition main.cpp:80
bool will_set_id() override
Definition main.cpp:226
bool called_did_set_id
Definition main.cpp:215
bool called_will_set_id
Definition main.cpp:214
bool did_set_id() override
Definition main.cpp:231
Bottle getBottle() override
Definition main.cpp:163
int32_t check(const yarp::os::Value &param) override
Definition main.cpp:153
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
void fromString(const std::string &text)
Initializes bottle from a string.
Definition Bottle.cpp:205
size_type size() const
Gets the number of elements in the bottle.
Definition Bottle.cpp:252
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Definition Bottle.cpp:241
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition Bottle.cpp:247
void clear()
Empties the bottle of any objects it contains.
Definition Bottle.cpp:121
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
Definition Bottle.cpp:231
bool isNull() const override
Checks if the object is invalid.
Definition Bottle.cpp:344
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:212
A mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
An interface for reading from a network connection.
A dummy connection to test yarp::os::Portable implementations.
ConnectionWriter & getWriter()
Get the dummy ConnectionWriter loaded with whatever was written the ConnectionWriter since it was las...
void setTextMode(bool textmode)
Set the textMode of the dummy connection.
ConnectionReader & getReader(ConnectionWriter *replyWriter=nullptr)
Get the dummy ConnectionReader loaded with whatever was written the ConnectionWriter since it was las...
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
Definition Network.cpp:784
static bool setLocalMode(bool flag)
Chooses whether communication is process-local.
Definition Network.cpp:1137
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:718
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition Portable.cpp:16
A port that is specialized as an RPC client.
Definition RpcClient.h:22
A port that is specialized as an RPC server.
Definition RpcServer.h:23
A single value (typically within a Bottle).
Definition Value.h:44
virtual yarp::conf::vocab32_t asVocab32() const
Get 32 bit vocabulary identifier as an integer.
Definition Value.cpp:228
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:204
virtual Bottle * asList() const
Get list value.
Definition Value.cpp:246
std::string toString() const override
Return a standard text representation of the content of the object.
Definition Value.cpp:347
virtual bool isInt32() const
Checks if value is a 32-bit integer.
Definition Value.cpp:132
virtual std::string asString() const
Get string value.
Definition Value.cpp:240
int main(int argc, char *argv[])
Definition main.cpp:1204
TEST_CASE("IdlThriftTest", "[yarp::idl::thrift]")
Definition main.cpp:239
void delay(double seconds)
Wait for a certain number of seconds.
Definition Time.cpp:111
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.
Definition Vocab32.h:27
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_UNUSED(var)
Definition api.h:162
std::string INFO
Definition ymanager.cpp:54