MessageTopicRegistry.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 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 
19 #include <QDir>
20 #include <QMutexLocker>
21 
22 #include <ros/master.h>
23 
25 
26 namespace rqt_multiplot {
27 
28 /*****************************************************************************/
29 /* Static Initializations */
30 /*****************************************************************************/
31 
32 MessageTopicRegistry::Impl MessageTopicRegistry::impl_;
33 
34 /*****************************************************************************/
35 /* Constructors and Destructor */
36 /*****************************************************************************/
37 
39  QObject(parent) {
40  connect(&impl_, SIGNAL(started()), this, SLOT(threadStarted()));
41  connect(&impl_, SIGNAL(finished()), this, SLOT(threadFinished()));
42 }
43 
45 }
46 
48  QThread(parent) {
49 }
50 
52  terminate();
53  wait();
54 }
55 
56 /*****************************************************************************/
57 /* Accessors */
58 /*****************************************************************************/
59 
60 QMap<QString, QString> MessageTopicRegistry::getTopics() const {
61  QMutexLocker lock(&impl_.mutex_);
62 
63  return impl_.topics_;
64 }
65 
67  return impl_.isRunning();
68 }
69 
71  QMutexLocker lock(&impl_.mutex_);
72 
73  return impl_.topics_.isEmpty();
74 }
75 
76 /*****************************************************************************/
77 /* Methods */
78 /*****************************************************************************/
79 
81  impl_.start();
82 }
83 
85  std::vector<ros::master::TopicInfo> topics;
86 
87  mutex_.lock();
88  topics_.clear();
89  mutex_.unlock();
90 
91  if (ros::master::getTopics(topics)) {
92  for (size_t i = 0; i < topics.size(); ++i) {
93  QString topic = QString::fromStdString(topics[i].name);
94  QString type = QString::fromStdString(topics[i].datatype);
95 
96  topics_[topic] = type;
97  }
98  }
99 }
100 
101 /*****************************************************************************/
102 /* Slots */
103 /*****************************************************************************/
104 
106  emit updateStarted();
107 }
108 
110  emit updateFinished();
111 }
112 
113 }
ROSCPP_DECL bool getTopics(V_TopicInfo &topics)
void wait(int seconds)
QMap< QString, QString > getTopics() const


rqt_multiplot_plugin
Author(s): Ralf Kaestner
autogenerated on Fri Jan 15 2021 03:47:53