YARP
Yet Another Robot Platform
Header.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/Header" msg definition:
12 // # Standard metadata for higher-level stamped data types.
13 // # This is generally used to communicate timestamped data
14 // # in a particular coordinate frame.
15 // #
16 // # sequence ID: consecutively increasing ID
17 // uint32 seq
18 // #Two-integer timestamp that is expressed as:
19 // # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')
20 // # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')
21 // # time-handling sugar is provided by the client library
22 // time stamp
23 // #Frame this data is associated with
24 // # 0: no frame
25 // # 1: global frame
26 // string frame_id
27 // Instances of this class can be read and written with YARP ports,
28 // using a ROS-compatible format.
29 
30 #ifndef YARP_ROSMSG_std_msgs_Header_h
31 #define YARP_ROSMSG_std_msgs_Header_h
32 
33 #include <yarp/os/Wire.h>
34 #include <yarp/os/Type.h>
35 #include <yarp/os/idl/WireTypes.h>
36 #include <string>
37 #include <vector>
38 #include <yarp/rosmsg/TickTime.h>
39 
40 namespace yarp {
41 namespace rosmsg {
42 namespace std_msgs {
43 
45 {
46 public:
47  std::uint32_t seq;
49  std::string frame_id;
50 
51  Header() :
52  seq(0),
53  stamp(),
54  frame_id("")
55  {
56  }
57 
58  void clear()
59  {
60  // *** seq ***
61  seq = 0;
62 
63  // *** stamp ***
64  stamp.clear();
65 
66  // *** frame_id ***
67  frame_id = "";
68  }
69 
70  bool readBare(yarp::os::ConnectionReader& connection) override
71  {
72  // *** seq ***
73  seq = connection.expectInt32();
74 
75  // *** stamp ***
76  if (!stamp.read(connection)) {
77  return false;
78  }
79 
80  // *** frame_id ***
81  int len = connection.expectInt32();
82  frame_id.resize(len);
83  if (!connection.expectBlock((char*)frame_id.c_str(), len)) {
84  return false;
85  }
86 
87  return !connection.isError();
88  }
89 
90  bool readBottle(yarp::os::ConnectionReader& connection) override
91  {
92  connection.convertTextMode();
93  yarp::os::idl::WireReader reader(connection);
94  if (!reader.readListHeader(3)) {
95  return false;
96  }
97 
98  // *** seq ***
99  seq = reader.expectInt32();
100 
101  // *** stamp ***
102  if (!stamp.read(connection)) {
103  return false;
104  }
105 
106  // *** frame_id ***
107  if (!reader.readString(frame_id)) {
108  return false;
109  }
110 
111  return !connection.isError();
112  }
113 
115  bool read(yarp::os::ConnectionReader& connection) override
116  {
117  return (connection.isBareMode() ? readBare(connection)
118  : readBottle(connection));
119  }
120 
121  bool writeBare(yarp::os::ConnectionWriter& connection) const override
122  {
123  // *** seq ***
124  connection.appendInt32(seq);
125 
126  // *** stamp ***
127  if (!stamp.write(connection)) {
128  return false;
129  }
130 
131  // *** frame_id ***
132  connection.appendInt32(frame_id.length());
133  connection.appendExternalBlock((char*)frame_id.c_str(), frame_id.length());
134 
135  return !connection.isError();
136  }
137 
138  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
139  {
140  connection.appendInt32(BOTTLE_TAG_LIST);
141  connection.appendInt32(3);
142 
143  // *** seq ***
144  connection.appendInt32(BOTTLE_TAG_INT32);
145  connection.appendInt32(seq);
146 
147  // *** stamp ***
148  if (!stamp.write(connection)) {
149  return false;
150  }
151 
152  // *** frame_id ***
153  connection.appendInt32(BOTTLE_TAG_STRING);
154  connection.appendInt32(frame_id.length());
155  connection.appendExternalBlock((char*)frame_id.c_str(), frame_id.length());
156 
157  connection.convertTextMode();
158  return !connection.isError();
159  }
160 
162  bool write(yarp::os::ConnectionWriter& connection) const override
163  {
164  return (connection.isBareMode() ? writeBare(connection)
165  : writeBottle(connection));
166  }
167 
168  // This class will serialize ROS style or YARP style depending on protocol.
169  // If you need to force a serialization style, use one of these classes:
172 
173  // The name for this message, ROS will need this
174  static constexpr const char* typeName = "std_msgs/Header";
175 
176  // The checksum for this message, ROS will need this
177  static constexpr const char* typeChecksum = "2176decaecbce78abc3b96ef049fabed";
178 
179  // The source text for this message, ROS will need this
180  static constexpr const char* typeText = "\
181 # Standard metadata for higher-level stamped data types.\n\
182 # This is generally used to communicate timestamped data \n\
183 # in a particular coordinate frame.\n\
184 # \n\
185 # sequence ID: consecutively increasing ID \n\
186 uint32 seq\n\
187 #Two-integer timestamp that is expressed as:\n\
188 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
189 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
190 # time-handling sugar is provided by the client library\n\
191 time stamp\n\
192 #Frame this data is associated with\n\
193 # 0: no frame\n\
194 # 1: global frame\n\
195 string frame_id\n\
196 ";
197 
198  yarp::os::Type getType() const override
199  {
201  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
202  typ.addProperty("message_definition", yarp::os::Value(typeText));
203  return typ;
204  }
205 };
206 
207 } // namespace std_msgs
208 } // namespace rosmsg
209 } // namespace yarp
210 
211 #endif // YARP_ROSMSG_std_msgs_Header_h
yarp::rosmsg::std_msgs::Header::getType
yarp::os::Type getType() const override
Definition: Header.h:198
TickTime.h
yarp::rosmsg::std_msgs::Header::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:115
yarp::os::idl::WireReader::readString
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:339
yarp::rosmsg::std_msgs::Header::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: Header.h:121
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::std_msgs::Header::typeName
static constexpr const char * typeName
Definition: Header.h:174
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::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::std_msgs::Header::clear
void clear()
Definition: Header.h:58
yarp::rosmsg::std_msgs::Header::frame_id
std::string frame_id
Definition: Header.h:49
BOTTLE_TAG_STRING
#define BOTTLE_TAG_STRING
Definition: Bottle.h:28
Wire.h
yarp::rosmsg::std_msgs::Header::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::std_msgs::Header > bottleStyle
Definition: Header.h:171
yarp::rosmsg::std_msgs::Header::typeChecksum
static constexpr const char * typeChecksum
Definition: Header.h:177
BOTTLE_TAG_INT32
#define BOTTLE_TAG_INT32
Definition: Bottle.h:23
yarp::rosmsg::std_msgs::Header::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: Header.h:138
yarp::rosmsg::std_msgs::Header::Header
Header()
Definition: Header.h:51
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::TickTime
Definition: TickTime.h:30
yarp::rosmsg::std_msgs::Header::seq
std::uint32_t seq
Definition: Header.h:47
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
yarp::rosmsg::std_msgs::Header::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: Header.h:70
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
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::Header::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::std_msgs::Header > rosStyle
Definition: Header.h:170
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::std_msgs::Header::typeText
static constexpr const char * typeText
Definition: Header.h:180
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::Header::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:162
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::rosmsg::TickTime::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: TickTime.h:116
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::os::idl::WireReader::expectInt32
std::int32_t expectInt32()
Definition: WireReader.h:99
yarp::rosmsg::std_msgs::Header::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: Header.h:90
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::TickTime::clear
void clear()
Definition: TickTime.h:78
yarp::os::ConnectionWriter::appendExternalBlock
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
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::TickTime::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: TickTime.h:151
yarp::rosmsg::std_msgs::Header::stamp
yarp::rosmsg::TickTime stamp
Definition: Header.h:48
yarp::rosmsg::std_msgs::Header
Definition: Header.h:45
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