YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ColorRGB.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/sig/ColorRGB.h>
12
13namespace yarp::sig {
14
15// Constructor with field values
16ColorRGB::ColorRGB(const std::int16_t r,
17 const std::int16_t g,
18 const std::int16_t b) :
19 WirePortable(),
20 r(r),
21 g(g),
22 b(b)
23{
24}
25
26// Read structure on a Wire
28{
29 if (!read_r(reader)) {
30 return false;
31 }
32 if (!read_g(reader)) {
33 return false;
34 }
35 if (!read_b(reader)) {
36 return false;
37 }
38 if (reader.isError()) {
39 return false;
40 }
41 return true;
42}
43
44// Read structure on a Connection
46{
47 yarp::os::idl::WireReader reader(connection);
48 if (!reader.readListHeader(3)) {
49 return false;
50 }
51 if (!read(reader)) {
52 return false;
53 }
54 return true;
55}
56
57// Write structure on a Wire
59{
60 if (!write_r(writer)) {
61 return false;
62 }
63 if (!write_g(writer)) {
64 return false;
65 }
66 if (!write_b(writer)) {
67 return false;
68 }
69 if (writer.isError()) {
70 return false;
71 }
72 return true;
73}
74
75// Write structure on a Connection
77{
78 yarp::os::idl::WireWriter writer(connection);
79 if (!writer.writeListHeader(3)) {
80 return false;
81 }
82 if (!write(writer)) {
83 return false;
84 }
85 return true;
86}
87
88// Convert to a printable string
89std::string ColorRGB::toString() const
90{
93 return {};
94 }
95 return b.toString();
96}
97
98// read r field
99bool ColorRGB::read_r(yarp::os::idl::WireReader& reader)
100{
101 if (reader.noMore()) {
102 reader.fail();
103 return false;
104 }
105 if (!reader.readI16(r)) {
106 reader.fail();
107 return false;
108 }
109 return true;
110}
111
112// write r field
113bool ColorRGB::write_r(const yarp::os::idl::WireWriter& writer) const
114{
115 if (!writer.writeI16(r)) {
116 return false;
117 }
118 return true;
119}
120
121// read (nested) r field
122bool ColorRGB::nested_read_r(yarp::os::idl::WireReader& reader)
123{
124 if (reader.noMore()) {
125 reader.fail();
126 return false;
127 }
128 if (!reader.readI16(r)) {
129 reader.fail();
130 return false;
131 }
132 return true;
133}
134
135// write (nested) r field
136bool ColorRGB::nested_write_r(const yarp::os::idl::WireWriter& writer) const
137{
138 if (!writer.writeI16(r)) {
139 return false;
140 }
141 return true;
142}
143
144// read g field
145bool ColorRGB::read_g(yarp::os::idl::WireReader& reader)
146{
147 if (reader.noMore()) {
148 reader.fail();
149 return false;
150 }
151 if (!reader.readI16(g)) {
152 reader.fail();
153 return false;
154 }
155 return true;
156}
157
158// write g field
159bool ColorRGB::write_g(const yarp::os::idl::WireWriter& writer) const
160{
161 if (!writer.writeI16(g)) {
162 return false;
163 }
164 return true;
165}
166
167// read (nested) g field
168bool ColorRGB::nested_read_g(yarp::os::idl::WireReader& reader)
169{
170 if (reader.noMore()) {
171 reader.fail();
172 return false;
173 }
174 if (!reader.readI16(g)) {
175 reader.fail();
176 return false;
177 }
178 return true;
179}
180
181// write (nested) g field
182bool ColorRGB::nested_write_g(const yarp::os::idl::WireWriter& writer) const
183{
184 if (!writer.writeI16(g)) {
185 return false;
186 }
187 return true;
188}
189
190// read b field
191bool ColorRGB::read_b(yarp::os::idl::WireReader& reader)
192{
193 if (reader.noMore()) {
194 reader.fail();
195 return false;
196 }
197 if (!reader.readI16(b)) {
198 reader.fail();
199 return false;
200 }
201 return true;
202}
203
204// write b field
205bool ColorRGB::write_b(const yarp::os::idl::WireWriter& writer) const
206{
207 if (!writer.writeI16(b)) {
208 return false;
209 }
210 return true;
211}
212
213// read (nested) b field
214bool ColorRGB::nested_read_b(yarp::os::idl::WireReader& reader)
215{
216 if (reader.noMore()) {
217 reader.fail();
218 return false;
219 }
220 if (!reader.readI16(b)) {
221 reader.fail();
222 return false;
223 }
224 return true;
225}
226
227// write (nested) b field
228bool ColorRGB::nested_write_b(const yarp::os::idl::WireWriter& writer) const
229{
230 if (!writer.writeI16(b)) {
231 return false;
232 }
233 return true;
234}
235
236} // namespace yarp::sig
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:217
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 readI16(std::int16_t &x)
IDL-friendly connection writer.
Definition WireWriter.h:28
bool writeI16(std::int16_t x, bool skip_tag=false) const
bool writeListHeader(int len) const
bool write(const yarp::os::idl::WireWriter &writer) const override
Definition ColorRGB.cpp:58
std::string toString() const
Definition ColorRGB.cpp:89
std::int16_t r
Definition ColorRGB.h:26
std::int16_t b
Definition ColorRGB.h:28
bool read(yarp::os::idl::WireReader &reader) override
Definition ColorRGB.cpp:27
std::int16_t g
Definition ColorRGB.h:27