YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
MultipleAnalogSensorsMetadata.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>
15#include <yarp/os/LogStream.h>
16
18
19#include <algorithm>
20
21namespace
22{
23 YARP_LOG_COMPONENT(SERVICE_LOG_COMPONENT, "MultipleAnalogSensorsMetadata")
24}
25
26//MultipleAnalogSensorsMetadata_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 MultipleAnalogSensorsMetadata_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 MultipleAnalogSensorsMetadata::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// getMetadata 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
155
158
159 static constexpr const char* s_tag{"getMetadata"};
160 static constexpr size_t s_tag_len{1};
161 static constexpr size_t s_cmd_len{1};
162 static constexpr size_t s_reply_len{12};
163 static constexpr const char* s_prototype{"SensorRPCData MultipleAnalogSensorsMetadata::getMetadata()"};
164 static constexpr const char* s_help{
165 "Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device."
166 };
167};
168
169// getMetadata helper class implementation
171{
172 return cmd.write(connection);
173}
174
179
181{
182 yarp::os::idl::WireWriter writer(connection);
183 if (!writer.writeListHeader(s_cmd_len)) {
184 return false;
185 }
186 return write(writer);
187}
188
190{
191 yarp::os::idl::WireReader reader(connection);
192 if (!reader.readListHeader()) {
193 reader.fail();
194 return false;
195 }
196 return read(reader);
197}
198
200{
201 if (!writeTag(writer)) {
202 return false;
203 }
204 if (!writeArgs(writer)) {
205 return false;
206 }
207 return true;
208}
209
211{
212 if (!writer.writeTag(s_tag, 1, s_tag_len)) {
213 return false;
214 }
215 return true;
216}
217
219{
220 return true;
221}
222
224{
225 if (!readTag(reader)) {
226 return false;
227 }
228 if (!readArgs(reader)) {
229 return false;
230 }
231 return true;
232}
233
235{
236 std::string tag = reader.readTag(s_tag_len);
237 if (reader.isError()) {
238 return false;
239 }
240 if (tag != s_tag) {
241 reader.fail();
242 return false;
243 }
244 return true;
245}
246
248{
249 if (!reader.noMore()) {
250 reader.fail();
251 return false;
252 }
253 return true;
254}
255
257{
258 yarp::os::idl::WireWriter writer(connection);
259 return write(writer);
260}
261
267
269{
270 if (!writer.isNull()) {
271 if (!writer.writeListHeader(s_reply_len)) {
272 return false;
273 }
274 if (!writer.write(return_helper)) {
275 return false;
276 }
277 }
278 return true;
279}
280
282{
283 if (!reader.readListReturn()) {
284 return false;
285 }
286 if (reader.noMore()) {
287 reader.fail();
288 return false;
289 }
290 if (!reader.read(return_helper)) {
291 reader.fail();
292 return false;
293 }
294 return true;
295}
296
301
302// Constructor
307
309{
310 if (!yarp().canWrite()) {
312 }
314 bool ok = yarp().write(helper, helper);
315 return ok ? helper.reply.return_helper : SensorRPCData{};
316}
317
318// help method
319std::vector<std::string> MultipleAnalogSensorsMetadata::help(const std::string& functionName)
320{
321 bool showAll = (functionName == "--all");
322 std::vector<std::string> helpString;
323 if (showAll) {
324 helpString.emplace_back("*** Available commands:");
326 helpString.emplace_back("help");
327 } else {
331 }
332 if (functionName == "help") {
333 helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
334 helpString.emplace_back("Return list of available commands, or help message for a specific function");
335 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");
336 helpString.emplace_back("@return list of strings (one string per line)");
337 }
338 }
339 if (helpString.empty()) {
340 helpString.emplace_back("Command not found");
341 }
342 return helpString;
343}
344
345// read from ConnectionReader
347{
348 constexpr size_t max_tag_len = 1;
349 size_t tag_len = 1;
350
351 yarp::os::idl::WireReader reader(connection);
352 reader.expectAccept();
353 if (!reader.readListHeader()) {
354 reader.fail();
355 return false;
356 }
357
358 std::string tag = reader.readTag(1);
359 bool direct = (tag == "__direct__");
360 if (direct) {
361 tag = reader.readTag(1);
362 }
363 while (tag_len <= max_tag_len && !reader.isError()) {
364 if(tag == "getRemoteProtocolVersion") {
365 if (!reader.noMore()) {
366 yError("Reader invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
367 reader.fail();
368 return false;
369 }
370
371 auto proto = getLocalProtocolVersion();
372
373 yarp::os::idl::WireWriter writer(reader);
374 if (!writer.writeListHeader(1)) {
375 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
376 return false;}
377 if (!writer.write(proto)) {
378 yWarning("Writer invalid protocol?! %s:%d - %s", __FILE__, __LINE__, __YFUNCTION__);
379 return false;
380 }
381 reader.accept();
382 return true;
383 }
386 if (!helper.cmd.readArgs(reader)) {
387 return false;
388 }
389
390 helper.call(this);
391
392 yarp::os::idl::WireWriter writer(reader);
393 if (!helper.reply.write(writer)) {
394 return false;
395 }
396 reader.accept();
397 return true;
398 }
399 if (tag == "help") {
400 std::string functionName;
401 if (!reader.readString(functionName)) {
402 functionName = "--all";
403 }
404 auto help_strings = help(functionName);
405 yarp::os::idl::WireWriter writer(reader);
406 if (!writer.isNull()) {
407 if (!writer.writeListHeader(2)) {
408 return false;
409 }
410 if (!writer.writeTag("many", 1, 0)) {
411 return false;
412 }
413 if (!writer.writeListBegin(0, help_strings.size())) {
414 return false;
415 }
416 for (const auto& help_string : help_strings) {
417 if (!writer.writeString(help_string)) {
418 return false;
419 }
420 }
421 if (!writer.writeListEnd()) {
422 return false;
423 }
424 }
425 reader.accept();
426 return true;
427 }
428 if (reader.noMore()) {
429 reader.fail();
430 return false;
431 }
432 std::string next_tag = reader.readTag(1);
433 if (next_tag.empty()) {
434 break;
435 }
436 tag.append("_").append(next_tag);
437 tag_len = std::count(tag.begin(), tag.end(), '_') + 1;
438 }
439 return false;
440}
#define yError(...)
Definition Log.h:361
#define __YFUNCTION__
Definition Log.h:24
#define yWarning(...)
Definition Log.h:340
bool writeArgs(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 writeTag(const yarp::os::idl::WireWriter &writer) const
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 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 yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
virtual SensorRPCData getMetadata()
Read the sensor metadata necessary to configure the MultipleAnalogSensorsClient device.
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