ros_topic_property.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef ROS_TOPIC_PROPERTY_H
30 #define ROS_TOPIC_PROPERTY_H
31 
32 #include <string>
33 
35 #include <rviz/rviz_export.h>
36 
37 namespace rviz
38 {
39 class RVIZ_EXPORT RosTopicProperty : public EditableEnumProperty
40 {
41  Q_OBJECT
42 public:
43  RosTopicProperty(const QString& name = QString(),
44  const QString& default_value = QString(),
45  const QString& message_type = QString(),
46  const QString& description = QString(),
47  Property* parent = nullptr);
48 
49  template <typename Func, typename R>
50  RosTopicProperty(const QString& name,
51  const QString& default_value,
52  const QString& message_type,
53  const QString& description,
54  Property* parent,
55  Func&& changed_slot,
56  const R* receiver)
57  : RosTopicProperty(name, default_value, message_type, description, parent)
58  {
59  connect(receiver, std::forward<Func>(changed_slot));
60  }
61 
62  // this variant is required to allow omitting the receiver argument
63  template <typename Func, typename P>
64  RosTopicProperty(const QString& name,
65  const QString& default_value,
66  const QString& message_type,
67  const QString& description,
68  P* parent,
69  Func&& changed_slot)
70  : RosTopicProperty(name, default_value, message_type, description, parent)
71  {
72  connect(parent, std::forward<Func>(changed_slot));
73  }
74 
75  void setMessageType(const QString& message_type);
76  QString getMessageType() const
77  {
78  return message_type_;
79  }
80 
81  QString getTopic() const
82  {
83  return getValue().toString();
84  }
85  std::string getTopicStd() const
86  {
87  return getValue().toString().toStdString();
88  }
89 
90 protected Q_SLOTS:
91  virtual void fillTopicList();
92 
93 private:
94  QString message_type_;
95 };
96 
97 } // end namespace rviz
98 
99 #endif // ROS_TOPIC_PROPERTY_H
rviz::RosTopicProperty
Definition: ros_topic_property.h:39
rviz::RosTopicProperty::RosTopicProperty
RosTopicProperty(const QString &name, const QString &default_value, const QString &message_type, const QString &description, P *parent, Func &&changed_slot)
Definition: ros_topic_property.h:64
rviz::RosTopicProperty::message_type_
QString message_type_
Definition: ros_topic_property.h:94
rviz::EditableEnumProperty
Editable Enum property.
Definition: editable_enum_property.h:43
description
description
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz
Definition: add_display_dialog.cpp:54
rviz::RosTopicProperty::RosTopicProperty
RosTopicProperty(const QString &name, const QString &default_value, const QString &message_type, const QString &description, Property *parent, Func &&changed_slot, const R *receiver)
Definition: ros_topic_property.h:50
rviz::RosTopicProperty::getTopic
QString getTopic() const
Definition: ros_topic_property.h:81
rviz::RosTopicProperty::getTopicStd
std::string getTopicStd() const
Definition: ros_topic_property.h:85
rviz::RosTopicProperty::getMessageType
QString getMessageType() const
Definition: ros_topic_property.h:76
default_value
def default_value(type_)
editable_enum_property.h


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10