MessageTypeRegistry.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/package.h>
23 
25 
26 namespace rqt_multiplot {
27 
28 /*****************************************************************************/
29 /* Static Initializations */
30 /*****************************************************************************/
31 
32 MessageTypeRegistry::Impl MessageTypeRegistry::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 QList<QString> MessageTypeRegistry::getTypes() const {
61  QMutexLocker lock(&impl_.mutex_);
62 
63  return impl_.types_;
64 }
65 
67  return impl_.isRunning();
68 }
69 
71  QMutexLocker lock(&impl_.mutex_);
72 
73  return impl_.types_.isEmpty();
74 }
75 
76 /*****************************************************************************/
77 /* Methods */
78 /*****************************************************************************/
79 
81  impl_.start();
82 }
83 
85  impl_.wait();
86 }
87 
89  std::vector<std::string> packages;
90 
91  mutex_.lock();
92  types_.clear();
93  mutex_.unlock();
94 
95  if (ros::package::getAll(packages)) {
96  for (size_t i = 0; i < packages.size(); ++i) {
97  QString package = QString::fromStdString(packages[i]);
98  QDir directory(QString::fromStdString(ros::package::
99  getPath(packages[i]))+"/msg");
100 
101  if (directory.exists()) {
102  QList<QString> filters;
103  filters.append("*.msg");
104 
105  QFileInfoList entries = directory.entryInfoList(filters,
106  QDir::Files | QDir::Readable);
107 
108  for (QFileInfoList::iterator it = entries.begin(); it !=
109  entries.end(); ++it) {
110  mutex_.lock();
111  types_.append(package+"/"+it->baseName());
112  mutex_.unlock();
113  }
114  }
115  }
116  }
117 }
118 
119 /*****************************************************************************/
120 /* Slots */
121 /*****************************************************************************/
122 
124  emit updateStarted();
125 }
126 
128  emit updateFinished();
129 }
130 
131 }
ROSLIB_DECL bool getAll(V_string &packages)
string package
ROSLIB_DECL std::string getPath(const std::string &package_name)


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44