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 (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 <IOdometry2DMsgs.h>
15#include <yarp/os/LogStream.h>
16
18
19#include <algorithm>
20
21namespace
22{
23 YARP_LOG_COMPONENT(SERVICE_LOG_COMPONENT, "IOdometry2DMsgs")
24}
25
26//IOdometry2DMsgs_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 IOdometry2DMsgs_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 IOdometry2DMsgs::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// reset_odometry_RPC helper class declaration
111 public yarp::os::Portable
112{
113public:
115 bool write(yarp::os::ConnectionWriter& connection) const override;
116 bool read(yarp::os::ConnectionReader& connection) override;
117
118 class Command :
120 {
121 public:
122 Command() = default;
123 ~Command() override = default;
124
125 bool write(yarp::os::ConnectionWriter& connection) const override;
126 bool read(yarp::os::ConnectionReader& connection) override;
127
128 bool write(const yarp::os::idl::WireWriter& writer) const override;
129 bool writeTag(const yarp::os::idl::WireWriter& writer) const;
130 bool writeArgs(const yarp::os::idl::WireWriter& writer) const;
131
132 bool read(yarp::os::idl::WireReader& reader) override;
135 };
136
137 class Reply :
139 {
140 public:
141 Reply() = default;
142 ~Reply() override = default;
143
144 bool write(yarp::os::ConnectionWriter& connection) const override;
145 bool read(yarp::os::ConnectionReader& connection) override;
146
147 bool write(const yarp::os::idl::WireWriter& writer) const override;
148 bool read(yarp::os::idl::WireReader& reader) override;
149
151 };
152
154 void call(IOdometry2DMsgs* ptr);
155
158
159 static constexpr const char* s_tag{"reset_odometry_RPC"};
160 static constexpr size_t s_tag_len{3};
161 static constexpr size_t s_cmd_len{3};
162 static constexpr size_t s_reply_len{1};
163 static constexpr const char* s_prototype{"yarp::dev::ReturnValue IOdometry2DMsgs::reset_odometry_RPC()"};
164 static constexpr const char* s_help{""};
165};
166
167// reset_odometry_RPC helper class implementation
169{
170 return cmd.write(connection);
171}
172
177
179{
180 yarp::os::idl::WireWriter writer(connection);
181 if (!writer.writeListHeader(s_cmd_len)) {
182 return false;
183 }
184 return write(writer);
185}
186
188{
189 yarp::os::idl::WireReader reader(connection);
190 if (!reader.readListHeader()) {
191 reader.fail();
192 return false;
193 }
194 return read(reader);
195}
196
198{
199 if (!writeTag(writer)) {
200 return false;
201 }
202 if (!writeArgs(writer)) {
203 return false;
204 }
205 return true;
206}
207
209{
210 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
211 return false;
212 }
213 return true;
214}
215
217{
218 return true;
219}
220
222{
223 if (!readTag(reader)) {
224 return false;
225 }
226 if (!readArgs(reader)) {
227 return false;
228 }
229 return true;
230}
231
233{
234 std::string tag = reader.readTag(s_tag_len);
235 if (reader.isError()) {
236 return false;
237 }
238 if (tag != s_tag) {
239 reader.fail();
240 return false;
241 }
242 return true;
243}
244
246{
247 if (!reader.noMore()) {
248 reader.fail();
249 return false;
250 }
251 return true;
252}
253
255{
256 yarp::os::idl::WireWriter writer(connection);
257 return write(writer);
258}
259
261{
262 yarp::os::idl::WireReader reader(connection);
263 return read(reader);
264}
265
267{
268 if (!writer.isNull()) {
269 if (!writer.write(return_helper)) {
270 return false;
271 }
272 }
273 return true;
274}
275
277{
278 if (reader.noMore()) {
279 reader.fail();
280 return false;
281 }
282 if (!reader.read(return_helper)) {
283 reader.fail();
284 return false;
285 }
286 return true;
287}
288
293
294// Constructor
296{
297 yarp().setOwner(*this);
298}
299
301{
302 if (!yarp().canWrite()) {
304 }
306 bool ok = yarp().write(helper, helper);
308}
309
310// help method
311std::vector<std::string> IOdometry2DMsgs::help(const std::string& functionName)
312{
313 bool showAll = (functionName == "--all");
314 std::vector<std::string> helpString;
315 if (showAll) {
316 helpString.emplace_back("*** Available commands:");
318 helpString.emplace_back("help");
319 } else {
322 }
323 if (functionName == "help") {
324 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
325 helpString.emplace_back("Return list of available commands, or help message for a specific function");
326 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");
327 helpString.emplace_back("@return list of strings (one string per line)");
328 }
329 }
330 if (helpString.empty()) {
331 helpString.emplace_back("Command not found");
332 }
333 return helpString;
334}
335
336// read from ConnectionReader
338{
339 constexpr size_t max_tag_len = 3;
340 size_t tag_len = 1;
341
342 yarp::os::idl::WireReader reader(connection);
343 reader.expectAccept();
344 if (!reader.readListHeader()) {
345 reader.fail();
346 return false;
347 }
348
349 std::string tag = reader.readTag(1);
350 bool direct = (tag == "__direct__");
351 if (direct) {
352 tag = reader.readTag(1);
353 }
354 while (tag_len <= max_tag_len && !reader.isError()) {
355 if(tag == "getRemoteProtocolVersion") {
356 if (!reader.noMore()) {
357 yError("Reader invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
358 reader.fail();
359 return false;
360 }
361
362 auto proto = getLocalProtocolVersion();
363
364 yarp::os::idl::WireWriter writer(reader);
365 if (!writer.writeListHeader(1)) {
366 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
367 return false;}
368 if (!writer.write(proto)) {
369 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
370 return false;
371 }
372 reader.accept();
373 return true;
374 }
377 if (!helper.cmd.readArgs(reader)) {
378 return false;
379 }
380
381 helper.call(this);
382
383 yarp::os::idl::WireWriter writer(reader);
384 if (!helper.reply.write(writer)) {
385 return false;
386 }
387 reader.accept();
388 return true;
389 }
390 if (tag == "help") {
391 std::string functionName;
392 if (!reader.readString(functionName)) {
393 functionName = "--all";
394 }
395 auto help_strings = help(functionName);
396 yarp::os::idl::WireWriter writer(reader);
397 if (!writer.isNull()) {
398 if (!writer.writeListHeader(2)) {
399 return false;
400 }
401 if (!writer.writeTag("many", 1, 0)) {
402 return false;
403 }
404 if (!writer.writeListBegin(0, help_strings.size())) {
405 return false;
406 }
407 for (const auto& help_string : help_strings) {
408 if (!writer.writeString(help_string)) {
409 return false;
410 }
411 }
412 if (!writer.writeListEnd()) {
413 return false;
414 }
415 }
416 reader.accept();
417 return true;
418 }
419 if (reader.noMore()) {
420 reader.fail();
421 return false;
422 }
423 std::string next_tag = reader.readTag(1);
424 if (next_tag.empty()) {
425 break;
426 }
427 tag.append("_").append(next_tag);
428 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
429 }
430 return false;
431}
#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")
@ 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 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