MessageDefinitionLoader.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 <QMutexLocker>
20 
22 
24 
25 namespace rqt_multiplot {
26 
27 /*****************************************************************************/
28 /* Constructors and Destructor */
29 /*****************************************************************************/
30 
32  QObject(parent),
33  impl_(this) {
34  connect(&impl_, SIGNAL(started()), this, SLOT(threadStarted()));
35  connect(&impl_, SIGNAL(finished()), this, SLOT(threadFinished()));
36 }
37 
39  impl_.quit();
40  impl_.wait();
41 }
42 
44  QThread(parent) {
45 }
46 
48  terminate();
49  wait();
50 }
51 
52 /*****************************************************************************/
53 /* Accessors */
54 /*****************************************************************************/
55 
57  QMutexLocker lock(&impl_.mutex_);
58 
59  return impl_.type_;
60 }
61 
62 variant_topic_tools::MessageDefinition MessageDefinitionLoader::
63  getDefinition() const {
64  QMutexLocker lock(&impl_.mutex_);
65 
66  return impl_.definition_;
67 }
68 
70  QMutexLocker lock(&impl_.mutex_);
71 
72  return impl_.error_;
73 }
74 
76  return impl_.isRunning();
77 }
78 
79 /*****************************************************************************/
80 /* Methods */
81 /*****************************************************************************/
82 
83 void MessageDefinitionLoader::load(const QString& type) {
84  impl_.wait();
85 
86  impl_.type_ = type;
87  impl_.start();
88 }
89 
91  impl_.wait();
92 }
93 
95  QMutexLocker lock(&mutex_);
96 
97  error_.clear();
98 
99  try {
100  QMutexLocker lock(&DataTypeRegistry::mutex_);
101 
102  definition_.load(type_.toStdString());
103  }
104  catch (const ros::Exception& exception) {
105  definition_.clear();
106  error_ = QString::fromStdString(exception.what());
107  }
108 }
109 
110 /*****************************************************************************/
111 /* Slots */
112 /*****************************************************************************/
113 
115  emit loadingStarted();
116 }
117 
119  if (impl_.error_.isEmpty())
120  emit loadingFinished();
121  else
122  emit loadingFailed(impl_.error_);
123 }
124 
125 }
variant_topic_tools::MessageDefinition getDefinition() const
void loadingFailed(const QString &error)
variant_topic_tools::MessageDefinition definition_


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