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
11#include <yarp/conf/version.h>
14#include <yarp/os/LogStream.h>
15
17
18#include <algorithm>
19
20namespace
21{
22 YARP_LOG_COMPONENT(SERVICE_LOG_COMPONENT, "FrameTransformStorageGetRPC")
23}
24
25//FrameTransformStorageGetRPC_getRemoteProtocolVersion_helper declaration
36
38{
39 yarp::os::idl::WireWriter writer(connection);
40 if (!writer.writeListHeader(1)) {
41 return false;
42 }
43 if (!writer.writeString("getRemoteProtocolVersion")) {
44 return false;
45 }
46 return true;
47}
48
49bool FrameTransformStorageGetRPC_getRemoteProtocolVersion_helper ::read(yarp::os::ConnectionReader & connection)
50 {
51 yarp::os::idl::WireReader reader(connection);
52 if (!reader.readListHeader()) {
53 reader.fail();
54 return false;
55 }
56
57 if (!helper_proto.read(connection)) {
58 reader.fail();
59 return false;
60 }
61 return true;
62}
63
64//ProtocolVersion, client side
66 {
67 if(!yarp().canWrite()) {
68 yError(" Missing server method FrameTransformStorageGetRPC::getRemoteProtocolVersion");
69 }
71 bool ok = yarp().write(helper, helper);
72 if (ok) {
73 return helper.helper_proto;}
74 else {
76 return failureproto;}
77}
78
79//ProtocolVersion, client side
81 {
82 auto locproto = this->getLocalProtocolVersion();
83 auto remproto = this->getRemoteProtocolVersion();
84 if (remproto.protocol_version != locproto.protocol_version)
85 {
86 yCError(SERVICE_LOG_COMPONENT) << "Invalid communication protocol.";
87 yCError(SERVICE_LOG_COMPONENT) << "Local Protocol Version: " << locproto.toString();
88 yCError(SERVICE_LOG_COMPONENT) << "Remote Protocol Version: " << remproto.toString();
89 return false;
90 }
91 return true;
92}
93
94//ProtocolVersion, server side
96{
98 //myproto.protocol_version using default value = 0
99 //to change this value add the following line to the .thrift file:
100 //const i16 protocol_version = <your_number_here>
101 myproto.protocol_version = 0;
105 return myproto;
106}
107
108// getTransformsRPC helper class declaration
110 public yarp::os::Portable
111{
112public:
114 bool write(yarp::os::ConnectionWriter& connection) const override;
115 bool read(yarp::os::ConnectionReader& connection) override;
116
117 class Command :
119 {
120 public:
121 Command() = default;
122 ~Command() override = default;
123
124 bool write(yarp::os::ConnectionWriter& connection) const override;
125 bool read(yarp::os::ConnectionReader& connection) override;
126
127 bool write(const yarp::os::idl::WireWriter& writer) const override;
128 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
129 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
130
131 bool read(yarp::os::idl::WireReader& reader) override;
134 };
135
136 class Reply :
138 {
139 public:
140 Reply() = default;
141 ~Reply() override = default;
142
143 bool write(yarp::os::ConnectionWriter& connection) const override;
144 bool read(yarp::os::ConnectionReader& connection) override;
145
146 bool write(const yarp::os::idl::WireWriter& writer) const override;
147 bool read(yarp::os::idl::WireReader& reader) override;
148
150 };
151
154
157
158 static constexpr const char* s_tag{"getTransformsRPC"};
159 static constexpr size_t s_tag_len{1};
160 static constexpr size_t s_cmd_len{1};
161 static constexpr size_t s_reply_len{2};
162 static constexpr const char* s_prototype{"return_getAllTransforms FrameTransformStorageGetRPC::getTransformsRPC()"};
163 static constexpr const char* s_help{""};
164};
165
166// getTransformsRPC helper class implementation
171
176
178{
179 yarp::os::idl::WireWriter writer(connection);
180 if (!writer.writeListHeader(s_cmd_len)) {
181 return false;
182 }
183 return write(writer);
184}
185
187{
188 yarp::os::idl::WireReader reader(connection);
189 if (!reader.readListHeader()) {
190 reader.fail();
191 return false;
192 }
193 return read(reader);
194}
195
197{
198 if (!writeTag(writer)) {
199 return false;
200 }
201 if (!writeArgs(writer)) {
202 return false;
203 }
204 return true;
205}
206
208{
209 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
210 return false;
211 }
212 return true;
213}
214
216{
217 return true;
218}
219
221{
222 if (!readTag(reader)) {
223 return false;
224 }
225 if (!readArgs(reader)) {
226 return false;
227 }
228 return true;
229}
230
232{
233 std::string tag = reader.readTag(s_tag_len);
234 if (reader.isError()) {
235 return false;
236 }
237 if (tag != s_tag) {
238 reader.fail();
239 return false;
240 }
241 return true;
242}
243
245{
246 if (!reader.noMore()) {
247 reader.fail();
248 return false;
249 }
250 return true;
251}
252
258
264
266{
267 if (!writer.isNull()) {
268 if (!writer.writeListHeader(s_reply_len)) {
269 return false;
270 }
271 if (!writer.write(return_helper)) {
272 return false;
273 }
274 }
275 return true;
276}
277
279{
280 if (!reader.readListReturn()) {
281 return false;
282 }
283 if (reader.noMore()) {
284 reader.fail();
285 return false;
286 }
287 if (!reader.read(return_helper)) {
288 reader.fail();
289 return false;
290 }
291 return true;
292}
293
298
299// Constructor
304
306{
307 if (!yarp().canWrite()) {
309 }
311 bool ok = yarp().write(helper, helper);
312 return ok ? helper.reply.return_helper : return_getAllTransforms{};
313}
314
315// help method
316std::vector<std::string> FrameTransformStorageGetRPC::help(const std::string& functionName)
317{
318 bool showAll = (functionName == "--all");
319 std::vector<std::string> helpString;
320 if (showAll) {
321 helpString.emplace_back("*** Available commands:");
323 helpString.emplace_back("help");
324 } else {
327 }
328 if (functionName == "help") {
329 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
330 helpString.emplace_back("Return list of available commands, or help message for a specific function");
331 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");
332 helpString.emplace_back("@return list of strings (one string per line)");
333 }
334 }
335 if (helpString.empty()) {
336 helpString.emplace_back("Command not found");
337 }
338 return helpString;
339}
340
341// read from ConnectionReader
343{
344 constexpr size_t max_tag_len = 1;
345 size_t tag_len = 1;
346
347 yarp::os::idl::WireReader reader(connection);
348 reader.expectAccept();
349 if (!reader.readListHeader()) {
350 reader.fail();
351 return false;
352 }
353
354 std::string tag = reader.readTag(1);
355 bool direct = (tag == "__direct__");
356 if (direct) {
357 tag = reader.readTag(1);
358 }
359 while (tag_len <= max_tag_len && !reader.isError()) {
360 if(tag == "getRemoteProtocolVersion") {
361 if (!reader.noMore()) {
362 yError("Reader invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
363 reader.fail();
364 return false;
365 }
366
367 auto proto = getLocalProtocolVersion();
368
369 yarp::os::idl::WireWriter writer(reader);
370 if (!writer.writeListHeader(1)) {
371 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
372 return false;}
373 if (!writer.write(proto)) {
374 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
375 return false;
376 }
377 reader.accept();
378 return true;
379 }
382 if (!helper.cmd.readArgs(reader)) {
383 return false;
384 }
385
386 helper.call(this);
387
388 yarp::os::idl::WireWriter writer(reader);
389 if (!helper.reply.write(writer)) {
390 return false;
391 }
392 reader.accept();
393 return true;
394 }
395 if (tag == "help") {
396 std::string functionName;
397 if (!reader.readString(functionName)) {
398 functionName = "--all";
399 }
400 auto help_strings = help(functionName);
401 yarp::os::idl::WireWriter writer(reader);
402 if (!writer.isNull()) {
403 if (!writer.writeListHeader(2)) {
404 return false;
405 }
406 if (!writer.writeTag("many", 1, 0)) {
407 return false;
408 }
409 if (!writer.writeListBegin(0, help_strings.size())) {
410 return false;
411 }
412 for (const auto& help_string : help_strings) {
413 if (!writer.writeString(help_string)) {
414 return false;
415 }
416 }
417 if (!writer.writeListEnd()) {
418 return false;
419 }
420 }
421 reader.accept();
422 return true;
423 }
424 if (reader.noMore()) {
425 reader.fail();
426 return false;
427 }
428 std::string next_tag = reader.readTag(1);
429 if (next_tag.empty()) {
430 break;
431 }
432 tag.append("_").append(next_tag);
433 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
434 }
435 return false;
436}
#define yError(...)
Definition Log.h:361
#define __YFUNCTION__
Definition Log.h:24
#define yWarning(...)
Definition Log.h:340
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 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 yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
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
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,...)
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