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 <IOdometry2DMsgs.h>
12
14
15#include <algorithm>
16
17// reset_odometry_RPC 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
62 void call(IOdometry2DMsgs* ptr);
63
66
67 static constexpr const char* s_tag{"reset_odometry_RPC"};
68 static constexpr size_t s_tag_len{3};
69 static constexpr size_t s_cmd_len{3};
70 static constexpr size_t s_reply_len{1};
71 static constexpr const char* s_prototype{"yarp::dev::ReturnValue IOdometry2DMsgs::reset_odometry_RPC()"};
72 static constexpr const char* s_help{""};
73};
74
75// reset_odometry_RPC helper class implementation
77{
78 return cmd.write(connection);
79}
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
163{
164 yarp::os::idl::WireWriter writer(connection);
165 return write(writer);
166}
167
169{
170 yarp::os::idl::WireReader reader(connection);
171 return read(reader);
172}
173
175{
176 if (!writer.isNull()) {
177 if (!writer.write(return_helper)) {
178 return false;
179 }
180 }
181 return true;
182}
183
185{
186 if (reader.noMore()) {
187 reader.fail();
188 return false;
189 }
190 if (!reader.read(return_helper)) {
191 reader.fail();
192 return false;
193 }
194 return true;
195}
196
201
202// Constructor
204{
205 yarp().setOwner(*this);
206}
207
209{
210 if (!yarp().canWrite()) {
212 }
214 bool ok = yarp().write(helper, helper);
215 return ok ? helper.reply.return_helper : yarp::dev::ReturnValue{};
216}
217
218// help method
219std::vector<std::string> IOdometry2DMsgs::help(const std::string& functionName)
220{
221 bool showAll = (functionName == "--all");
222 std::vector<std::string> helpString;
223 if (showAll) {
224 helpString.emplace_back("*** Available commands:");
226 helpString.emplace_back("help");
227 } else {
230 }
231 if (functionName == "help") {
232 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
233 helpString.emplace_back("Return list of available commands, or help message for a specific function");
234 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");
235 helpString.emplace_back("@return list of strings (one string per line)");
236 }
237 }
238 if (helpString.empty()) {
239 helpString.emplace_back("Command not found");
240 }
241 return helpString;
242}
243
244// read from ConnectionReader
246{
247 constexpr size_t max_tag_len = 3;
248 size_t tag_len = 1;
249
250 yarp::os::idl::WireReader reader(connection);
251 reader.expectAccept();
252 if (!reader.readListHeader()) {
253 reader.fail();
254 return false;
255 }
256
257 std::string tag = reader.readTag(1);
258 bool direct = (tag == "__direct__");
259 if (direct) {
260 tag = reader.readTag(1);
261 }
262 while (tag_len <= max_tag_len && !reader.isError()) {
265 if (!helper.cmd.readArgs(reader)) {
266 return false;
267 }
268
269 helper.call(this);
270
271 yarp::os::idl::WireWriter writer(reader);
272 if (!helper.reply.write(writer)) {
273 return false;
274 }
275 reader.accept();
276 return true;
277 }
278 if (tag == "help") {
279 std::string functionName;
280 if (!reader.readString(functionName)) {
281 functionName = "--all";
282 }
283 auto help_strings = help(functionName);
284 yarp::os::idl::WireWriter writer(reader);
285 if (!writer.isNull()) {
286 if (!writer.writeListHeader(2)) {
287 return false;
288 }
289 if (!writer.writeTag("many", 1, 0)) {
290 return false;
291 }
292 if (!writer.writeListBegin(0, help_strings.size())) {
293 return false;
294 }
295 for (const auto& help_string : help_strings) {
296 if (!writer.writeString(help_string)) {
297 return false;
298 }
299 }
300 if (!writer.writeListEnd()) {
301 return false;
302 }
303 }
304 reader.accept();
305 return true;
306 }
307 if (reader.noMore()) {
308 reader.fail();
309 return false;
310 }
311 std::string next_tag = reader.readTag(1);
312 if (next_tag.empty()) {
313 break;
314 }
315 tag.append("_").append(next_tag);
316 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
317 }
318 return false;
319}
#define yError(...)
Definition Log.h:361
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 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
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