MessageMember.cpp
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 
00019 #include "variant_topic_tools/DataType.h"
00020 #include "variant_topic_tools/MessageConstant.h"
00021 #include "variant_topic_tools/MessageMember.h"
00022 #include "variant_topic_tools/MessageVariable.h"
00023 
00024 namespace variant_topic_tools {
00025 
00026 /*****************************************************************************/
00027 /* Constructors and Destructor                                               */
00028 /*****************************************************************************/
00029 
00030 MessageMember::MessageMember() {
00031 }
00032 
00033 MessageMember::MessageMember(const MessageMember& src) :
00034   impl(src.impl) {
00035 }
00036 
00037 MessageMember::~MessageMember() {
00038 }
00039 
00040 MessageMember::Impl::Impl(const std::string& name) :
00041   name(name) {
00042 }
00043 
00044 MessageMember::Impl::~Impl() {
00045 }
00046 
00047 /*****************************************************************************/
00048 /* Accessors                                                                 */
00049 /*****************************************************************************/
00050 
00051 const std::string& MessageMember::getName() const {
00052   if (!impl) {
00053     static std::string name;
00054     return name;
00055   }
00056   else
00057     return impl->name;
00058 }
00059 
00060 const DataType& MessageMember::getType() const {
00061   if (!impl) {
00062     static DataType type;
00063     return type;
00064   }
00065   else
00066     return impl->getType();
00067 }
00068 
00069 bool MessageMember::isVariable() const {
00070   if (impl)
00071     return boost::dynamic_pointer_cast<MessageVariable::Impl>(impl);
00072   else
00073     return false;
00074 }
00075 
00076 bool MessageMember::isConstant() const {
00077   if (impl)
00078     return boost::dynamic_pointer_cast<MessageConstant::Impl>(impl);
00079   else
00080     return false;
00081 }
00082 
00083 bool MessageMember::isValid() const {
00084   return impl;
00085 }
00086 
00087 /*****************************************************************************/
00088 /* Methods                                                                   */
00089 /*****************************************************************************/
00090 
00091 void MessageMember::write(std::ostream& stream) const {
00092   if (impl)
00093     impl->write(stream);
00094 }
00095 
00096 /*****************************************************************************/
00097 /* Operators                                                                 */
00098 /*****************************************************************************/
00099 
00100 std::ostream& operator<<(std::ostream& stream, const MessageMember&
00101     messageMember) {
00102   messageMember.write(stream);
00103   return stream;
00104 }
00105 
00106 }


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