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_HEADER_H 00024 #define VARIANT_TOPIC_TOOLS_MESSAGE_HEADER_H 00025 00026 #include <ros/ros.h> 00027 00028 #include <variant_topic_tools/Forwards.h> 00029 00030 namespace variant_topic_tools { 00033 class MessageHeader { 00034 friend class Message; 00035 friend class ros::serialization::PreDeserialize<Message>; 00036 public: 00039 MessageHeader(); 00040 00043 MessageHeader(const MessageHeader& src); 00044 00047 ~MessageHeader(); 00048 00051 void setField(const std::string& name, const std::string& value); 00052 00055 const std::string& getField(const std::string& name) const; 00056 00059 void setPublisher(const std::string& publisher); 00060 00063 const std::string& getPublisher() const; 00064 00067 void setTopic(const std::string& topic); 00068 00071 const std::string& getTopic() const; 00072 00076 void setLatched(bool latched); 00077 00080 bool isLatched() const; 00081 00085 bool hasField(const std::string& name) const; 00086 00090 std::string& operator[](const std::string& name); 00091 00095 const std::string& operator[](const std::string& name) const; 00096 00097 protected: 00100 typedef std::map<std::string, std::string> Fields; 00101 00104 typedef boost::shared_ptr<std::map<std::string, std::string> > FieldsPtr; 00105 00108 FieldsPtr fields; 00109 00112 MessageHeader(const FieldsPtr& fields); 00113 }; 00114 }; 00115 00116 #endif