YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ISpeechTranscriptionMsgs.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>
15#include <yarp/os/LogStream.h>
16
18
19#include <algorithm>
20
21namespace
22{
23 YARP_LOG_COMPONENT(SERVICE_LOG_COMPONENT, "ISpeechTranscriptionMsgs")
24}
25
26//ISpeechTranscriptionMsgs_getRemoteProtocolVersion_helper declaration
37
39{
40 yarp::os::idl::WireWriter writer(connection);
41 if (!writer.writeListHeader(1)) {
42 return false;
43 }
44 if (!writer.writeString("getRemoteProtocolVersion")) {
45 return false;
46 }
47 return true;
48}
49
50bool ISpeechTranscriptionMsgs_getRemoteProtocolVersion_helper ::read(yarp::os::ConnectionReader & connection)
51 {
52 yarp::os::idl::WireReader reader(connection);
53 if (!reader.readListHeader()) {
54 reader.fail();
55 return false;
56 }
57
58 if (!helper_proto.read(connection)) {
59 reader.fail();
60 return false;
61 }
62 return true;
63}
64
65//ProtocolVersion, client side
67 {
68 if(!yarp().canWrite()) {
69 yError(" Missing server method ISpeechTranscriptionMsgs::getRemoteProtocolVersion");
70 }
72 bool ok = yarp().write(helper, helper);
73 if (ok) {
74 return helper.helper_proto;}
75 else {
77 return failureproto;}
78}
79
80//ProtocolVersion, client side
82 {
83 auto locproto = this->getLocalProtocolVersion();
84 auto remproto = this->getRemoteProtocolVersion();
85 if (remproto.protocol_version != locproto.protocol_version)
86 {
87 yCError(SERVICE_LOG_COMPONENT) << "Invalid communication protocol.";
88 yCError(SERVICE_LOG_COMPONENT) << "Local Protocol Version: " << locproto.toString();
89 yCError(SERVICE_LOG_COMPONENT) << "Remote Protocol Version: " << remproto.toString();
90 return false;
91 }
92 return true;
93}
94
95//ProtocolVersion, server side
97{
99 //myproto.protocol_version using default value = 0
100 //to change this value add the following line to the .thrift file:
101 //const i16 protocol_version = <your_number_here>
102 myproto.protocol_version = 0;
106 return myproto;
107}
108
109// set_language helper class declaration
111 public yarp::os::Portable
112{
113public:
115 explicit ISpeechTranscriptionMsgs_set_language_helper(const std::string& language);
116 bool write(yarp::os::ConnectionWriter& connection) const override;
117 bool read(yarp::os::ConnectionReader& connection) override;
118
119 class Command :
121 {
122 public:
123 Command() = default;
124 explicit Command(const std::string& language);
125
126 ~Command() override = default;
127
128 bool write(yarp::os::ConnectionWriter& connection) const override;
129 bool read(yarp::os::ConnectionReader& connection) override;
130
131 bool write(const yarp::os::idl::WireWriter& writer) const override;
132 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
133 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
134
135 bool read(yarp::os::idl::WireReader& reader) override;
138
139 std::string language{};
140 };
141
142 class Reply :
144 {
145 public:
146 Reply() = default;
147 ~Reply() override = default;
148
149 bool write(yarp::os::ConnectionWriter& connection) const override;
150 bool read(yarp::os::ConnectionReader& connection) override;
151
152 bool write(const yarp::os::idl::WireWriter& writer) const override;
153 bool read(yarp::os::idl::WireReader& reader) override;
154
156 };
157
158 using funcptr_t = return_set_language (*)(const std::string&);
160
163
164 static constexpr const char* s_tag{"set_language"};
165 static constexpr size_t s_tag_len{2};
166 static constexpr size_t s_cmd_len{3};
167 static constexpr size_t s_reply_len{1};
168 static constexpr const char* s_prototype{"return_set_language ISpeechTranscriptionMsgs::set_language(const std::string& language)"};
169 static constexpr const char* s_help{""};
170};
171
172// get_language helper class declaration
174 public yarp::os::Portable
175{
176public:
178 bool write(yarp::os::ConnectionWriter& connection) const override;
179 bool read(yarp::os::ConnectionReader& connection) override;
180
181 class Command :
183 {
184 public:
185 Command() = default;
186 ~Command() override = default;
187
188 bool write(yarp::os::ConnectionWriter& connection) const override;
189 bool read(yarp::os::ConnectionReader& connection) override;
190
191 bool write(const yarp::os::idl::WireWriter& writer) const override;
192 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
193 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
194
195 bool read(yarp::os::idl::WireReader& reader) override;
198 };
199
200 class Reply :
202 {
203 public:
204 Reply() = default;
205 ~Reply() override = default;
206
207 bool write(yarp::os::ConnectionWriter& connection) const override;
208 bool read(yarp::os::ConnectionReader& connection) override;
209
210 bool write(const yarp::os::idl::WireWriter& writer) const override;
211 bool read(yarp::os::idl::WireReader& reader) override;
212
214 };
215
218
221
222 static constexpr const char* s_tag{"get_language"};
223 static constexpr size_t s_tag_len{2};
224 static constexpr size_t s_cmd_len{2};
225 static constexpr size_t s_reply_len{2};
226 static constexpr const char* s_prototype{"return_get_language ISpeechTranscriptionMsgs::get_language()"};
227 static constexpr const char* s_help{""};
228};
229
230// transcribe helper class declaration
232 public yarp::os::Portable
233{
234public:
237 bool write(yarp::os::ConnectionWriter& connection) const override;
238 bool read(yarp::os::ConnectionReader& connection) override;
239
240 class Command :
242 {
243 public:
244 Command() = default;
245 explicit Command(const yarp::sig::Sound& sound);
246
247 ~Command() override = default;
248
249 bool write(yarp::os::ConnectionWriter& connection) const override;
250 bool read(yarp::os::ConnectionReader& connection) override;
251
252 bool write(const yarp::os::idl::WireWriter& writer) const override;
253 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
254 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
255
256 bool read(yarp::os::idl::WireReader& reader) override;
259
261 };
262
263 class Reply :
265 {
266 public:
267 Reply() = default;
268 ~Reply() override = default;
269
270 bool write(yarp::os::ConnectionWriter& connection) const override;
271 bool read(yarp::os::ConnectionReader& connection) override;
272
273 bool write(const yarp::os::idl::WireWriter& writer) const override;
274 bool read(yarp::os::idl::WireReader& reader) override;
275
277 };
278
281
284
285 static constexpr const char* s_tag{"transcribe"};
286 static constexpr size_t s_tag_len{1};
287 static constexpr size_t s_cmd_len{2};
288 static constexpr size_t s_reply_len{3};
289 static constexpr const char* s_prototype{"return_transcribe ISpeechTranscriptionMsgs::transcribe(const yarp::sig::Sound& sound)"};
290 static constexpr const char* s_help{""};
291};
292
293// set_language helper class implementation
298
300{
301 return cmd.write(connection);
302}
303
308
310 language{language}
311{
312}
313
315{
316 yarp::os::idl::WireWriter writer(connection);
317 if (!writer.writeListHeader(s_cmd_len)) {
318 return false;
319 }
320 return write(writer);
321}
322
324{
325 yarp::os::idl::WireReader reader(connection);
326 if (!reader.readListHeader()) {
327 reader.fail();
328 return false;
329 }
330 return read(reader);
331}
332
334{
335 if (!writeTag(writer)) {
336 return false;
337 }
338 if (!writeArgs(writer)) {
339 return false;
340 }
341 return true;
342}
343
345{
346 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
347 return false;
348 }
349 return true;
350}
351
353{
354 if (!writer.writeString(language)) {
355 return false;
356 }
357 return true;
358}
359
361{
362 if (!readTag(reader)) {
363 return false;
364 }
365 if (!readArgs(reader)) {
366 return false;
367 }
368 return true;
369}
370
372{
373 std::string tag = reader.readTag(s_tag_len);
374 if (reader.isError()) {
375 return false;
376 }
377 if (tag != s_tag) {
378 reader.fail();
379 return false;
380 }
381 return true;
382}
383
385{
386 if (reader.noMore()) {
387 reader.fail();
388 return false;
389 }
390 if (!reader.readString(language)) {
391 reader.fail();
392 return false;
393 }
394 if (!reader.noMore()) {
395 reader.fail();
396 return false;
397 }
398 return true;
399}
400
402{
403 yarp::os::idl::WireWriter writer(connection);
404 return write(writer);
405}
406
412
414{
415 if (!writer.isNull()) {
416 if (!writer.writeListHeader(s_reply_len)) {
417 return false;
418 }
419 if (!writer.write(return_helper)) {
420 return false;
421 }
422 }
423 return true;
424}
425
427{
428 if (!reader.readListReturn()) {
429 return false;
430 }
431 if (reader.noMore()) {
432 reader.fail();
433 return false;
434 }
435 if (!reader.read(return_helper)) {
436 reader.fail();
437 return false;
438 }
439 return true;
440}
441
446
447// get_language helper class implementation
449{
450 return cmd.write(connection);
451}
452
457
459{
460 yarp::os::idl::WireWriter writer(connection);
461 if (!writer.writeListHeader(s_cmd_len)) {
462 return false;
463 }
464 return write(writer);
465}
466
468{
469 yarp::os::idl::WireReader reader(connection);
470 if (!reader.readListHeader()) {
471 reader.fail();
472 return false;
473 }
474 return read(reader);
475}
476
478{
479 if (!writeTag(writer)) {
480 return false;
481 }
482 if (!writeArgs(writer)) {
483 return false;
484 }
485 return true;
486}
487
489{
490 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
491 return false;
492 }
493 return true;
494}
495
497{
498 return true;
499}
500
502{
503 if (!readTag(reader)) {
504 return false;
505 }
506 if (!readArgs(reader)) {
507 return false;
508 }
509 return true;
510}
511
513{
514 std::string tag = reader.readTag(s_tag_len);
515 if (reader.isError()) {
516 return false;
517 }
518 if (tag != s_tag) {
519 reader.fail();
520 return false;
521 }
522 return true;
523}
524
526{
527 if (!reader.noMore()) {
528 reader.fail();
529 return false;
530 }
531 return true;
532}
533
535{
536 yarp::os::idl::WireWriter writer(connection);
537 return write(writer);
538}
539
545
547{
548 if (!writer.isNull()) {
549 if (!writer.writeListHeader(s_reply_len)) {
550 return false;
551 }
552 if (!writer.write(return_helper)) {
553 return false;
554 }
555 }
556 return true;
557}
558
560{
561 if (!reader.readListReturn()) {
562 return false;
563 }
564 if (reader.noMore()) {
565 reader.fail();
566 return false;
567 }
568 if (!reader.read(return_helper)) {
569 reader.fail();
570 return false;
571 }
572 return true;
573}
574
579
580// transcribe helper class implementation
585
587{
588 return cmd.write(connection);
589}
590
595
600
602{
603 yarp::os::idl::WireWriter writer(connection);
604 if (!writer.writeListHeader(s_cmd_len)) {
605 return false;
606 }
607 return write(writer);
608}
609
611{
612 yarp::os::idl::WireReader reader(connection);
613 if (!reader.readListHeader()) {
614 reader.fail();
615 return false;
616 }
617 return read(reader);
618}
619
621{
622 if (!writeTag(writer)) {
623 return false;
624 }
625 if (!writeArgs(writer)) {
626 return false;
627 }
628 return true;
629}
630
632{
633 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
634 return false;
635 }
636 return true;
637}
638
640{
641 if (!writer.writeNested(sound)) {
642 return false;
643 }
644 return true;
645}
646
648{
649 if (!readTag(reader)) {
650 return false;
651 }
652 if (!readArgs(reader)) {
653 return false;
654 }
655 return true;
656}
657
659{
660 std::string tag = reader.readTag(s_tag_len);
661 if (reader.isError()) {
662 return false;
663 }
664 if (tag != s_tag) {
665 reader.fail();
666 return false;
667 }
668 return true;
669}
670
672{
673 if (reader.noMore()) {
674 reader.fail();
675 return false;
676 }
677 if (!reader.readNested(sound)) {
678 reader.fail();
679 return false;
680 }
681 if (!reader.noMore()) {
682 reader.fail();
683 return false;
684 }
685 return true;
686}
687
689{
690 yarp::os::idl::WireWriter writer(connection);
691 return write(writer);
692}
693
695{
696 yarp::os::idl::WireReader reader(connection);
697 return read(reader);
698}
699
701{
702 if (!writer.isNull()) {
703 if (!writer.writeListHeader(s_reply_len)) {
704 return false;
705 }
706 if (!writer.write(return_helper)) {
707 return false;
708 }
709 }
710 return true;
711}
712
714{
715 if (!reader.readListReturn()) {
716 return false;
717 }
718 if (reader.noMore()) {
719 reader.fail();
720 return false;
721 }
722 if (!reader.read(return_helper)) {
723 reader.fail();
724 return false;
725 }
726 return true;
727}
728
733
734// Constructor
739
741{
742 if (!yarp().canWrite()) {
744 }
746 bool ok = yarp().write(helper, helper);
747 if (!ok) {
748 return_set_language failed_reply{};
750 return failed_reply;
751 }
752 return helper.reply.return_helper;
753}
754
756{
757 if (!yarp().canWrite()) {
759 }
761 bool ok = yarp().write(helper, helper);
762 if (!ok) {
763 return_get_language failed_reply{};
765 return failed_reply;
766 }
767 return helper.reply.return_helper;
768}
769
771{
772 if (!yarp().canWrite()) {
774 }
776 bool ok = yarp().write(helper, helper);
777 if (!ok) {
778 return_transcribe failed_reply{};
780 return failed_reply;
781 }
782 return helper.reply.return_helper;
783}
784
785// help method
786std::vector<std::string> ISpeechTranscriptionMsgs::help(const std::string& functionName)
787{
788 bool showAll = (functionName == "--all");
789 std::vector<std::string> helpString;
790 if (showAll) {
791 helpString.emplace_back("*** Available commands:");
795 helpString.emplace_back("help");
796 } else {
799 }
802 }
805 }
806 if (functionName == "help") {
807 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
808 helpString.emplace_back("Return list of available commands, or help message for a specific function");
809 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");
810 helpString.emplace_back("@return list of strings (one string per line)");
811 }
812 }
813 if (helpString.empty()) {
814 helpString.emplace_back("Command not found");
815 }
816 return helpString;
817}
818
819// read from ConnectionReader
821{
822 constexpr size_t max_tag_len = 2;
823 size_t tag_len = 1;
824
825 yarp::os::idl::WireReader reader(connection);
826 reader.expectAccept();
827 if (!reader.readListHeader()) {
828 reader.fail();
829 return false;
830 }
831
832 std::string tag = reader.readTag(1);
833 bool direct = (tag == "__direct__");
834 if (direct) {
835 tag = reader.readTag(1);
836 }
837 while (tag_len <= max_tag_len && !reader.isError()) {
838 if(tag == "getRemoteProtocolVersion") {
839 if (!reader.noMore()) {
840 yError("Reader invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
841 reader.fail();
842 return false;
843 }
844
845 auto proto = getLocalProtocolVersion();
846
847 yarp::os::idl::WireWriter writer(reader);
848 if (!writer.writeListHeader(1)) {
849 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
850 return false;}
851 if (!writer.write(proto)) {
852 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
853 return false;
854 }
855 reader.accept();
856 return true;
857 }
860 if (!helper.cmd.readArgs(reader)) {
861 return false;
862 }
863
864 helper.call(this);
865
866 yarp::os::idl::WireWriter writer(reader);
867 if (!helper.reply.write(writer)) {
868 return false;
869 }
870 reader.accept();
871 return true;
872 }
875 if (!helper.cmd.readArgs(reader)) {
876 return false;
877 }
878
879 helper.call(this);
880
881 yarp::os::idl::WireWriter writer(reader);
882 if (!helper.reply.write(writer)) {
883 return false;
884 }
885 reader.accept();
886 return true;
887 }
890 if (!helper.cmd.readArgs(reader)) {
891 return false;
892 }
893
894 helper.call(this);
895
896 yarp::os::idl::WireWriter writer(reader);
897 if (!helper.reply.write(writer)) {
898 return false;
899 }
900 reader.accept();
901 return true;
902 }
903 if (tag == "help") {
904 std::string functionName;
905 if (!reader.readString(functionName)) {
906 functionName = "--all";
907 }
908 auto help_strings = help(functionName);
909 yarp::os::idl::WireWriter writer(reader);
910 if (!writer.isNull()) {
911 if (!writer.writeListHeader(2)) {
912 return false;
913 }
914 if (!writer.writeTag("many", 1, 0)) {
915 return false;
916 }
917 if (!writer.writeListBegin(0, help_strings.size())) {
918 return false;
919 }
920 for (const auto& help_string : help_strings) {
921 if (!writer.writeString(help_string)) {
922 return false;
923 }
924 }
925 if (!writer.writeListEnd()) {
926 return false;
927 }
928 }
929 reader.accept();
930 return true;
931 }
932 if (reader.noMore()) {
933 reader.fail();
934 return false;
935 }
936 std::string next_tag = reader.readTag(1);
937 if (next_tag.empty()) {
938 break;
939 }
940 tag.append("_").append(next_tag);
941 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
942 }
943 return false;
944}
#define yError(...)
Definition Log.h:361
#define __YFUNCTION__
Definition Log.h:24
#define yWarning(...)
Definition Log.h:340
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 writeTag(const yarp::os::idl::WireWriter &writer) const
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 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.
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 writeTag(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
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.
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.
return_set_language(*)(const std::string &) funcptr_t
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
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.
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.
return_transcribe(*)(const yarp::sig::Sound &) funcptr_t
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual return_transcribe transcribe(const yarp::sig::Sound &sound)
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
virtual return_set_language set_language(const std::string &language)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual return_get_language get_language()
virtual std::vector< std::string > help(const std::string &functionName="--all")
yarp::dev::ReturnValue ret
yarp::dev::ReturnValue ret
yarp::dev::ReturnValue ret
@ return_value_error_nws_nwc_communication_error
Method is not (yet) implemented.
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 readNested(WirePortable &obj)
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 writeNested(const WirePortable &obj) const
bool writeListBegin(int tag, size_t len) const
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition Sound.h:39
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
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