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_CONSTANT_H 00024 #define VARIANT_TOPIC_TOOLS_MESSAGE_CONSTANT_H 00025 00026 #include <variant_topic_tools/MessageMember.h> 00027 #include <variant_topic_tools/Variant.h> 00028 00029 namespace variant_topic_tools { 00032 class MessageConstant : 00033 public MessageMember { 00034 friend class MessageDataType; 00035 friend class MessageMember; 00036 public: 00039 MessageConstant(); 00040 00043 MessageConstant(const MessageConstant& src); 00044 00047 MessageConstant(const MessageMember& src); 00048 00051 ~MessageConstant(); 00052 00055 const Variant& getValue() const; 00056 00057 protected: 00060 class Impl : 00061 public MessageMember::Impl { 00062 public: 00065 Impl(const std::string& name, const Variant& value); 00066 00069 virtual ~Impl(); 00070 00073 const DataType& getType() const; 00074 00077 void write(std::ostream& stream) const; 00078 00081 Variant value; 00082 }; 00083 00087 MessageConstant(const std::string& name, const Variant& value); 00088 00092 MessageConstant(const std::string& name, const DataType& type, 00093 const std::string& value); 00094 00097 template <typename T> static MessageConstant create(const std::string& 00098 name, const T& value); 00099 }; 00100 }; 00101 00102 #include <variant_topic_tools/MessageConstant.tpp> 00103 00104 #endif