YARP
Yet Another Robot Platform
TimeReference.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 "sensor_msgs/TimeReference" msg definition:
9 // # Measurement from an external time source not actively synchronized with the system clock.
10 //
11 // Header header # stamp is system time for which measurement was valid
12 // # frame_id is not used
13 //
14 // time time_ref # corresponding time from this external source
15 // string source # (optional) name of time source
16 // Instances of this class can be read and written with YARP ports,
17 // using a ROS-compatible format.
18 
19 #ifndef YARP_ROSMSG_sensor_msgs_TimeReference_h
20 #define YARP_ROSMSG_sensor_msgs_TimeReference_h
21 
22 #include <yarp/os/Wire.h>
23 #include <yarp/os/Type.h>
24 #include <yarp/os/idl/WireTypes.h>
25 #include <string>
26 #include <vector>
28 #include <yarp/rosmsg/TickTime.h>
29 
30 namespace yarp {
31 namespace rosmsg {
32 namespace sensor_msgs {
33 
35 {
36 public:
39  std::string source;
40 
42  header(),
43  time_ref(),
44  source("")
45  {
46  }
47 
48  void clear()
49  {
50  // *** header ***
51  header.clear();
52 
53  // *** time_ref ***
54  time_ref.clear();
55 
56  // *** source ***
57  source = "";
58  }
59 
60  bool readBare(yarp::os::ConnectionReader& connection) override
61  {
62  // *** header ***
63  if (!header.read(connection)) {
64  return false;
65  }
66 
67  // *** time_ref ***
68  if (!time_ref.read(connection)) {
69  return false;
70  }
71 
72  // *** source ***
73  int len = connection.expectInt32();
74  source.resize(len);
75  if (!connection.expectBlock((char*)source.c_str(), len)) {
76  return false;
77  }
78 
79  return !connection.isError();
80  }
81 
82  bool readBottle(yarp::os::ConnectionReader& connection) override
83  {
84  connection.convertTextMode();
85  yarp::os::idl::WireReader reader(connection);
86  if (!reader.readListHeader(3)) {
87  return false;
88  }
89 
90  // *** header ***
91  if (!header.read(connection)) {
92  return false;
93  }
94 
95  // *** time_ref ***
96  if (!time_ref.read(connection)) {
97  return false;
98  }
99 
100  // *** source ***
101  if (!reader.readString(source)) {
102  return false;
103  }
104 
105  return !connection.isError();
106  }
107 
109  bool read(yarp::os::ConnectionReader& connection) override
110  {
111  return (connection.isBareMode() ? readBare(connection)
112  : readBottle(connection));
113  }
114 
115  bool writeBare(yarp::os::ConnectionWriter& connection) const override
116  {
117  // *** header ***
118  if (!header.write(connection)) {
119  return false;
120  }
121 
122  // *** time_ref ***
123  if (!time_ref.write(connection)) {
124  return false;
125  }
126 
127  // *** source ***
128  connection.appendInt32(source.length());
129  connection.appendExternalBlock((char*)source.c_str(), source.length());
130 
131  return !connection.isError();
132  }
133 
134  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
135  {
136  connection.appendInt32(BOTTLE_TAG_LIST);
137  connection.appendInt32(3);
138 
139  // *** header ***
140  if (!header.write(connection)) {
141  return false;
142  }
143 
144  // *** time_ref ***
145  if (!time_ref.write(connection)) {
146  return false;
147  }
148 
149  // *** source ***
150  connection.appendInt32(BOTTLE_TAG_STRING);
151  connection.appendInt32(source.length());
152  connection.appendExternalBlock((char*)source.c_str(), source.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 = "sensor_msgs/TimeReference";
172 
173  // The checksum for this message, ROS will need this
174  static constexpr const char* typeChecksum = "fded64a0265108ba86c3d38fb11c0c16";
175 
176  // The source text for this message, ROS will need this
177  static constexpr const char* typeText = "\
178 # Measurement from an external time source not actively synchronized with the system clock.\n\
179 \n\
180 Header header # stamp is system time for which measurement was valid\n\
181  # frame_id is not used \n\
182 \n\
183 time time_ref # corresponding time from this external source\n\
184 string source # (optional) name of time source\n\
185 \n\
186 ================================================================================\n\
187 MSG: std_msgs/Header\n\
188 # Standard metadata for higher-level stamped data types.\n\
189 # This is generally used to communicate timestamped data \n\
190 # in a particular coordinate frame.\n\
191 # \n\
192 # sequence ID: consecutively increasing ID \n\
193 uint32 seq\n\
194 #Two-integer timestamp that is expressed as:\n\
195 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
196 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
197 # time-handling sugar is provided by the client library\n\
198 time stamp\n\
199 #Frame this data is associated with\n\
200 # 0: no frame\n\
201 # 1: global frame\n\
202 string frame_id\n\
203 ";
204 
205  yarp::os::Type getType() const override
206  {
208  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
209  typ.addProperty("message_definition", yarp::os::Value(typeText));
210  return typ;
211  }
212 };
213 
214 } // namespace sensor_msgs
215 } // namespace rosmsg
216 } // namespace yarp
217 
218 #endif // YARP_ROSMSG_sensor_msgs_TimeReference_h
#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:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
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:30
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:382
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 read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::TimeReference > bottleStyle
static constexpr const char * typeName
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::TimeReference > rosStyle
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: TimeReference.h:60
yarp::os::Type getType() const override
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
static constexpr const char * typeText
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: TimeReference.h:82
yarp::rosmsg::std_msgs::Header header
Definition: TimeReference.h:37
static constexpr const char * typeChecksum
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:159
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:112
The main, catch-all namespace for YARP.
Definition: dirs.h:16