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_MEMBER_H 00024 #define VARIANT_TOPIC_TOOLS_MESSAGE_MEMBER_H 00025 00026 #include <variant_topic_tools/Forwards.h> 00027 00028 namespace variant_topic_tools { 00031 class MessageMember { 00032 friend class MessageDataType; 00033 public: 00036 MessageMember(); 00037 00040 MessageMember(const MessageMember& src); 00041 00044 ~MessageMember(); 00045 00048 const std::string& getName() const; 00049 00052 const DataType& getType() const; 00053 00056 bool isVariable() const; 00057 00060 bool isConstant() const; 00061 00064 bool isValid() const; 00065 00068 void write(std::ostream& stream) const; 00069 00072 inline operator void*() const { 00073 return (impl) ? (void*)1 : (void*)0; 00074 }; 00075 00076 protected: 00079 class Impl { 00080 public: 00083 Impl(const std::string& name); 00084 00087 virtual ~Impl(); 00088 00092 virtual const DataType& getType() const = 0; 00093 00096 virtual void write(std::ostream& stream) const = 0; 00097 00100 std::string name; 00101 }; 00102 00105 typedef boost::shared_ptr<Impl> ImplPtr; 00106 00110 typedef boost::weak_ptr<Impl> ImplWPtr; 00111 00114 ImplPtr impl; 00115 }; 00116 00119 std::ostream& operator<<(std::ostream& stream, const MessageMember& 00120 messageMember); 00121 }; 00122 00123 #endif