message_traits.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009, Willow Garage, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Willow Garage, Inc. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef ROSLIB_MESSAGE_TRAITS_H
29 #define ROSLIB_MESSAGE_TRAITS_H
30 
31 #include "message_forward.h"
32 
33 #include "ros/time.h"
34 
35 #include <string>
36 #include "boost/enable_if.hpp"
37 
38 #include <memory.h>
40 
41 namespace std_msgs
42 {
44 }
45 
46 #define ROS_IMPLEMENT_SIMPLE_TOPIC_TRAITS(msg, md5sum, datatype, definition) \
47  namespace rs2rosinternal \
48  { \
49  namespace message_traits \
50  { \
51  template<> struct MD5Sum<msg> \
52  { \
53  static const char* value() { return md5sum; } \
54  static const char* value(const msg&) { return value(); } \
55  }; \
56  template<> struct DataType<msg> \
57  { \
58  static const char* value() { return datatype; } \
59  static const char* value(const msg&) { return value(); } \
60  }; \
61  template<> struct Definition<msg> \
62  { \
63  static const char* value() { return definition; } \
64  static const char* value(const msg&) { return value(); } \
65  }; \
66  } \
67  }
68 
69 
70 namespace rs2rosinternal
71 {
72 namespace message_traits
73 {
74 
79 struct TrueType
80 {
81  static const bool value = true;
82  typedef TrueType type;
83 };
84 
89 struct FalseType
90 {
91  static const bool value = false;
92  typedef FalseType type;
93 };
94 
99 template<typename M> struct IsSimple : public FalseType {};
103 template<typename M> struct IsFixedSize : public FalseType {};
107 template<typename M> struct HasHeader : public FalseType {};
108 
112 template<typename M> struct IsMessage : public FalseType {};
113 
117 template<typename M>
118 struct MD5Sum
119 {
120  static const char* value()
121  {
122  return M::__s_getMD5Sum();
123  }
124 
125  static const char* value(const M& m)
126  {
127  return m.__getMD5Sum();
128  }
129 };
130 
134 template<typename M>
135 struct DataType
136 {
137  static const char* value()
138  {
139  return M::__s_getDataType();
140  }
141 
142  static const char* value(const M& m)
143  {
144  return m.__getDataType();
145  }
146 };
147 
151 template<typename M>
153 {
154  static const char* value()
155  {
156  return M::__s_getMessageDefinition();
157  }
158 
159  static const char* value(const M& m)
160  {
161  return m.__getMessageDefinition();
162  }
163 };
164 
169 template<typename M, typename Enable = void>
170 struct Header
171 {
172  static std_msgs::Header* pointer(M& m) { (void)m; return 0; }
173  static std_msgs::Header const* pointer(const M& m) { (void)m; return 0; }
174 };
175 
176 template<typename M>
177 struct Header<M, typename boost::enable_if<HasHeader<M> >::type >
178 {
179  static std_msgs::Header* pointer(M& m) { return &m.header; }
180  static std_msgs::Header const* pointer(const M& m) { return &m.header; }
181 };
182 
188 template<typename M, typename Enable = void>
189 struct FrameId
190 {
191  static std::string* pointer(M& m) { (void)m; return 0; }
192  static std::string const* pointer(const M& m) { (void)m; return 0; }
193 };
194 
195 template<typename M>
196 struct FrameId<M, typename boost::enable_if<HasHeader<M> >::type >
197 {
198  static std::string* pointer(M& m) { return &m.header.frame_id; }
199  static std::string const* pointer(const M& m) { return &m.header.frame_id; }
200  static std::string value(const M& m) { return m.header.frame_id; }
201 };
202 
208 template<typename M, typename Enable = void>
209 struct TimeStamp
210 {
211  static rs2rosinternal::Time* pointer(M& m) { (void)m; return 0; }
212  static rs2rosinternal::Time const* pointer(const M& m) { (void)m; return 0; }
213 };
214 
215 template<typename M>
216 struct TimeStamp<M, typename boost::enable_if<HasHeader<M> >::type >
217 {
218  static rs2rosinternal::Time* pointer(typename std::remove_const<M>::type &m) { return &m.header.stamp; }
219  static rs2rosinternal::Time const* pointer(const M& m) { return &m.header.stamp; }
220  static rs2rosinternal::Time value(const M& m) { return m.header.stamp; }
221 };
222 
226 template<typename M>
227 inline const char* md5sum()
228 {
230 }
231 
235 template<typename M>
236 inline const char* datatype()
237 {
239 }
240 
244 template<typename M>
245 inline const char* definition()
246 {
248 }
249 
253 template<typename M>
254 inline const char* md5sum(const M& m)
255 {
257 }
258 
262 template<typename M>
263 inline const char* datatype(const M& m)
264 {
266 }
267 
271 template<typename M>
272 inline const char* definition(const M& m)
273 {
275 }
276 
280 template<typename M>
282 {
284 }
285 
289 template<typename M>
290 inline std_msgs::Header const* header(const M& m)
291 {
293 }
294 
298 template<typename M>
300 {
302 }
303 
307 template<typename M>
308 inline std::string const* frameId(const M& m)
309 {
311 }
312 
316 template<typename M>
318 {
320 }
321 
325 template<typename M>
326 inline rs2rosinternal::Time const* timeStamp(const M& m)
327 {
329 }
330 
334 template<typename M>
335 inline bool isSimple()
336 {
338 }
339 
343 template<typename M>
344 inline bool isFixedSize()
345 {
347 }
348 
352 template<typename M>
353 inline bool hasHeader()
354 {
356 }
357 
358 } // namespace message_traits
359 } // namespace rs2rosinternal
360 
361 #endif // ROSLIB_MESSAGE_TRAITS_H
static std_msgs::Header * pointer(M &m)
GLenum GLsizei const void * pointer
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
Base type for compile-type true/false tests. Compatible with Boost.MPL. classes inheriting from this ...
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
rs2rosinternal::Time const * timeStamp(const M &m)
returns TimeStamp<M>::pointer(m);
#define ROS_DECLARE_MESSAGE(msg)
Forward-declare a message, including Ptr and ConstPtr types, using std::allocator.
const GLfloat * m
Definition: glext.h:6814
Specialize to provide the md5sum for a message.
GLfloat value
static const char * value(const M &m)
Base type for compile-type true/false tests. Compatible with Boost.MPL. classes inheriting from this ...
GLsizei const GLchar *const * string
bool hasHeader()
returns HasHeader<M>::value;
Specialize to provide the datatype for a message.
HasHeader informs whether or not there is a header that gets serialized as the first thing in the mes...
static std_msgs::Header const * pointer(const M &m)
static std::string const * pointer(const M &m)
A fixed-size datatype is one whose size is constant, i.e. it has no variable-length arrays or strings...
std_msgs::Header const * header(const M &m)
returns Header<M>::pointer(m);
bool isSimple()
returns IsSimple<M>::value;
static std::string * pointer(M &m)
A simple datatype is one that can be memcpy&#39;d directly in array form, i.e. it&#39;s a POD...
const char * md5sum(const M &m)
returns MD5Sum<M>::value(m);
const char * datatype(const M &m)
returns DataType<M>::value(m);
::std_msgs::Header_< std::allocator< void > > Header
Definition: Header.h:57
TimeStamp trait. In the default implementation pointer() returns &m.header.stamp if HasHeader<M>::val...
Time representation. May either represent wall clock time or ROS clock time.
Definition: time.h:177
Definition: Bool.h:19
Specialize to provide the definition for a message.
std::string const * frameId(const M &m)
returns FrameId<M>::pointer(m);
static rs2rosinternal::Time * pointer(typename std::remove_const< M >::type &m)
static rs2rosinternal::Time const * pointer(const M &m)
GLenum type
static rs2rosinternal::Time * pointer(M &m)
FrameId trait. In the default implementation pointer() returns &m.header.frame_id if HasHeader<M>::va...
M
Definition: rmse.py:42
static const char * value(const M &m)
const char * definition(const M &m)
returns Definition<M>::value(m);
static const char * value(const M &m)
bool isFixedSize()
returns IsFixedSize<M>::value;
Header trait. In the default implementation pointer() returns &m.header if HasHeader<M>::value is tru...


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:21