BuiltinTypeTraits.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (C) 2014 by Ralf Kaestner                                        *
00003  * ralf.kaestner@gmail.com                                                    *
00004  *                                                                            *
00005  * This program is free software; you can redistribute it and/or modify       *
00006  * it under the terms of the Lesser GNU General Public License as published by*
00007  * the Free Software Foundation; either version 3 of the License, or          *
00008  * (at your option) any later version.                                        *
00009  *                                                                            *
00010  * This program is distributed in the hope that it will be useful,            *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the               *
00013  * Lesser GNU General Public License for more details.                        *
00014  *                                                                            *
00015  * You should have received a copy of the Lesser GNU General Public License   *
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.       *
00017  ******************************************************************************/
00018 
00023 #ifndef VARIANT_TOPIC_TOOLS_BUILTIN_TYPE_TRAITS_H
00024 #define VARIANT_TOPIC_TOOLS_BUILTIN_TYPE_TRAITS_H
00025 
00026 #include <string>
00027 
00028 #include <boost/type_traits.hpp>
00029 #include <boost/type_traits/ice.hpp>
00030 
00031 #include <ros/duration.h>
00032 #include <ros/message_traits.h>
00033 #include <ros/time.h>
00034 
00035 namespace variant_topic_tools {
00036   namespace type_traits {
00037     template <typename T, typename D = void> struct IsBuiltin :
00038       public boost::type_traits::ice_or<
00039         boost::is_integral<T>::value,
00040         boost::is_floating_point<T>::value> {
00041     };
00042 
00043     template <typename D> struct IsBuiltin<std::string, D> :
00044       public boost::true_type {
00045     };
00046 
00047     template <typename D> struct IsBuiltin<ros::Duration, D> :
00048       public boost::true_type {
00049     };
00050 
00051     template <typename D> struct IsBuiltin<ros::Time, D> :
00052       public boost::true_type {
00053     };
00054 
00055     template <typename T, typename D = void> struct BuiltinType {
00056       typedef T ValueType;
00057       typedef T StreamType;
00058       typedef boost::type_traits::ice_or<
00059         boost::is_integral<T>::value,
00060         boost::is_floating_point<T>::value> IsNumeric;
00061       typedef ros::message_traits::IsFixedSize<ValueType> IsFixedSize;
00062       typedef ros::message_traits::IsSimple<ValueType> IsSimple;
00063     };
00064 
00065     template <typename D> struct BuiltinType<uint8_t, D> {
00066       typedef uint8_t ValueType;
00067       typedef uint32_t StreamType;
00068       typedef boost::true_type IsNumeric;
00069       typedef ros::message_traits::IsFixedSize<ValueType> IsFixedSize;
00070       typedef ros::message_traits::IsSimple<ValueType> IsSimple;
00071     };
00072 
00073     template <typename D> struct BuiltinType<int8_t, D> {
00074       typedef int8_t ValueType;
00075       typedef int32_t StreamType;
00076       typedef boost::true_type IsNumeric;
00077       typedef ros::message_traits::IsFixedSize<ValueType> IsFixedSize;
00078       typedef ros::message_traits::IsSimple<ValueType> IsSimple;
00079     };
00080 
00081     template <typename D> struct BuiltinType<bool, D> {
00082       typedef uint8_t ValueType;
00083       typedef std::string StreamType;
00084       typedef boost::true_type IsNumeric;
00085       typedef ros::message_traits::IsFixedSize<ValueType> IsFixedSize;
00086       typedef ros::message_traits::IsSimple<ValueType> IsSimple;
00087     };
00088 
00089     template <typename D> struct BuiltinType<ros::Duration, D> {
00090       typedef ros::Duration ValueType;
00091       typedef ros::Duration StreamType;
00092       typedef boost::true_type IsNumeric;
00093       typedef ros::message_traits::IsFixedSize<ValueType> IsFixedSize;
00094       typedef ros::message_traits::IsSimple<ValueType> IsSimple;
00095     };
00096 
00097     template <typename D> struct BuiltinType<ros::Time, D> {
00098       typedef ros::Time ValueType;
00099       typedef ros::Time StreamType;
00100       typedef boost::true_type IsNumeric;
00101       typedef ros::message_traits::IsFixedSize<ValueType> IsFixedSize;
00102       typedef ros::message_traits::IsSimple<ValueType> IsSimple;
00103     };
00104 
00105     template <typename T> struct ToBuiltinType {
00106       typedef T BuiltinType;
00107     };
00108 
00109     template <size_t N> struct ToBuiltinType<char[N]> {
00110       typedef std::string BuiltinType;
00111     };
00112   };
00113 };
00114 
00115 #endif


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Tue Jul 9 2019 03:18:42