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_SERIALIZER_H 00024 #define VARIANT_TOPIC_TOOLS_BUILTIN_SERIALIZER_H 00025 00026 #include <variant_topic_tools/BuiltinTypeTraits.h> 00027 #include <variant_topic_tools/Serializer.h> 00028 00029 namespace variant_topic_tools { 00032 class BuiltinSerializer : 00033 public Serializer { 00034 friend class BuiltinDataType; 00035 friend class BuiltinVariant; 00036 public: 00039 BuiltinSerializer(); 00040 00043 BuiltinSerializer(const BuiltinSerializer& src); 00044 00047 BuiltinSerializer(const Serializer& src); 00048 00051 ~BuiltinSerializer(); 00052 00053 protected: 00056 class Impl : 00057 public virtual Serializer::Impl { 00058 public: 00061 Impl(); 00062 00065 virtual ~Impl(); 00066 }; 00067 00071 template <typename T> class ImplT : 00072 public Impl { 00073 public: 00074 BOOST_STATIC_ASSERT(type_traits::IsBuiltin<T>::value); 00075 00078 typedef typename type_traits::BuiltinType<T>::ValueType ValueType; 00079 00082 ImplT(); 00083 00086 virtual ~ImplT(); 00087 00091 size_t getSerializedLength(const Variant& value) const; 00092 00095 void serialize(ros::serialization::OStream& stream, const 00096 Variant& value); 00097 00100 void deserialize(ros::serialization::IStream& stream, Variant& value); 00101 }; 00102 00105 template <typename T> static BuiltinSerializer create(); 00106 }; 00107 }; 00108 00109 #include <variant_topic_tools/BuiltinSerializer.tpp> 00110 00111 #endif