YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FrameTransformStorageGetRPC.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6// Autogenerated by Thrift Compiler (0.14.1-yarped)
7//
8// This is an automatically generated file.
9// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
10
12
14
15#include <algorithm>
16
17// getTransformsRPC helper class declaration
20{
21public:
23 bool write(yarp::os::ConnectionWriter& connection) const override;
24 bool read(yarp::os::ConnectionReader& connection) override;
25
26 class Command :
28 {
29 public:
30 Command() = default;
31 ~Command() override = default;
32
33 bool write(yarp::os::ConnectionWriter& connection) const override;
34 bool read(yarp::os::ConnectionReader& connection) override;
35
36 bool write(const yarp::os::idl::WireWriter& writer) const override;
37 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
38 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
39
40 bool read(yarp::os::idl::WireReader& reader) override;
43 };
44
45 class Reply :
47 {
48 public:
49 Reply() = default;
50 ~Reply() override = default;
51
52 bool write(yarp::os::ConnectionWriter& connection) const override;
53 bool read(yarp::os::ConnectionReader& connection) override;
54
55 bool write(const yarp::os::idl::WireWriter& writer) const override;
56 bool read(yarp::os::idl::WireReader& reader) override;
57
59 };
60
63
66
67 static constexpr const char* s_tag{"getTransformsRPC"};
68 static constexpr size_t s_tag_len{1};
69 static constexpr size_t s_cmd_len{1};
70 static constexpr size_t s_reply_len{2};
71 static constexpr const char* s_prototype{"return_getAllTransforms FrameTransformStorageGetRPC::getTransformsRPC()"};
72 static constexpr const char* s_help{""};
73};
74
75// getTransformsRPC helper class implementation
80
85
87{
88 yarp::os::idl::WireWriter writer(connection);
89 if (!writer.writeListHeader(s_cmd_len)) {
90 return false;
91 }
92 return write(writer);
93}
94
96{
97 yarp::os::idl::WireReader reader(connection);
98 if (!reader.readListHeader()) {
99 reader.fail();
100 return false;
101 }
102 return read(reader);
103}
104
106{
107 if (!writeTag(writer)) {
108 return false;
109 }
110 if (!writeArgs(writer)) {
111 return false;
112 }
113 return true;
114}
115
117{
118 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
119 return false;
120 }
121 return true;
122}
123
125{
126 return true;
127}
128
130{
131 if (!readTag(reader)) {
132 return false;
133 }
134 if (!readArgs(reader)) {
135 return false;
136 }
137 return true;
138}
139
141{
142 std::string tag = reader.readTag(s_tag_len);
143 if (reader.isError()) {
144 return false;
145 }
146 if (tag != s_tag) {
147 reader.fail();
148 return false;
149 }
150 return true;
151}
152
154{
155 if (!reader.noMore()) {
156 reader.fail();
157 return false;
158 }
159 return true;
160}
161
167
173
175{
176 if (!writer.isNull()) {
177 if (!writer.writeListHeader(s_reply_len)) {
178 return false;
179 }
180 if (!writer.write(return_helper)) {
181 return false;
182 }
183 }
184 return true;
185}
186
188{
189 if (!reader.readListReturn()) {
190 return false;
191 }
192 if (reader.noMore()) {
193 reader.fail();
194 return false;
195 }
196 if (!reader.read(return_helper)) {
197 reader.fail();
198 return false;
199 }
200 return true;
201}
202
207
208// Constructor
213
215{
216 if (!yarp().canWrite()) {
218 }
220 bool ok = yarp().write(helper, helper);
221 return ok ? helper.reply.return_helper : return_getAllTransforms{};
222}
223
224// help method
225std::vector<std::string> FrameTransformStorageGetRPC::help(const std::string& functionName)
226{
227 bool showAll = (functionName == "--all");
228 std::vector<std::string> helpString;
229 if (showAll) {
230 helpString.emplace_back("*** Available commands:");
232 helpString.emplace_back("help");
233 } else {
236 }
237 if (functionName == "help") {
238 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
239 helpString.emplace_back("Return list of available commands, or help message for a specific function");
240 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");
241 helpString.emplace_back("@return list of strings (one string per line)");
242 }
243 }
244 if (helpString.empty()) {
245 helpString.emplace_back("Command not found");
246 }
247 return helpString;
248}
249
250// read from ConnectionReader
252{
253 constexpr size_t max_tag_len = 1;
254 size_t tag_len = 1;
255
256 yarp::os::idl::WireReader reader(connection);
257 reader.expectAccept();
258 if (!reader.readListHeader()) {
259 reader.fail();
260 return false;
261 }
262
263 std::string tag = reader.readTag(1);
264 bool direct = (tag == "__direct__");
265 if (direct) {
266 tag = reader.readTag(1);
267 }
268 while (tag_len <= max_tag_len && !reader.isError()) {
271 if (!helper.cmd.readArgs(reader)) {
272 return false;
273 }
274
275 helper.call(this);
276
277 yarp::os::idl::WireWriter writer(reader);
278 if (!helper.reply.write(writer)) {
279 return false;
280 }
281 reader.accept();
282 return true;
283 }
284 if (tag == "help") {
285 std::string functionName;
286 if (!reader.readString(functionName)) {
287 functionName = "--all";
288 }
289 auto help_strings = help(functionName);
290 yarp::os::idl::WireWriter writer(reader);
291 if (!writer.isNull()) {
292 if (!writer.writeListHeader(2)) {
293 return false;
294 }
295 if (!writer.writeTag("many", 1, 0)) {
296 return false;
297 }
298 if (!writer.writeListBegin(0, help_strings.size())) {
299 return false;
300 }
301 for (const auto& help_string : help_strings) {
302 if (!writer.writeString(help_string)) {
303 return false;
304 }
305 }
306 if (!writer.writeListEnd()) {
307 return false;
308 }
309 }
310 reader.accept();
311 return true;
312 }
313 if (reader.noMore()) {
314 reader.fail();
315 return false;
316 }
317 std::string next_tag = reader.readTag(1);
318 if (next_tag.empty()) {
319 break;
320 }
321 tag.append("_").append(next_tag);
322 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
323 }
324 return false;
325}
#define yError(...)
Definition Log.h:361
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
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 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 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.
virtual return_getAllTransforms getTransformsRPC()
virtual std::vector< std::string > help(const std::string &functionName="--all")
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
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
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
The main, catch-all namespace for YARP.
Definition dirs.h:16