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