Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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