Robowflex  v0.1
Making MoveIt Easy
macros.h
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #ifndef ROBOWFLEX_MACROS_
4 #define ROBOWFLEX_MACROS_
5 
6 #include <boost/version.hpp> // for boost version macros
7 
8 #include <moveit/version.h> // for MoveIt version macros
9 
10 #include <ros/common.h> // for ROS version macros
11 
12 /** \file */
13 
14 ///
15 /// Other Macros
16 ///
17 
18 /** \def Checks if a include file exists. */
19 #define ROBOWFLEX_INCLUDE_EXISTS(file) __has_include(file)
20 
21 ///
22 /// ROS Version Checking
23 ///
24 
25 /** \def Tests if the ROS version is Indigo or higher. */
26 #define ROBOWFLEX_AT_LEAST_INDIGO ROS_VERSION_MINIMUM(1, 11, 0)
27 
28 /** \def Tests if the ROS version is Kinetic or higher. */
29 #define ROBOWFLEX_AT_LEAST_KINETIC ROS_VERSION_MINIMUM(1, 12, 0)
30 
31 /** \def Tests if the ROS version is Lunar or higher. */
32 #define ROBOWFLEX_AT_LEAST_LUNAR ROS_VERSION_MINIMUM(1, 13, 0)
33 
34 /** \def Tests if the ROS version is Melodic or higher. */
35 #define ROBOWFLEX_AT_LEAST_MELODIC ROS_VERSION_MINIMUM(1, 14, 0)
36 
37 /** \def Tests if the ROS version is Noetic or higher. */
38 #define ROBOWFLEX_AT_LEAST_NOETIC ROS_VERSION_MINIMUM(1, 15, 0)
39 
40 /** \def Tests if the ROS version is not further than Melodic */
41 #define ROBOWFLEX_AT_MOST_MELODIC \
42  ROS_VERSION_GE(1, 15, 0, ROS_VERSION_MAJOR, ROS_VERSION_MINOR, ROS_VERSION_PATCH)
43 
44 /** \def Tests if boost is at least version 1.64 */
45 #define IS_BOOST_164 (BOOST_VERSION >= 106400u)
46 
47 /** \def Tests if boost is at least version 1.58 */
48 #define IS_BOOST_158 (BOOST_VERSION >= 105800u)
49 
50 #if ROBOWFLEX_AT_LEAST_KINETIC
51 /** \def Sets flow style for YAML nodes. */
52 #define ROBOWFLEX_YAML_FLOW(n) n.SetStyle(YAML::EmitterStyle::Flow);
53 #else
54 #define ROBOWFLEX_YAML_FLOW(n)
55 #endif
56 
57 ///
58 /// MoveIt Version Checking
59 ///
60 
61 /** \def Phrase MoveIt version as integer. */
62 #define ROBOWFLEX_MOVEIT_VERSION_COMPUTE(major, minor, patch) \
63  ((major * 100000u) + (minor * 1000u) + (patch * 1u))
64 #define ROBOWFLEX_MOVEIT_VERSION \
65  ROBOWFLEX_MOVEIT_VERSION_COMPUTE(MOVEIT_VERSION_MAJOR, MOVEIT_VERSION_MINOR, MOVEIT_VERSION_PATCH)
66 
67 ///
68 /// Compiler Warning Helpers
69 ///
70 
71 /** \def Stringify helper macro. */
72 #define ROBOWFLEX_PRAGMA_HELPER0(x) #x
73 /** \def Pragma generator helper macro. */
74 #define ROBOWFLEX_PRAGMA_HELPER1(x, y) ROBOWFLEX_PRAGMA_HELPER0(x diagnostic ignored y)
75 
76 /** \def Push a pragma to disable a compiler warning for GCC. */
77 #define ROBOWFLEX_PUSH_DISABLE_GCC_WARNING(warning)
78 
79 /** \def Pop a compiler warning for GCC. */
80 #define ROBOWFLEX_POP_GCC
81 
82 /** \def Push a pragma to disable a compiler warning for clang. */
83 #define ROBOWFLEX_PUSH_DISABLE_CLANG_WARNING(warning)
84 
85 /** \def Pop a compiler warning for clang. */
86 #define ROBOWFLEX_POP_CLANG
87 
88 /** \cond IGNORE */
89 #if defined(__clang__)
90 #undef ROBOWFLEX_PUSH_DISABLE_CLANG_WARNING
91 #undef ROBOWFLEX_POP_CLANG
92 #define ROBOWFLEX_PUSH_DISABLE_CLANG_WARNING(warning) \
93  _Pragma("clang diagnostic push") \
94  _Pragma(ROBOWFLEX_PRAGMA_HELPER1(clang, ROBOWFLEX_PRAGMA_HELPER0(warning)))
95 #define ROBOWFLEX_POP_CLANG _Pragma("GCC diagnostic pop")
96 #elif defined __GNUC__
97 #undef ROBOWFLEX_PUSH_DISABLE_GCC_WARNING
98 #undef ROBOWFLEX_POP_GCC
99 #define ROBOWFLEX_PUSH_DISABLE_GCC_WARNING(warning) \
100  _Pragma("GCC diagnostic push") _Pragma(ROBOWFLEX_PRAGMA_HELPER1(GCC, ROBOWFLEX_PRAGMA_HELPER0(warning)))
101 #define ROBOWFLEX_POP_GCC _Pragma("GCC diagnostic pop")
102 #endif
103 /** \endcond */
104 
105 ///
106 /// Type information helpers
107 ///
108 
109 #if IS_BOOST_158
110 #include <boost/core/demangle.hpp>
111 #define ROBOWFLEX_DEMANGLE(x) boost::core::demangle(x)
112 #else
113 #include <boost/exception/detail/type_info.hpp>
114 #define ROBOWFLEX_DEMANGLE(x) boost::units::detail::demangle(x)
115 #endif
116 
117 #endif