YARP
Yet Another Robot Platform
Byte.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/Byte" msg definition:
12 // byte data
13 // Instances of this class can be read and written with YARP ports,
14 // using a ROS-compatible format.
15 
16 #ifndef YARP_ROSMSG_std_msgs_Byte_h
17 #define YARP_ROSMSG_std_msgs_Byte_h
18 
19 #include <yarp/os/Wire.h>
20 #include <yarp/os/Type.h>
21 #include <yarp/os/idl/WireTypes.h>
22 #include <string>
23 #include <vector>
24 
25 namespace yarp {
26 namespace rosmsg {
27 namespace std_msgs {
28 
30 {
31 public:
32  std::uint8_t data;
33 
34  Byte() :
35  data(0)
36  {
37  }
38 
39  void clear()
40  {
41  // *** data ***
42  data = 0;
43  }
44 
45  bool readBare(yarp::os::ConnectionReader& connection) override
46  {
47  // *** data ***
48  data = connection.expectInt8();
49 
50  return !connection.isError();
51  }
52 
53  bool readBottle(yarp::os::ConnectionReader& connection) override
54  {
55  connection.convertTextMode();
56  yarp::os::idl::WireReader reader(connection);
57  if (!reader.readListHeader(1)) {
58  return false;
59  }
60 
61  // *** data ***
62  data = reader.expectInt8();
63 
64  return !connection.isError();
65  }
66 
68  bool read(yarp::os::ConnectionReader& connection) override
69  {
70  return (connection.isBareMode() ? readBare(connection)
71  : readBottle(connection));
72  }
73 
74  bool writeBare(yarp::os::ConnectionWriter& connection) const override
75  {
76  // *** data ***
77  connection.appendInt8(data);
78 
79  return !connection.isError();
80  }
81 
82  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
83  {
84  connection.appendInt32(BOTTLE_TAG_LIST);
85  connection.appendInt32(1);
86 
87  // *** data ***
88  connection.appendInt32(BOTTLE_TAG_INT8);
89  connection.appendInt8(data);
90 
91  connection.convertTextMode();
92  return !connection.isError();
93  }
94 
96  bool write(yarp::os::ConnectionWriter& connection) const override
97  {
98  return (connection.isBareMode() ? writeBare(connection)
99  : writeBottle(connection));
100  }
101 
102  // This class will serialize ROS style or YARP style depending on protocol.
103  // If you need to force a serialization style, use one of these classes:
106 
107  // The name for this message, ROS will need this
108  static constexpr const char* typeName = "std_msgs/Byte";
109 
110  // The checksum for this message, ROS will need this
111  static constexpr const char* typeChecksum = "ad736a2e8818154c487bb80fe42ce43b";
112 
113  // The source text for this message, ROS will need this
114  static constexpr const char* typeText = "\
115 byte data\n\
116 ";
117 
118  yarp::os::Type getType() const override
119  {
121  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
122  typ.addProperty("message_definition", yarp::os::Value(typeText));
123  return typ;
124  }
125 };
126 
127 } // namespace std_msgs
128 } // namespace rosmsg
129 } // namespace yarp
130 
131 #endif // YARP_ROSMSG_std_msgs_Byte_h
yarp::rosmsg::std_msgs::Byte::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Byte.h:96
yarp::rosmsg::std_msgs::Byte::typeText
static constexpr const char * typeText
Definition: Byte.h:114
yarp::rosmsg::std_msgs::Byte::data
std::uint8_t data
Definition: Byte.h:32
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::std_msgs::Byte::typeName
static constexpr const char * typeName
Definition: Byte.h:108
yarp::rosmsg::std_msgs::Byte::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::std_msgs::Byte > rosStyle
Definition: Byte.h:104
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::os::ConnectionWriter::appendInt8
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::std_msgs::Byte::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Byte.h:68
Wire.h
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::rosmsg::std_msgs::Byte::typeChecksum
static constexpr const char * typeChecksum
Definition: Byte.h:111
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
yarp::rosmsg::std_msgs::Byte::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Byte.h:53
Type.h
yarp::rosmsg::std_msgs::Byte::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Byte.h:82
std_msgs
Definition: Bool.h:22
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::std_msgs::Byte::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Byte.h:45
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::rosmsg::std_msgs::Byte::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::std_msgs::Byte > bottleStyle
Definition: Byte.h:105
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::Byte::clear
void clear()
Definition: Byte.h:39
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
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::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
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::std_msgs::Byte::Byte
Byte()
Definition: Byte.h:34
yarp::rosmsg::std_msgs::Byte::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Byte.h:74
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::std_msgs::Byte::getType
yarp::os::Type getType() const override
Definition: Byte.h:118
yarp::rosmsg::std_msgs::Byte
Definition: Byte.h:30
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