YARP
Yet Another Robot Platform
TimeReference.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2018 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  {
210  yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
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
static constexpr const char * typeName
bool writeBare(yarp::os::ConnectionWriter &connection) const override
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
#define BOTTLE_TAG_STRING
Definition: Bottle.h:28
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
static constexpr const char * typeChecksum
static Type byName(const char *name)
Definition: Type.cpp:176
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:138
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: TimeReference.h:63
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::TimeReference > rosStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::TimeReference > bottleStyle
virtual bool isError() const =0
yarp::os::Type getType() const override
The main, catch-all namespace for YARP.
Definition: numeric.h:47
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary...
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: TickTime.h:151
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::std_msgs::Header header
Definition: TimeReference.h:40
static constexpr const char * typeText
An interface for writing to a network connection.
virtual bool write(const yarp::os::idl::WireWriter &writer) const
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool isError() const =0
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:162
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:33
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
An interface for reading from a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: TickTime.h:116
A single value (typically within a Bottle).
Definition: Value.h:46
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:330
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: TimeReference.h:85
IDL-friendly connection reader.
Definition: WireReader.h:32
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:115
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.