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