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