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