YARP
Yet Another Robot Platform
SensorMeasurement.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 <SensorMeasurement.h>
12
13// Constructor with field values
15 const double timestamp) :
16 WirePortable(),
17 measurement(measurement),
18 timestamp(timestamp)
19{
20}
21
22// Read structure on a Wire
24{
25 if (!nested_read_measurement(reader)) {
26 return false;
27 }
28 if (!read_timestamp(reader)) {
29 return false;
30 }
31 if (reader.isError()) {
32 return false;
33 }
34 return true;
35}
36
37// Read structure on a Connection
39{
40 yarp::os::idl::WireReader reader(connection);
41 if (!reader.readListHeader(2)) {
42 return false;
43 }
44 if (!read(reader)) {
45 return false;
46 }
47 return true;
48}
49
50// Write structure on a Wire
52{
53 if (!nested_write_measurement(writer)) {
54 return false;
55 }
56 if (!write_timestamp(writer)) {
57 return false;
58 }
59 if (writer.isError()) {
60 return false;
61 }
62 return true;
63}
64
65// Write structure on a Connection
67{
68 yarp::os::idl::WireWriter writer(connection);
69 if (!writer.writeListHeader(2)) {
70 return false;
71 }
72 if (!write(writer)) {
73 return false;
74 }
75 return true;
76}
77
78// Convert to a printable string
79std::string SensorMeasurement::toString() const
80{
82 if (!yarp::os::Portable::copyPortable(*this, b)) {
83 return {};
84 }
85 return b.toString();
86}
87
88// read measurement field
89bool SensorMeasurement::read_measurement(yarp::os::idl::WireReader& reader)
90{
91 if (reader.noMore()) {
92 reader.fail();
93 return false;
94 }
95 if (!reader.read(measurement)) {
96 reader.fail();
97 return false;
98 }
99 return true;
100}
101
102// write measurement field
103bool SensorMeasurement::write_measurement(const yarp::os::idl::WireWriter& writer) const
104{
105 if (!writer.write(measurement)) {
106 return false;
107 }
108 return true;
109}
110
111// read (nested) measurement field
112bool SensorMeasurement::nested_read_measurement(yarp::os::idl::WireReader& reader)
113{
114 if (reader.noMore()) {
115 reader.fail();
116 return false;
117 }
118 if (!reader.readNested(measurement)) {
119 reader.fail();
120 return false;
121 }
122 return true;
123}
124
125// write (nested) measurement field
126bool SensorMeasurement::nested_write_measurement(const yarp::os::idl::WireWriter& writer) const
127{
128 if (!writer.writeNested(measurement)) {
129 return false;
130 }
131 return true;
132}
133
134// read timestamp field
135bool SensorMeasurement::read_timestamp(yarp::os::idl::WireReader& reader)
136{
137 if (reader.noMore()) {
138 reader.fail();
139 return false;
140 }
141 if (!reader.readFloat64(timestamp)) {
142 reader.fail();
143 return false;
144 }
145 return true;
146}
147
148// write timestamp field
149bool SensorMeasurement::write_timestamp(const yarp::os::idl::WireWriter& writer) const
150{
151 if (!writer.writeFloat64(timestamp)) {
152 return false;
153 }
154 return true;
155}
156
157// read (nested) timestamp field
158bool SensorMeasurement::nested_read_timestamp(yarp::os::idl::WireReader& reader)
159{
160 if (reader.noMore()) {
161 reader.fail();
162 return false;
163 }
164 if (!reader.readFloat64(timestamp)) {
165 reader.fail();
166 return false;
167 }
168 return true;
169}
170
171// write (nested) timestamp field
172bool SensorMeasurement::nested_write_timestamp(const yarp::os::idl::WireWriter& writer) const
173{
174 if (!writer.writeFloat64(timestamp)) {
175 return false;
176 }
177 return true;
178}
bool read(yarp::os::idl::WireReader &reader) override
bool write(const yarp::os::idl::WireWriter &writer) const override
yarp::sig::Vector measurement
SensorMeasurement()=default
std::string toString() const
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition: Bottle.cpp:211
An interface for reading from a network connection.
An interface for writing to a network connection.
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition: Portable.cpp:16
IDL-friendly connection reader.
Definition: WireReader.h:27
bool readNested(WirePortable &obj)
Definition: WireReader.cpp:82
bool read(WirePortable &obj)
Definition: WireReader.cpp:72
bool readFloat64(yarp::conf::float64_t &x)
Definition: WireReader.cpp:271
IDL-friendly connection writer.
Definition: WireWriter.h:28
bool write(const WirePortable &obj) const
Definition: WireWriter.cpp:50
bool writeListHeader(int len) const
Definition: WireWriter.cpp:231
bool writeFloat64(yarp::conf::float64_t x, bool skip_tag=false) const
Definition: WireWriter.cpp:124
bool writeNested(const WirePortable &obj) const
Definition: WireWriter.cpp:60