MessageSerializer.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_MESSAGE_SERIALIZER_H
00024 #define VARIANT_TOPIC_TOOLS_MESSAGE_SERIALIZER_H
00025 
00026 #include <variant_topic_tools/MessageFieldCollection.h>
00027 #include <variant_topic_tools/MessageTypeTraits.h>
00028 #include <variant_topic_tools/Serializer.h>
00029 
00030 namespace variant_topic_tools {
00033   class MessageSerializer :
00034     public Serializer {
00035   friend class MessageDataType;
00036   friend class MessageVariant;
00037   public:
00040     MessageSerializer();
00041     
00044     MessageSerializer(const MessageSerializer& src);
00045     
00048     MessageSerializer(const Serializer& src);
00049     
00052     ~MessageSerializer();
00053     
00054   protected:
00057     class Impl :
00058       public virtual Serializer::Impl {
00059     public:
00062       Impl();
00063       
00066       virtual ~Impl();
00067     };
00068     
00071     class ImplV :
00072       public Impl {
00073     public:
00076       ImplV(const MessageFieldCollection<Serializer>& memberSerializers =
00077         MessageFieldCollection<Serializer>());
00078       
00081       virtual ~ImplV();
00082     
00086       size_t getSerializedLength(const Variant& value) const;
00087       
00090       void serialize(ros::serialization::OStream& stream, const
00091         Variant& value);
00092       
00095       void deserialize(ros::serialization::IStream& stream, Variant& value);
00096         
00099       MessageFieldCollection<Serializer> memberSerializers;
00100     };
00101     
00105     template <typename T> class ImplT :
00106       public Impl {
00107     public:
00108       BOOST_STATIC_ASSERT(type_traits::IsMessage<T>::value);
00109       
00112       typedef typename type_traits::MessageType<T>::ValueType ValueType;
00113       
00116       ImplT();
00117       
00120       virtual ~ImplT();
00121     
00125       size_t getSerializedLength(const Variant& value) const;
00126       
00129       void serialize(ros::serialization::OStream& stream, const
00130         Variant& value);
00131       
00134       void deserialize(ros::serialization::IStream& stream, Variant& value);
00135     };
00136     
00140     MessageSerializer(const MessageFieldCollection<Serializer>&
00141       memberSerializers);
00142     
00143     
00146     template <typename T> static MessageSerializer create();
00147   };
00148 };
00149 
00150 #include <variant_topic_tools/MessageSerializer.tpp>
00151 
00152 #endif


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Fri Aug 5 2016 06:06:27