YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ILLMMsgs.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 (based on compiler 0.14.1-yarped)
7// yarpidl_thrift version 2.0 - 11/11/2026
8// Protocol version: protocol_version=0, yarp_major=4, yarp_minor=0, yarp_patch=2
9// This is an automatically generated file.
10// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
11
12#include <yarp/conf/version.h>
13#include <yarp/dev/ILLMMsgs.h>
15#include <yarp/os/LogStream.h>
16
18
19#include <algorithm>
20
21namespace
22{
23 YARP_LOG_COMPONENT(SERVICE_LOG_COMPONENT, "ILLMMsgs")
24}
25
26namespace yarp::dev {
27
28//ILLMMsgs_getRemoteProtocolVersion_helper declaration
39
41{
42 yarp::os::idl::WireWriter writer(connection);
43 if (!writer.writeListHeader(1)) {
44 return false;
45 }
46 if (!writer.writeString("getRemoteProtocolVersion")) {
47 return false;
48 }
49 return true;
50}
51
52bool ILLMMsgs_getRemoteProtocolVersion_helper ::read(yarp::os::ConnectionReader & connection)
53 {
54 yarp::os::idl::WireReader reader(connection);
55 if (!reader.readListHeader()) {
56 reader.fail();
57 return false;
58 }
59
60 if (!helper_proto.read(connection)) {
61 reader.fail();
62 return false;
63 }
64 return true;
65}
66
67//ProtocolVersion, client side
69 {
70 if(!yarp().canWrite()) {
71 yError(" Missing server method ILLMMsgs::getRemoteProtocolVersion");
72 }
74 bool ok = yarp().write(helper, helper);
75 if (ok) {
76 return helper.helper_proto;}
77 else {
79 return failureproto;}
80}
81
82//ProtocolVersion, client side
84 {
85 auto locproto = this->getLocalProtocolVersion();
86 auto remproto = this->getRemoteProtocolVersion();
87 if (remproto.protocol_version != locproto.protocol_version)
88 {
89 yCError(SERVICE_LOG_COMPONENT) << "Invalid communication protocol.";
90 yCError(SERVICE_LOG_COMPONENT) << "Local Protocol Version: " << locproto.toString();
91 yCError(SERVICE_LOG_COMPONENT) << "Remote Protocol Version: " << remproto.toString();
92 return false;
93 }
94 return true;
95}
96
97//ProtocolVersion, server side
99{
101 //myproto.protocol_version using default value = 0
102 //to change this value add the following line to the .thrift file:
103 //const i16 protocol_version = <your_number_here>
104 myproto.protocol_version = 0;
108 return myproto;
109}
110
111// setPrompt helper class declaration
113 public yarp::os::Portable
114{
115public:
117 explicit ILLMMsgs_setPrompt_helper(const std::string& prompt);
118 bool write(yarp::os::ConnectionWriter& connection) const override;
119 bool read(yarp::os::ConnectionReader& connection) override;
120
121 class Command :
123 {
124 public:
125 Command() = default;
126 explicit Command(const std::string& prompt);
127
128 ~Command() override = default;
129
130 bool write(yarp::os::ConnectionWriter& connection) const override;
131 bool read(yarp::os::ConnectionReader& connection) override;
132
133 bool write(const yarp::os::idl::WireWriter& writer) const override;
134 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
135 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
136
137 bool read(yarp::os::idl::WireReader& reader) override;
140
141 std::string prompt{};
142 };
143
144 class Reply :
146 {
147 public:
148 Reply() = default;
149 ~Reply() override = default;
150
151 bool write(yarp::os::ConnectionWriter& connection) const override;
152 bool read(yarp::os::ConnectionReader& connection) override;
153
154 bool write(const yarp::os::idl::WireWriter& writer) const override;
155 bool read(yarp::os::idl::WireReader& reader) override;
156
158 };
159
160 using funcptr_t = yarp::dev::ReturnValue (*)(const std::string&);
161 void call(ILLMMsgs* ptr);
162
165
166 static constexpr const char* s_tag{"setPrompt"};
167 static constexpr size_t s_tag_len{1};
168 static constexpr size_t s_cmd_len{2};
169 static constexpr size_t s_reply_len{1};
170 static constexpr const char* s_prototype{"yarp::dev::ReturnValue ILLMMsgs::setPrompt(const std::string& prompt)"};
171 static constexpr const char* s_help{""};
172};
173
174// readPrompt helper class declaration
176 public yarp::os::Portable
177{
178public:
180 bool write(yarp::os::ConnectionWriter& connection) const override;
181 bool read(yarp::os::ConnectionReader& connection) override;
182
183 class Command :
185 {
186 public:
187 Command() = default;
188 ~Command() override = default;
189
190 bool write(yarp::os::ConnectionWriter& connection) const override;
191 bool read(yarp::os::ConnectionReader& connection) override;
192
193 bool write(const yarp::os::idl::WireWriter& writer) const override;
194 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
195 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
196
197 bool read(yarp::os::idl::WireReader& reader) override;
200 };
201
202 class Reply :
204 {
205 public:
206 Reply() = default;
207 ~Reply() override = default;
208
209 bool write(yarp::os::ConnectionWriter& connection) const override;
210 bool read(yarp::os::ConnectionReader& connection) override;
211
212 bool write(const yarp::os::idl::WireWriter& writer) const override;
213 bool read(yarp::os::idl::WireReader& reader) override;
214
216 };
217
219 void call(ILLMMsgs* ptr);
220
223
224 static constexpr const char* s_tag{"readPrompt"};
225 static constexpr size_t s_tag_len{1};
226 static constexpr size_t s_cmd_len{1};
227 static constexpr size_t s_reply_len{2};
228 static constexpr const char* s_prototype{"return_readPrompt ILLMMsgs::readPrompt()"};
229 static constexpr const char* s_help{""};
230};
231
232// ask helper class declaration
234 public yarp::os::Portable
235{
236public:
238 explicit ILLMMsgs_ask_helper(const std::string& question);
239 bool write(yarp::os::ConnectionWriter& connection) const override;
240 bool read(yarp::os::ConnectionReader& connection) override;
241
242 class Command :
244 {
245 public:
246 Command() = default;
247 explicit Command(const std::string& question);
248
249 ~Command() override = default;
250
251 bool write(yarp::os::ConnectionWriter& connection) const override;
252 bool read(yarp::os::ConnectionReader& connection) override;
253
254 bool write(const yarp::os::idl::WireWriter& writer) const override;
255 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
256 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
257
258 bool read(yarp::os::idl::WireReader& reader) override;
261
262 std::string question{};
263 };
264
265 class Reply :
267 {
268 public:
269 Reply() = default;
270 ~Reply() override = default;
271
272 bool write(yarp::os::ConnectionWriter& connection) const override;
273 bool read(yarp::os::ConnectionReader& connection) override;
274
275 bool write(const yarp::os::idl::WireWriter& writer) const override;
276 bool read(yarp::os::idl::WireReader& reader) override;
277
279 };
280
281 using funcptr_t = return_ask (*)(const std::string&);
282 void call(ILLMMsgs* ptr);
283
286
287 static constexpr const char* s_tag{"ask"};
288 static constexpr size_t s_tag_len{1};
289 static constexpr size_t s_cmd_len{2};
290 static constexpr size_t s_reply_len{2};
291 static constexpr const char* s_prototype{"return_ask ILLMMsgs::ask(const std::string& question)"};
292 static constexpr const char* s_help{""};
293};
294
295// getConversation helper class declaration
297 public yarp::os::Portable
298{
299public:
301 bool write(yarp::os::ConnectionWriter& connection) const override;
302 bool read(yarp::os::ConnectionReader& connection) override;
303
304 class Command :
306 {
307 public:
308 Command() = default;
309 ~Command() override = default;
310
311 bool write(yarp::os::ConnectionWriter& connection) const override;
312 bool read(yarp::os::ConnectionReader& connection) override;
313
314 bool write(const yarp::os::idl::WireWriter& writer) const override;
315 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
316 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
317
318 bool read(yarp::os::idl::WireReader& reader) override;
321 };
322
323 class Reply :
325 {
326 public:
327 Reply() = default;
328 ~Reply() override = default;
329
330 bool write(yarp::os::ConnectionWriter& connection) const override;
331 bool read(yarp::os::ConnectionReader& connection) override;
332
333 bool write(const yarp::os::idl::WireWriter& writer) const override;
334 bool read(yarp::os::idl::WireReader& reader) override;
335
337 };
338
340 void call(ILLMMsgs* ptr);
341
344
345 static constexpr const char* s_tag{"getConversation"};
346 static constexpr size_t s_tag_len{1};
347 static constexpr size_t s_cmd_len{1};
348 static constexpr size_t s_reply_len{2};
349 static constexpr const char* s_prototype{"return_getConversation ILLMMsgs::getConversation()"};
350 static constexpr const char* s_help{""};
351};
352
353// deleteConversation helper class declaration
355 public yarp::os::Portable
356{
357public:
359 bool write(yarp::os::ConnectionWriter& connection) const override;
360 bool read(yarp::os::ConnectionReader& connection) override;
361
362 class Command :
364 {
365 public:
366 Command() = default;
367 ~Command() override = default;
368
369 bool write(yarp::os::ConnectionWriter& connection) const override;
370 bool read(yarp::os::ConnectionReader& connection) override;
371
372 bool write(const yarp::os::idl::WireWriter& writer) const override;
373 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
374 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
375
376 bool read(yarp::os::idl::WireReader& reader) override;
379 };
380
381 class Reply :
383 {
384 public:
385 Reply() = default;
386 ~Reply() override = default;
387
388 bool write(yarp::os::ConnectionWriter& connection) const override;
389 bool read(yarp::os::ConnectionReader& connection) override;
390
391 bool write(const yarp::os::idl::WireWriter& writer) const override;
392 bool read(yarp::os::idl::WireReader& reader) override;
393
395 };
396
398 void call(ILLMMsgs* ptr);
399
402
403 static constexpr const char* s_tag{"deleteConversation"};
404 static constexpr size_t s_tag_len{1};
405 static constexpr size_t s_cmd_len{1};
406 static constexpr size_t s_reply_len{1};
407 static constexpr const char* s_prototype{"yarp::dev::ReturnValue ILLMMsgs::deleteConversation()"};
408 static constexpr const char* s_help{""};
409};
410
411// refreshConversation helper class declaration
413 public yarp::os::Portable
414{
415public:
417 bool write(yarp::os::ConnectionWriter& connection) const override;
418 bool read(yarp::os::ConnectionReader& connection) override;
419
420 class Command :
422 {
423 public:
424 Command() = default;
425 ~Command() override = default;
426
427 bool write(yarp::os::ConnectionWriter& connection) const override;
428 bool read(yarp::os::ConnectionReader& connection) override;
429
430 bool write(const yarp::os::idl::WireWriter& writer) const override;
431 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
432 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
433
434 bool read(yarp::os::idl::WireReader& reader) override;
437 };
438
439 class Reply :
441 {
442 public:
443 Reply() = default;
444 ~Reply() override = default;
445
446 bool write(yarp::os::ConnectionWriter& connection) const override;
447 bool read(yarp::os::ConnectionReader& connection) override;
448
449 bool write(const yarp::os::idl::WireWriter& writer) const override;
450 bool read(yarp::os::idl::WireReader& reader) override;
451
453 };
454
456 void call(ILLMMsgs* ptr);
457
460
461 static constexpr const char* s_tag{"refreshConversation"};
462 static constexpr size_t s_tag_len{1};
463 static constexpr size_t s_cmd_len{1};
464 static constexpr size_t s_reply_len{1};
465 static constexpr const char* s_prototype{"yarp::dev::ReturnValue ILLMMsgs::refreshConversation()"};
466 static constexpr const char* s_help{""};
467};
468
469// setPrompt helper class implementation
471 cmd{prompt}
472{
473}
474
476{
477 return cmd.write(connection);
478}
479
481{
482 return reply.read(connection);
483}
484
486 prompt{prompt}
487{
488}
489
491{
492 yarp::os::idl::WireWriter writer(connection);
493 if (!writer.writeListHeader(s_cmd_len)) {
494 return false;
495 }
496 return write(writer);
497}
498
500{
501 yarp::os::idl::WireReader reader(connection);
502 if (!reader.readListHeader()) {
503 reader.fail();
504 return false;
505 }
506 return read(reader);
507}
508
510{
511 if (!writeTag(writer)) {
512 return false;
513 }
514 if (!writeArgs(writer)) {
515 return false;
516 }
517 return true;
518}
519
521{
522 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
523 return false;
524 }
525 return true;
526}
527
529{
530 if (!writer.writeString(prompt)) {
531 return false;
532 }
533 return true;
534}
535
537{
538 if (!readTag(reader)) {
539 return false;
540 }
541 if (!readArgs(reader)) {
542 return false;
543 }
544 return true;
545}
546
548{
549 std::string tag = reader.readTag(s_tag_len);
550 if (reader.isError()) {
551 return false;
552 }
553 if (tag != s_tag) {
554 reader.fail();
555 return false;
556 }
557 return true;
558}
559
561{
562 if (reader.noMore()) {
563 reader.fail();
564 return false;
565 }
566 if (!reader.readString(prompt)) {
567 reader.fail();
568 return false;
569 }
570 if (!reader.noMore()) {
571 reader.fail();
572 return false;
573 }
574 return true;
575}
576
578{
579 yarp::os::idl::WireWriter writer(connection);
580 return write(writer);
581}
582
584{
585 yarp::os::idl::WireReader reader(connection);
586 return read(reader);
587}
588
590{
591 if (!writer.isNull()) {
592 if (!writer.write(return_helper)) {
593 return false;
594 }
595 }
596 return true;
597}
598
600{
601 if (reader.noMore()) {
602 reader.fail();
603 return false;
604 }
605 if (!reader.read(return_helper)) {
606 reader.fail();
607 return false;
608 }
609 return true;
610}
611
616
617// readPrompt helper class implementation
619{
620 return cmd.write(connection);
621}
622
624{
625 return reply.read(connection);
626}
627
629{
630 yarp::os::idl::WireWriter writer(connection);
631 if (!writer.writeListHeader(s_cmd_len)) {
632 return false;
633 }
634 return write(writer);
635}
636
638{
639 yarp::os::idl::WireReader reader(connection);
640 if (!reader.readListHeader()) {
641 reader.fail();
642 return false;
643 }
644 return read(reader);
645}
646
648{
649 if (!writeTag(writer)) {
650 return false;
651 }
652 if (!writeArgs(writer)) {
653 return false;
654 }
655 return true;
656}
657
659{
660 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
661 return false;
662 }
663 return true;
664}
665
667{
668 return true;
669}
670
672{
673 if (!readTag(reader)) {
674 return false;
675 }
676 if (!readArgs(reader)) {
677 return false;
678 }
679 return true;
680}
681
683{
684 std::string tag = reader.readTag(s_tag_len);
685 if (reader.isError()) {
686 return false;
687 }
688 if (tag != s_tag) {
689 reader.fail();
690 return false;
691 }
692 return true;
693}
694
696{
697 if (!reader.noMore()) {
698 reader.fail();
699 return false;
700 }
701 return true;
702}
703
705{
706 yarp::os::idl::WireWriter writer(connection);
707 return write(writer);
708}
709
711{
712 yarp::os::idl::WireReader reader(connection);
713 return read(reader);
714}
715
717{
718 if (!writer.isNull()) {
719 if (!writer.writeListHeader(s_reply_len)) {
720 return false;
721 }
722 if (!writer.write(return_helper)) {
723 return false;
724 }
725 }
726 return true;
727}
728
730{
731 if (!reader.readListReturn()) {
732 return false;
733 }
734 if (reader.noMore()) {
735 reader.fail();
736 return false;
737 }
738 if (!reader.read(return_helper)) {
739 reader.fail();
740 return false;
741 }
742 return true;
743}
744
749
750// ask helper class implementation
751ILLMMsgs_ask_helper::ILLMMsgs_ask_helper(const std::string& question) :
752 cmd{question}
753{
754}
755
757{
758 return cmd.write(connection);
759}
760
762{
763 return reply.read(connection);
764}
765
766ILLMMsgs_ask_helper::Command::Command(const std::string& question) :
767 question{question}
768{
769}
770
772{
773 yarp::os::idl::WireWriter writer(connection);
774 if (!writer.writeListHeader(s_cmd_len)) {
775 return false;
776 }
777 return write(writer);
778}
779
781{
782 yarp::os::idl::WireReader reader(connection);
783 if (!reader.readListHeader()) {
784 reader.fail();
785 return false;
786 }
787 return read(reader);
788}
789
791{
792 if (!writeTag(writer)) {
793 return false;
794 }
795 if (!writeArgs(writer)) {
796 return false;
797 }
798 return true;
799}
800
802{
803 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
804 return false;
805 }
806 return true;
807}
808
810{
811 if (!writer.writeString(question)) {
812 return false;
813 }
814 return true;
815}
816
818{
819 if (!readTag(reader)) {
820 return false;
821 }
822 if (!readArgs(reader)) {
823 return false;
824 }
825 return true;
826}
827
829{
830 std::string tag = reader.readTag(s_tag_len);
831 if (reader.isError()) {
832 return false;
833 }
834 if (tag != s_tag) {
835 reader.fail();
836 return false;
837 }
838 return true;
839}
840
842{
843 if (reader.noMore()) {
844 reader.fail();
845 return false;
846 }
847 if (!reader.readString(question)) {
848 reader.fail();
849 return false;
850 }
851 if (!reader.noMore()) {
852 reader.fail();
853 return false;
854 }
855 return true;
856}
857
859{
860 yarp::os::idl::WireWriter writer(connection);
861 return write(writer);
862}
863
865{
866 yarp::os::idl::WireReader reader(connection);
867 return read(reader);
868}
869
871{
872 if (!writer.isNull()) {
873 if (!writer.writeListHeader(s_reply_len)) {
874 return false;
875 }
876 if (!writer.write(return_helper)) {
877 return false;
878 }
879 }
880 return true;
881}
882
884{
885 if (!reader.readListReturn()) {
886 return false;
887 }
888 if (reader.noMore()) {
889 reader.fail();
890 return false;
891 }
892 if (!reader.read(return_helper)) {
893 reader.fail();
894 return false;
895 }
896 return true;
897}
898
903
904// getConversation helper class implementation
906{
907 return cmd.write(connection);
908}
909
911{
912 return reply.read(connection);
913}
914
916{
917 yarp::os::idl::WireWriter writer(connection);
918 if (!writer.writeListHeader(s_cmd_len)) {
919 return false;
920 }
921 return write(writer);
922}
923
925{
926 yarp::os::idl::WireReader reader(connection);
927 if (!reader.readListHeader()) {
928 reader.fail();
929 return false;
930 }
931 return read(reader);
932}
933
935{
936 if (!writeTag(writer)) {
937 return false;
938 }
939 if (!writeArgs(writer)) {
940 return false;
941 }
942 return true;
943}
944
946{
947 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
948 return false;
949 }
950 return true;
951}
952
954{
955 return true;
956}
957
959{
960 if (!readTag(reader)) {
961 return false;
962 }
963 if (!readArgs(reader)) {
964 return false;
965 }
966 return true;
967}
968
970{
971 std::string tag = reader.readTag(s_tag_len);
972 if (reader.isError()) {
973 return false;
974 }
975 if (tag != s_tag) {
976 reader.fail();
977 return false;
978 }
979 return true;
980}
981
983{
984 if (!reader.noMore()) {
985 reader.fail();
986 return false;
987 }
988 return true;
989}
990
992{
993 yarp::os::idl::WireWriter writer(connection);
994 return write(writer);
995}
996
998{
999 yarp::os::idl::WireReader reader(connection);
1000 return read(reader);
1001}
1002
1004{
1005 if (!writer.isNull()) {
1006 if (!writer.writeListHeader(s_reply_len)) {
1007 return false;
1008 }
1009 if (!writer.write(return_helper)) {
1010 return false;
1011 }
1012 }
1013 return true;
1014}
1015
1017{
1018 if (!reader.readListReturn()) {
1019 return false;
1020 }
1021 if (reader.noMore()) {
1022 reader.fail();
1023 return false;
1024 }
1025 if (!reader.read(return_helper)) {
1026 reader.fail();
1027 return false;
1028 }
1029 return true;
1030}
1031
1036
1037// deleteConversation helper class implementation
1039{
1040 return cmd.write(connection);
1041}
1042
1044{
1045 return reply.read(connection);
1046}
1047
1049{
1050 yarp::os::idl::WireWriter writer(connection);
1051 if (!writer.writeListHeader(s_cmd_len)) {
1052 return false;
1053 }
1054 return write(writer);
1055}
1056
1058{
1059 yarp::os::idl::WireReader reader(connection);
1060 if (!reader.readListHeader()) {
1061 reader.fail();
1062 return false;
1063 }
1064 return read(reader);
1065}
1066
1068{
1069 if (!writeTag(writer)) {
1070 return false;
1071 }
1072 if (!writeArgs(writer)) {
1073 return false;
1074 }
1075 return true;
1076}
1077
1079{
1080 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
1081 return false;
1082 }
1083 return true;
1084}
1085
1087{
1088 return true;
1089}
1090
1092{
1093 if (!readTag(reader)) {
1094 return false;
1095 }
1096 if (!readArgs(reader)) {
1097 return false;
1098 }
1099 return true;
1100}
1101
1103{
1104 std::string tag = reader.readTag(s_tag_len);
1105 if (reader.isError()) {
1106 return false;
1107 }
1108 if (tag != s_tag) {
1109 reader.fail();
1110 return false;
1111 }
1112 return true;
1113}
1114
1116{
1117 if (!reader.noMore()) {
1118 reader.fail();
1119 return false;
1120 }
1121 return true;
1122}
1123
1125{
1126 yarp::os::idl::WireWriter writer(connection);
1127 return write(writer);
1128}
1129
1131{
1132 yarp::os::idl::WireReader reader(connection);
1133 return read(reader);
1134}
1135
1137{
1138 if (!writer.isNull()) {
1139 if (!writer.write(return_helper)) {
1140 return false;
1141 }
1142 }
1143 return true;
1144}
1145
1147{
1148 if (reader.noMore()) {
1149 reader.fail();
1150 return false;
1151 }
1152 if (!reader.read(return_helper)) {
1153 reader.fail();
1154 return false;
1155 }
1156 return true;
1157}
1158
1163
1164// refreshConversation helper class implementation
1166{
1167 return cmd.write(connection);
1168}
1169
1171{
1172 return reply.read(connection);
1173}
1174
1176{
1177 yarp::os::idl::WireWriter writer(connection);
1178 if (!writer.writeListHeader(s_cmd_len)) {
1179 return false;
1180 }
1181 return write(writer);
1182}
1183
1185{
1186 yarp::os::idl::WireReader reader(connection);
1187 if (!reader.readListHeader()) {
1188 reader.fail();
1189 return false;
1190 }
1191 return read(reader);
1192}
1193
1195{
1196 if (!writeTag(writer)) {
1197 return false;
1198 }
1199 if (!writeArgs(writer)) {
1200 return false;
1201 }
1202 return true;
1203}
1204
1206{
1207 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
1208 return false;
1209 }
1210 return true;
1211}
1212
1214{
1215 return true;
1216}
1217
1219{
1220 if (!readTag(reader)) {
1221 return false;
1222 }
1223 if (!readArgs(reader)) {
1224 return false;
1225 }
1226 return true;
1227}
1228
1230{
1231 std::string tag = reader.readTag(s_tag_len);
1232 if (reader.isError()) {
1233 return false;
1234 }
1235 if (tag != s_tag) {
1236 reader.fail();
1237 return false;
1238 }
1239 return true;
1240}
1241
1243{
1244 if (!reader.noMore()) {
1245 reader.fail();
1246 return false;
1247 }
1248 return true;
1249}
1250
1252{
1253 yarp::os::idl::WireWriter writer(connection);
1254 return write(writer);
1255}
1256
1258{
1259 yarp::os::idl::WireReader reader(connection);
1260 return read(reader);
1261}
1262
1264{
1265 if (!writer.isNull()) {
1266 if (!writer.write(return_helper)) {
1267 return false;
1268 }
1269 }
1270 return true;
1271}
1272
1274{
1275 if (reader.noMore()) {
1276 reader.fail();
1277 return false;
1278 }
1279 if (!reader.read(return_helper)) {
1280 reader.fail();
1281 return false;
1282 }
1283 return true;
1284}
1285
1290
1291// Constructor
1293{
1294 yarp().setOwner(*this);
1295}
1296
1298{
1299 if (!yarp().canWrite()) {
1300 yError("Missing server method '%s'?", ILLMMsgs_setPrompt_helper::s_prototype);
1301 }
1302 ILLMMsgs_setPrompt_helper helper{prompt};
1303 bool ok = yarp().write(helper, helper);
1305}
1306
1308{
1309 if (!yarp().canWrite()) {
1310 yError("Missing server method '%s'?", ILLMMsgs_readPrompt_helper::s_prototype);
1311 }
1313 bool ok = yarp().write(helper, helper);
1314 if (!ok) {
1315 return_readPrompt failed_reply{};
1317 return failed_reply;
1318 }
1319 return helper.reply.return_helper;
1320}
1321
1322return_ask ILLMMsgs::ask(const std::string& question)
1323{
1324 if (!yarp().canWrite()) {
1325 yError("Missing server method '%s'?", ILLMMsgs_ask_helper::s_prototype);
1326 }
1327 ILLMMsgs_ask_helper helper{question};
1328 bool ok = yarp().write(helper, helper);
1329 if (!ok) {
1330 return_ask failed_reply{};
1332 return failed_reply;
1333 }
1334 return helper.reply.return_helper;
1335}
1336
1338{
1339 if (!yarp().canWrite()) {
1340 yError("Missing server method '%s'?", ILLMMsgs_getConversation_helper::s_prototype);
1341 }
1343 bool ok = yarp().write(helper, helper);
1344 if (!ok) {
1345 return_getConversation failed_reply{};
1347 return failed_reply;
1348 }
1349 return helper.reply.return_helper;
1350}
1351
1353{
1354 if (!yarp().canWrite()) {
1355 yError("Missing server method '%s'?", ILLMMsgs_deleteConversation_helper::s_prototype);
1356 }
1358 bool ok = yarp().write(helper, helper);
1360}
1361
1363{
1364 if (!yarp().canWrite()) {
1365 yError("Missing server method '%s'?", ILLMMsgs_refreshConversation_helper::s_prototype);
1366 }
1368 bool ok = yarp().write(helper, helper);
1370}
1371
1372// help method
1373std::vector<std::string> ILLMMsgs::help(const std::string& functionName)
1374{
1375 bool showAll = (functionName == "--all");
1376 std::vector<std::string> helpString;
1377 if (showAll) {
1378 helpString.emplace_back("*** Available commands:");
1379 helpString.emplace_back(ILLMMsgs_setPrompt_helper::s_tag);
1380 helpString.emplace_back(ILLMMsgs_readPrompt_helper::s_tag);
1381 helpString.emplace_back(ILLMMsgs_ask_helper::s_tag);
1382 helpString.emplace_back(ILLMMsgs_getConversation_helper::s_tag);
1383 helpString.emplace_back(ILLMMsgs_deleteConversation_helper::s_tag);
1384 helpString.emplace_back(ILLMMsgs_refreshConversation_helper::s_tag);
1385 helpString.emplace_back("help");
1386 } else {
1387 if (functionName == ILLMMsgs_setPrompt_helper::s_tag) {
1388 helpString.emplace_back(ILLMMsgs_setPrompt_helper::s_prototype);
1389 }
1390 if (functionName == ILLMMsgs_readPrompt_helper::s_tag) {
1391 helpString.emplace_back(ILLMMsgs_readPrompt_helper::s_prototype);
1392 }
1393 if (functionName == ILLMMsgs_ask_helper::s_tag) {
1394 helpString.emplace_back(ILLMMsgs_ask_helper::s_prototype);
1395 }
1396 if (functionName == ILLMMsgs_getConversation_helper::s_tag) {
1397 helpString.emplace_back(ILLMMsgs_getConversation_helper::s_prototype);
1398 }
1399 if (functionName == ILLMMsgs_deleteConversation_helper::s_tag) {
1400 helpString.emplace_back(ILLMMsgs_deleteConversation_helper::s_prototype);
1401 }
1402 if (functionName == ILLMMsgs_refreshConversation_helper::s_tag) {
1403 helpString.emplace_back(ILLMMsgs_refreshConversation_helper::s_prototype);
1404 }
1405 if (functionName == "help") {
1406 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
1407 helpString.emplace_back("Return list of available commands, or help message for a specific function");
1408 helpString.emplace_back("@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands");
1409 helpString.emplace_back("@return list of strings (one string per line)");
1410 }
1411 }
1412 if (helpString.empty()) {
1413 helpString.emplace_back("Command not found");
1414 }
1415 return helpString;
1416}
1417
1418// read from ConnectionReader
1420{
1421 constexpr size_t max_tag_len = 1;
1422 size_t tag_len = 1;
1423
1424 yarp::os::idl::WireReader reader(connection);
1425 reader.expectAccept();
1426 if (!reader.readListHeader()) {
1427 reader.fail();
1428 return false;
1429 }
1430
1431 std::string tag = reader.readTag(1);
1432 bool direct = (tag == "__direct__");
1433 if (direct) {
1434 tag = reader.readTag(1);
1435 }
1436 while (tag_len <= max_tag_len && !reader.isError()) {
1437 if(tag == "getRemoteProtocolVersion") {
1438 if (!reader.noMore()) {
1439 yError("Reader invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
1440 reader.fail();
1441 return false;
1442 }
1443
1444 auto proto = getLocalProtocolVersion();
1445
1446 yarp::os::idl::WireWriter writer(reader);
1447 if (!writer.writeListHeader(1)) {
1448 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
1449 return false;}
1450 if (!writer.write(proto)) {
1451 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
1452 return false;
1453 }
1454 reader.accept();
1455 return true;
1456 }
1459 if (!helper.cmd.readArgs(reader)) {
1460 return false;
1461 }
1462
1463 helper.call(this);
1464
1465 yarp::os::idl::WireWriter writer(reader);
1466 if (!helper.reply.write(writer)) {
1467 return false;
1468 }
1469 reader.accept();
1470 return true;
1471 }
1474 if (!helper.cmd.readArgs(reader)) {
1475 return false;
1476 }
1477
1478 helper.call(this);
1479
1480 yarp::os::idl::WireWriter writer(reader);
1481 if (!helper.reply.write(writer)) {
1482 return false;
1483 }
1484 reader.accept();
1485 return true;
1486 }
1487 if (tag == ILLMMsgs_ask_helper::s_tag) {
1488 ILLMMsgs_ask_helper helper;
1489 if (!helper.cmd.readArgs(reader)) {
1490 return false;
1491 }
1492
1493 helper.call(this);
1494
1495 yarp::os::idl::WireWriter writer(reader);
1496 if (!helper.reply.write(writer)) {
1497 return false;
1498 }
1499 reader.accept();
1500 return true;
1501 }
1504 if (!helper.cmd.readArgs(reader)) {
1505 return false;
1506 }
1507
1508 helper.call(this);
1509
1510 yarp::os::idl::WireWriter writer(reader);
1511 if (!helper.reply.write(writer)) {
1512 return false;
1513 }
1514 reader.accept();
1515 return true;
1516 }
1519 if (!helper.cmd.readArgs(reader)) {
1520 return false;
1521 }
1522
1523 helper.call(this);
1524
1525 yarp::os::idl::WireWriter writer(reader);
1526 if (!helper.reply.write(writer)) {
1527 return false;
1528 }
1529 reader.accept();
1530 return true;
1531 }
1534 if (!helper.cmd.readArgs(reader)) {
1535 return false;
1536 }
1537
1538 helper.call(this);
1539
1540 yarp::os::idl::WireWriter writer(reader);
1541 if (!helper.reply.write(writer)) {
1542 return false;
1543 }
1544 reader.accept();
1545 return true;
1546 }
1547 if (tag == "help") {
1548 std::string functionName;
1549 if (!reader.readString(functionName)) {
1550 functionName = "--all";
1551 }
1552 auto help_strings = help(functionName);
1553 yarp::os::idl::WireWriter writer(reader);
1554 if (!writer.isNull()) {
1555 if (!writer.writeListHeader(2)) {
1556 return false;
1557 }
1558 if (!writer.writeTag("many", 1, 0)) {
1559 return false;
1560 }
1561 if (!writer.writeListBegin(0, help_strings.size())) {
1562 return false;
1563 }
1564 for (const auto& help_string : help_strings) {
1565 if (!writer.writeString(help_string)) {
1566 return false;
1567 }
1568 }
1569 if (!writer.writeListEnd()) {
1570 return false;
1571 }
1572 }
1573 reader.accept();
1574 return true;
1575 }
1576 if (reader.noMore()) {
1577 reader.fail();
1578 return false;
1579 }
1580 std::string next_tag = reader.readTag(1);
1581 if (next_tag.empty()) {
1582 break;
1583 }
1584 tag.append("_").append(next_tag);
1585 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
1586 }
1587 return false;
1588}
1589
1590} // namespace yarp::dev
#define yError(...)
Definition Log.h:361
#define __YFUNCTION__
Definition Log.h:24
#define yWarning(...)
Definition Log.h:340
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:809
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:780
bool readTag(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:828
bool writeTag(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:801
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:771
bool readArgs(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:841
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:864
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:858
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:761
static constexpr size_t s_reply_len
Definition ILLMMsgs.cpp:290
static constexpr const char * s_help
Definition ILLMMsgs.cpp:292
static constexpr size_t s_tag_len
Definition ILLMMsgs.cpp:288
static constexpr const char * s_tag
Definition ILLMMsgs.cpp:287
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:756
static constexpr const char * s_prototype
Definition ILLMMsgs.cpp:291
void call(ILLMMsgs *ptr)
Definition ILLMMsgs.cpp:899
static constexpr size_t s_cmd_len
Definition ILLMMsgs.cpp:289
return_ask(*)(const std::string &) funcptr_t
Definition ILLMMsgs.cpp:281
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
bool readTag(yarp::os::idl::WireReader &reader)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_prototype
Definition ILLMMsgs.cpp:407
yarp::dev::ReturnValue(*)() funcptr_t
Definition ILLMMsgs.cpp:397
static constexpr const char * s_tag
Definition ILLMMsgs.cpp:403
static constexpr const char * s_help
Definition ILLMMsgs.cpp:408
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:969
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:924
bool writeTag(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:945
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:953
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:915
bool readArgs(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:982
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:997
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:991
static constexpr const char * s_tag
Definition ILLMMsgs.cpp:345
static constexpr const char * s_prototype
Definition ILLMMsgs.cpp:349
return_getConversation(*)() funcptr_t
Definition ILLMMsgs.cpp:339
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:910
static constexpr const char * s_help
Definition ILLMMsgs.cpp:350
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:905
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:40
yarp::os::ApplicationNetworkProtocolVersion helper_proto
Definition ILLMMsgs.cpp:37
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:52
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:628
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:666
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:637
bool writeTag(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:658
bool readTag(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:682
bool readArgs(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:695
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:710
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:704
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:623
static constexpr const char * s_prototype
Definition ILLMMsgs.cpp:228
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:618
return_readPrompt(*)() funcptr_t
Definition ILLMMsgs.cpp:218
static constexpr size_t s_cmd_len
Definition ILLMMsgs.cpp:226
static constexpr const char * s_tag
Definition ILLMMsgs.cpp:224
static constexpr size_t s_reply_len
Definition ILLMMsgs.cpp:227
static constexpr size_t s_tag_len
Definition ILLMMsgs.cpp:225
static constexpr const char * s_help
Definition ILLMMsgs.cpp:229
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_prototype
Definition ILLMMsgs.cpp:465
static constexpr const char * s_help
Definition ILLMMsgs.cpp:466
static constexpr const char * s_tag
Definition ILLMMsgs.cpp:461
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:499
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:528
bool writeTag(const yarp::os::idl::WireWriter &writer) const
Definition ILLMMsgs.cpp:520
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:490
bool readArgs(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:560
bool readTag(yarp::os::idl::WireReader &reader)
Definition ILLMMsgs.cpp:547
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:577
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:583
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition ILLMMsgs.cpp:475
static constexpr const char * s_help
Definition ILLMMsgs.cpp:171
static constexpr size_t s_reply_len
Definition ILLMMsgs.cpp:169
static constexpr const char * s_tag
Definition ILLMMsgs.cpp:166
static constexpr size_t s_cmd_len
Definition ILLMMsgs.cpp:168
static constexpr size_t s_tag_len
Definition ILLMMsgs.cpp:167
static constexpr const char * s_prototype
Definition ILLMMsgs.cpp:170
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition ILLMMsgs.cpp:480
yarp::dev::ReturnValue(*)(const std::string &) funcptr_t
Definition ILLMMsgs.cpp:160
virtual yarp::dev::ReturnValue deleteConversation()
virtual yarp::dev::ReturnValue refreshConversation()
virtual bool checkProtocolVersion()
Definition ILLMMsgs.cpp:83
virtual return_ask ask(const std::string &question)
virtual yarp::dev::ReturnValue setPrompt(const std::string &prompt)
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual return_readPrompt readPrompt()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
Definition ILLMMsgs.cpp:98
virtual return_getConversation getConversation()
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
Definition ILLMMsgs.cpp:68
@ return_value_error_nws_nwc_communication_error
Method is not (yet) implemented.
yarp::dev::ReturnValue ret
Definition return_ask.h:26
yarp::dev::ReturnValue ret
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Definition Portable.h:25
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
Definition Wire.h:28
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
IDL-friendly connection reader.
Definition WireReader.h:27
bool readString(std::string &str, bool *is_vocab=nullptr)
std::string readTag(size_t len=static_cast< size_t >(-1))
bool read(WirePortable &obj)
IDL-friendly connection writer.
Definition WireWriter.h:28
bool write(const WirePortable &obj) const
bool writeListHeader(int len) const
bool writeTag(const char *tag, int split, int len) const
bool writeString(const std::string &str, bool skip_tag=false) const
bool writeListBegin(int tag, size_t len) const
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
The main, catch-all namespace for YARP.
Definition dirs.h:16
#define YARP_VERSION_PATCH
Definition version.h:12
#define YARP_VERSION_MAJOR
Definition version.h:10
#define YARP_VERSION_MINOR
Definition version.h:11