Serializer.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_SERIALIZER_H
00024 #define VARIANT_TOPIC_TOOLS_SERIALIZER_H
00025 
00026 #include <ros/ros.h>
00027 
00028 #include <variant_topic_tools/DataTypeTraits.h>
00029 #include <variant_topic_tools/Forwards.h>
00030 
00031 namespace variant_topic_tools {
00034   class Serializer {
00035   public:
00038     Serializer();
00039     
00045     Serializer(const DataType& dataType);
00046     
00049     Serializer(const Serializer& src);
00050     
00053     ~Serializer();
00054 
00057     size_t getSerializedLength(const Variant& value) const;
00058     
00061     bool isValid() const;
00062     
00065     void clear();
00066     
00069     void serialize(ros::serialization::OStream& stream, const Variant& value);
00070     
00073     void deserialize(ros::serialization::IStream& stream, Variant& value);
00074     
00077     void advance(ros::serialization::Stream& stream, const Variant& value);
00078     
00081     inline operator void*() const {
00082       return (impl) ? (void*)1 : (void*)0;
00083     };
00084     
00085   protected:
00088     class Impl {
00089     public:
00092       Impl();
00093       
00096       virtual ~Impl();
00097 
00101       virtual size_t getSerializedLength(const Variant& value) const = 0;
00102     
00105       virtual void serialize(ros::serialization::OStream& stream, const
00106         Variant& value) = 0;
00107       
00110       virtual void deserialize(ros::serialization::IStream& stream,
00111         Variant& value) = 0;
00112         
00115       void advance(ros::serialization::Stream& stream, const Variant& value);
00116     };
00117     
00120     typedef boost::shared_ptr<Impl> ImplPtr;
00121     
00124     typedef boost::weak_ptr<Impl> ImplWPtr;
00125     
00128     ImplPtr impl;
00129   };
00130   
00133   std::ostream& operator<<(std::ostream& stream, const Serializer& serializer);
00134 };
00135 
00136 #endif


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