YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
IOdometry2DMsgs.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>
12#include <IOdometry2DMsgs.h>
14#include <yarp/os/LogStream.h>
15
17
18#include <algorithm>
19
20namespace
21{
22 YARP_LOG_COMPONENT(SERVICE_LOG_COMPONENT, "IOdometry2DMsgs")
23}
24
25//IOdometry2DMsgs_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 IOdometry2DMsgs_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 IOdometry2DMsgs::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// reset_odometry_RPC 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
153 void call(IOdometry2DMsgs* ptr);
154
157
158 static constexpr const char* s_tag{"reset_odometry_RPC"};
159 static constexpr size_t s_tag_len{3};
160 static constexpr size_t s_cmd_len{3};
161 static constexpr size_t s_reply_len{1};
162 static constexpr const char* s_prototype{"yarp::dev::ReturnValue IOdometry2DMsgs::reset_odometry_RPC()"};
163 static constexpr const char* s_help{""};
164};
165
166// reset_odometry_RPC helper class implementation
168{
169 return cmd.write(connection);
170}
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
254{
255 yarp::os::idl::WireWriter writer(connection);
256 return write(writer);
257}
258
260{
261 yarp::os::idl::WireReader reader(connection);
262 return read(reader);
263}
264
266{
267 if (!writer.isNull()) {
268 if (!writer.write(return_helper)) {
269 return false;
270 }
271 }
272 return true;
273}
274
276{
277 if (reader.noMore()) {
278 reader.fail();
279 return false;
280 }
281 if (!reader.read(return_helper)) {
282 reader.fail();
283 return false;
284 }
285 return true;
286}
287
292
293// Constructor
295{
296 yarp().setOwner(*this);
297}
298
300{
301 if (!yarp().canWrite()) {
303 }
305 bool ok = yarp().write(helper, helper);
306 return ok ? helper.reply.return_helper : yarp::dev::ReturnValue{};
307}
308
309// help method
310std::vector<std::string> IOdometry2DMsgs::help(const std::string& functionName)
311{
312 bool showAll = (functionName == "--all");
313 std::vector<std::string> helpString;
314 if (showAll) {
315 helpString.emplace_back("*** Available commands:");
317 helpString.emplace_back("help");
318 } else {
321 }
322 if (functionName == "help") {
323 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
324 helpString.emplace_back("Return list of available commands, or help message for a specific function");
325 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");
326 helpString.emplace_back("@return list of strings (one string per line)");
327 }
328 }
329 if (helpString.empty()) {
330 helpString.emplace_back("Command not found");
331 }
332 return helpString;
333}
334
335// read from ConnectionReader
337{
338 constexpr size_t max_tag_len = 3;
339 size_t tag_len = 1;
340
341 yarp::os::idl::WireReader reader(connection);
342 reader.expectAccept();
343 if (!reader.readListHeader()) {
344 reader.fail();
345 return false;
346 }
347
348 std::string tag = reader.readTag(1);
349 bool direct = (tag == "__direct__");
350 if (direct) {
351 tag = reader.readTag(1);
352 }
353 while (tag_len <= max_tag_len && !reader.isError()) {
354 if(tag == "getRemoteProtocolVersion") {
355 if (!reader.noMore()) {
356 yError("Reader invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
357 reader.fail();
358 return false;
359 }
360
361 auto proto = getLocalProtocolVersion();
362
363 yarp::os::idl::WireWriter writer(reader);
364 if (!writer.writeListHeader(1)) {
365 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
366 return false;}
367 if (!writer.write(proto)) {
368 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
369 return false;
370 }
371 reader.accept();
372 return true;
373 }
376 if (!helper.cmd.readArgs(reader)) {
377 return false;
378 }
379
380 helper.call(this);
381
382 yarp::os::idl::WireWriter writer(reader);
383 if (!helper.reply.write(writer)) {
384 return false;
385 }
386 reader.accept();
387 return true;
388 }
389 if (tag == "help") {
390 std::string functionName;
391 if (!reader.readString(functionName)) {
392 functionName = "--all";
393 }
394 auto help_strings = help(functionName);
395 yarp::os::idl::WireWriter writer(reader);
396 if (!writer.isNull()) {
397 if (!writer.writeListHeader(2)) {
398 return false;
399 }
400 if (!writer.writeTag("many", 1, 0)) {
401 return false;
402 }
403 if (!writer.writeListBegin(0, help_strings.size())) {
404 return false;
405 }
406 for (const auto& help_string : help_strings) {
407 if (!writer.writeString(help_string)) {
408 return false;
409 }
410 }
411 if (!writer.writeListEnd()) {
412 return false;
413 }
414 }
415 reader.accept();
416 return true;
417 }
418 if (reader.noMore()) {
419 reader.fail();
420 return false;
421 }
422 std::string next_tag = reader.readTag(1);
423 if (next_tag.empty()) {
424 break;
425 }
426 tag.append("_").append(next_tag);
427 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
428 }
429 return false;
430}
#define yError(...)
Definition Log.h:361
#define __YFUNCTION__
Definition Log.h:24
#define yWarning(...)
Definition Log.h:340
yarp::os::ApplicationNetworkProtocolVersion helper_proto
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 readArgs(yarp::os::idl::WireReader &reader)
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool readTag(yarp::os::idl::WireReader &reader)
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 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
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 bool checkProtocolVersion()
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual yarp::dev::ReturnValue reset_odometry_RPC()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual std::vector< std::string > help(const std::string &functionName="--all")
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