MessageType.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2014 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
23 #ifndef VARIANT_TOPIC_TOOLS_MESSAGE_TYPE_H
24 #define VARIANT_TOPIC_TOOLS_MESSAGE_TYPE_H
25 
26 #include <ros/ros.h>
27 
29 
30 namespace variant_topic_tools {
33  class MessageType {
34  public:
37  MessageType(const std::string& dataType = std::string(),
38  const std::string& md5Sum = "*", const std::string&
39  definition = std::string());
40 
44 
47  MessageType(const MessageType& src);
48 
51  ~MessageType();
52 
55  void setDataType(const std::string& dataType);
56 
59  const std::string& getDataType() const;
60 
63  void setMD5Sum(const std::string& md5Sum);
64 
67  const std::string& getMD5Sum() const;
68 
71  void setDefinition(const std::string& definition);
72 
75  const std::string& getDefinition() const;
76 
79  bool isValid() const;
80 
83  template <typename T> static MessageType create();
84 
88  void load(const std::string& messageDataType);
89 
92  void clear();
93 
96  void write(std::ostream& stream) const;
97 
101  std::string& topic, size_t queueSize, bool latch = false,
104 
107  Subscriber subscribe(ros::NodeHandle& nodeHandle, const std::string&
108  topic, size_t queueSize, const SubscriberCallback& callback);
109 
112  bool operator==(const MessageType& type) const;
113 
116  bool operator!=(const MessageType& type) const;
117 
118  protected:
121  std::string dataType;
122 
125  std::string md5Sum;
126 
129  std::string definition;
130  };
131 
134  std::ostream& operator<<(std::ostream& stream, const MessageType&
135  messageType);
136 };
137 
138 #include <variant_topic_tools/MessageType.tpp>
139 
140 #endif
Publisher advertise(ros::NodeHandle &nodeHandle, const std::string &topic, size_t queueSize, bool latch=false, const ros::SubscriberStatusCallback &connectCallback=ros::SubscriberStatusCallback())
Advertise this message type.
void clear()
Clear the message type.
boost::function< void(const SingleSubscriberPublisher &)> SubscriberStatusCallback
Variant message publisher.
Definition: Publisher.h:36
std::string definition
The definition of this message.
Definition: MessageType.h:129
MessageType(const std::string &dataType=std::string(), const std::string &md5Sum="*", const std::string &definition=std::string())
Default constructor.
Definition: MessageType.cpp:44
Variant message subscriber.
Definition: Subscriber.h:36
bool operator!=(const MessageType &type) const
True, if this message type does not equal another message type.
Variant message type information.
Definition: MessageType.h:33
Header file providing forward declarations for the variant topic tools.
void setDataType(const std::string &dataType)
Set the data type of the message.
Definition: MessageType.cpp:70
Subscriber subscribe(ros::NodeHandle &nodeHandle, const std::string &topic, size_t queueSize, const SubscriberCallback &callback)
Subscribe to this message type.
const std::string & getDefinition() const
Retrieve the message definition.
Definition: MessageType.cpp:90
std::string md5Sum
The MD5 sum of this message.
Definition: MessageType.h:125
void callback(const variant_topic_tools::MessageVariant &variant, const ros::Time &receiptTime)
Definition: echo.cpp:58
void connectCallback(const ros::SingleSubscriberPublisher &)
Definition: relay.cpp:65
boost::function< void(const MessageVariant &, const ros::Time &)> SubscriberCallback
Definition of the subscriber callback type.
Definition: Forwards.h:120
void setMD5Sum(const std::string &md5Sum)
Set the MD5 sum of the message.
Definition: MessageType.cpp:78
const std::string & getDataType() const
Retrieve the data type of the message.
Definition: MessageType.cpp:74
ros::NodeHandlePtr nodeHandle
Definition: echo.cpp:23
const std::string & getMD5Sum() const
Retrieve the MD5 sum of the message.
Definition: MessageType.cpp:82
std::ostream & operator<<(std::ostream &stream, const DataType &dataType)
Operator for writing the data type to a stream.
Definition: DataType.cpp:190
void load(const std::string &messageDataType)
Attempt to load the message type corresponding to the specified message data type.
std::string dataType
The data type of this message.
Definition: MessageType.h:121
void write(std::ostream &stream) const
Write the message type to a stream.
bool isValid() const
True, if this message type is valid.
Definition: MessageType.cpp:94
variant_topic_tools::MessageType messageType
Definition: publish.cpp:33
void setDefinition(const std::string &definition)
Set the message definition.
Definition: MessageType.cpp:86
bool operator==(const MessageType &type) const
True, if this message type equals another message type.
static MessageType create()
Create a message type.


variant_topic_tools
Author(s): Ralf Kaestner
autogenerated on Sat Jan 9 2021 03:56:49