YARP
Yet Another Robot Platform
ColorRGBA.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 // This is an automatically generated file.
10 
11 // Generated from the following "std_msgs/ColorRGBA" msg definition:
12 // float32 r
13 // float32 g
14 // float32 b
15 // float32 a
16 // Instances of this class can be read and written with YARP ports,
17 // using a ROS-compatible format.
18 
19 #ifndef YARP_ROSMSG_std_msgs_ColorRGBA_h
20 #define YARP_ROSMSG_std_msgs_ColorRGBA_h
21 
22 #include <yarp/os/Wire.h>
23 #include <yarp/os/Type.h>
25 #include <string>
26 #include <vector>
27 
28 namespace yarp {
29 namespace rosmsg {
30 namespace std_msgs {
31 
33 {
34 public:
39 
41  r(0.0f),
42  g(0.0f),
43  b(0.0f),
44  a(0.0f)
45  {
46  }
47 
48  void clear()
49  {
50  // *** r ***
51  r = 0.0f;
52 
53  // *** g ***
54  g = 0.0f;
55 
56  // *** b ***
57  b = 0.0f;
58 
59  // *** a ***
60  a = 0.0f;
61  }
62 
63  bool readBare(yarp::os::ConnectionReader& connection) override
64  {
65  // *** r ***
66  r = connection.expectFloat32();
67 
68  // *** g ***
69  g = connection.expectFloat32();
70 
71  // *** b ***
72  b = connection.expectFloat32();
73 
74  // *** a ***
75  a = connection.expectFloat32();
76 
77  return !connection.isError();
78  }
79 
80  bool readBottle(yarp::os::ConnectionReader& connection) override
81  {
82  connection.convertTextMode();
83  yarp::os::idl::WireReader reader(connection);
84  if (!reader.readListHeader(4)) {
85  return false;
86  }
87 
88  // *** r ***
89  r = reader.expectFloat32();
90 
91  // *** g ***
92  g = reader.expectFloat32();
93 
94  // *** b ***
95  b = reader.expectFloat32();
96 
97  // *** a ***
98  a = reader.expectFloat32();
99 
100  return !connection.isError();
101  }
102 
104  bool read(yarp::os::ConnectionReader& connection) override
105  {
106  return (connection.isBareMode() ? readBare(connection)
107  : readBottle(connection));
108  }
109 
110  bool writeBare(yarp::os::ConnectionWriter& connection) const override
111  {
112  // *** r ***
113  connection.appendFloat32(r);
114 
115  // *** g ***
116  connection.appendFloat32(g);
117 
118  // *** b ***
119  connection.appendFloat32(b);
120 
121  // *** a ***
122  connection.appendFloat32(a);
123 
124  return !connection.isError();
125  }
126 
127  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
128  {
129  connection.appendInt32(BOTTLE_TAG_LIST);
130  connection.appendInt32(4);
131 
132  // *** r ***
133  connection.appendInt32(BOTTLE_TAG_FLOAT32);
134  connection.appendFloat32(r);
135 
136  // *** g ***
137  connection.appendInt32(BOTTLE_TAG_FLOAT32);
138  connection.appendFloat32(g);
139 
140  // *** b ***
141  connection.appendInt32(BOTTLE_TAG_FLOAT32);
142  connection.appendFloat32(b);
143 
144  // *** a ***
145  connection.appendInt32(BOTTLE_TAG_FLOAT32);
146  connection.appendFloat32(a);
147 
148  connection.convertTextMode();
149  return !connection.isError();
150  }
151 
153  bool write(yarp::os::ConnectionWriter& connection) const override
154  {
155  return (connection.isBareMode() ? writeBare(connection)
156  : writeBottle(connection));
157  }
158 
159  // This class will serialize ROS style or YARP style depending on protocol.
160  // If you need to force a serialization style, use one of these classes:
163 
164  // The name for this message, ROS will need this
165  static constexpr const char* typeName = "std_msgs/ColorRGBA";
166 
167  // The checksum for this message, ROS will need this
168  static constexpr const char* typeChecksum = "a29a96539573343b1310c73607334b00";
169 
170  // The source text for this message, ROS will need this
171  static constexpr const char* typeText = "\
172 float32 r\n\
173 float32 g\n\
174 float32 b\n\
175 float32 a\n\
176 ";
177 
178  yarp::os::Type getType() const override
179  {
181  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
182  typ.addProperty("message_definition", yarp::os::Value(typeText));
183  return typ;
184  }
185 };
186 
187 } // namespace std_msgs
188 } // namespace rosmsg
189 } // namespace yarp
190 
191 #endif // YARP_ROSMSG_std_msgs_ColorRGBA_h
yarp::rosmsg::std_msgs::ColorRGBA::clear
void clear()
Definition: ColorRGBA.h:48
yarp::os::ConnectionWriter::appendFloat32
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
yarp::rosmsg::std_msgs::ColorRGBA::a
yarp::conf::float32_t a
Definition: ColorRGBA.h:38
yarp::rosmsg::std_msgs::ColorRGBA::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: ColorRGBA.h:110
yarp::rosmsg::std_msgs::ColorRGBA::typeChecksum
static constexpr const char * typeChecksum
Definition: ColorRGBA.h:168
yarp::rosmsg::std_msgs::ColorRGBA::g
yarp::conf::float32_t g
Definition: ColorRGBA.h:36
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::os::idl::WireReader::expectFloat32
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:113
yarp::rosmsg::std_msgs::ColorRGBA::typeName
static constexpr const char * typeName
Definition: ColorRGBA.h:165
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::rosmsg::std_msgs::ColorRGBA::typeText
static constexpr const char * typeText
Definition: ColorRGBA.h:171
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
Wire.h
yarp::rosmsg::std_msgs::ColorRGBA::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: ColorRGBA.h:63
yarp::rosmsg::std_msgs::ColorRGBA::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: ColorRGBA.h:127
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
BOTTLE_TAG_FLOAT32
#define BOTTLE_TAG_FLOAT32
Definition: Bottle.h:26
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::rosmsg::std_msgs::ColorRGBA::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: ColorRGBA.h:80
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::rosmsg::std_msgs::ColorRGBA::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: ColorRGBA.h:153
std_msgs
Definition: Bool.h:22
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::rosmsg::std_msgs::ColorRGBA::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: ColorRGBA.h:104
yarp::rosmsg::std_msgs::ColorRGBA
Definition: ColorRGBA.h:33
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::std_msgs::ColorRGBA::ColorRGBA
ColorRGBA()
Definition: ColorRGBA.h:40
yarp::os::ConnectionReader::convertTextMode
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
yarp::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::rosmsg::std_msgs::ColorRGBA::b
yarp::conf::float32_t b
Definition: ColorRGBA.h:37
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::std_msgs::ColorRGBA::getType
yarp::os::Type getType() const override
Definition: ColorRGBA.h:178
yarp::os::ConnectionWriter::convertTextMode
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
yarp::conf::float32_t
float float32_t
Definition: numeric.h:50
yarp::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
yarp::os::idl::WireReader
IDL-friendly connection reader.
Definition: WireReader.h:33
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::std_msgs::ColorRGBA::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::std_msgs::ColorRGBA > bottleStyle
Definition: ColorRGBA.h:162
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::ConnectionReader::expectFloat32
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::std_msgs::ColorRGBA::r
yarp::conf::float32_t r
Definition: ColorRGBA.h:35
yarp::rosmsg::std_msgs::ColorRGBA::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::std_msgs::ColorRGBA > rosStyle
Definition: ColorRGBA.h:161
yarp::os::idl::WireReader::readListHeader
bool readListHeader()
Definition: WireReader.cpp:470
yarp::os::idl::WirePortable::write
virtual bool write(const yarp::os::idl::WireWriter &writer) const
Definition: WirePortable.cpp:20