MessageVariable.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_VARIABLE_H
00024 #define VARIANT_TOPIC_TOOLS_MESSAGE_VARIABLE_H
00025 
00026 #include <variant_topic_tools/DataType.h>
00027 #include <variant_topic_tools/MessageMember.h>
00028 #include <variant_topic_tools/MessageTypeTraits.h>
00029 #include <variant_topic_tools/Pointer.h>
00030 
00031 namespace variant_topic_tools {
00034   class MessageVariable :
00035     public MessageMember {
00036   friend class MessageDataType;
00037   friend class MessageMember;
00038   friend class MessageVariant;
00039   public:
00042     MessageVariable();
00043     
00046     MessageVariable(const MessageVariable& src);
00047     
00050     MessageVariable(const MessageMember& src);
00051     
00054     ~MessageVariable();
00055     
00056   protected:
00059     class Impl :
00060       public MessageMember::Impl {
00061     public:
00064       Impl(const std::string& name, const DataType& type);
00065       
00068       virtual ~Impl();
00069       
00072       const DataType& getType() const;
00073     
00076       void write(std::ostream& stream) const;
00077       
00080       DataType type;
00081     };
00082     
00086     template <typename T> class ImplT :
00087       public Impl {
00088     public:
00089       BOOST_STATIC_ASSERT(type_traits::IsMessage<T>::value);
00090       
00093       typedef typename type_traits::MessageType<T>::ValueType ValueType;
00094       
00097       ImplT(const std::string& name, const DataType& type);
00098       
00101       virtual ~ImplT();
00102       
00106       virtual Variant createVariant(const Pointer<ValueType>& message)
00107         const = 0;
00108     };
00109     
00113     template <typename T, typename M> class ImplM :
00114       public ImplT<T> {
00115     public:
00118       typedef typename ImplT<T>::ValueType ValueType;
00119       
00122       ImplM(const std::string& name, const DataType& type, size_t offset);
00123       
00126       virtual ~ImplM();
00127       
00131       Variant createVariant(const Pointer<ValueType>& message) const;
00132       
00135       size_t offset;
00136     };
00137     
00140     MessageVariable(const std::string& name, const DataType& type);
00141     
00144     template <typename T, typename M> static MessageVariable create(const
00145       std::string& name, size_t offset);
00146   };
00147 };
00148 
00149 #include <variant_topic_tools/MessageVariable.tpp>
00150 
00151 #endif


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