MessageField.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_FIELD_H
00024 #define VARIANT_TOPIC_TOOLS_MESSAGE_FIELD_H
00025 
00026 #include <boost/type_traits.hpp>
00027 
00028 #include <ros/ros.h>
00029 
00030 #include <variant_topic_tools/MessageFieldCollection.h>
00031 #include <variant_topic_tools/MessageFieldTypeTraits.h>
00032 #include <variant_topic_tools/MessageType.h>
00033 
00034 namespace variant_topic_tools {
00037   template <typename T> class MessageField :
00038     public MessageFieldCollection<T> {
00039   public:
00042     MessageField(const std::string& name = std::string(), const
00043       T& value = T());
00044     
00047     MessageField(const MessageField<T>& src);
00048     
00051     virtual ~MessageField();
00052     
00055     void setName(const std::string& name);
00056     
00059     const std::string& getName() const;
00060     
00063     void setValue(const T& value);
00064     
00067     T& getValue();
00068     
00071     const T& getValue() const;
00072     
00075     bool isValid() const;
00076     
00079     void clear();
00080     
00083     void write(std::ostream& stream, const std::string& indent =
00084       std::string()) const;
00085     
00088     bool operator==(const MessageField<T>& field) const;
00089     
00093     bool operator!=(const MessageField<T>& field) const;
00094     
00095   protected:
00098     std::string name;
00099     
00102     T value;
00103     
00107     template <typename U> static bool isValid(const U& value, typename boost::
00108       enable_if_c<MessageFieldTypeTraits::HasIsValid<U>::value>::type* = 0);
00109     
00113     template <typename U> static bool isValid(const U& value, typename boost::
00114       disable_if_c<MessageFieldTypeTraits::HasIsValid<U>::value>::type* = 0);
00115     
00119     template <typename U> static void writeValue(std::ostream& stream, const
00120       U& value, typename boost::enable_if<boost::has_left_shift<std::ostream,
00121       const U&> >::type* = 0);
00122     
00126     template <typename U> static void writeValue(std::ostream& stream, const
00127       U& value, typename boost::disable_if<boost::has_left_shift<std::ostream,
00128       const U&> >::type* = 0);
00129   };
00130   
00133   template <typename T> std::ostream& operator<<(std::ostream& stream,
00134     const MessageField<T>& messageField);
00135 };
00136 
00137 #include <variant_topic_tools/MessageField.tpp>
00138 
00139 #endif


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Tue Jul 9 2019 03:18:42