Main Page
Namespaces
Classes
Files
File List
src
rqt_multiplot
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
21
#include <
rqt_multiplot/DataTypeRegistry.h
>
22
23
#include "
rqt_multiplot/MessageDefinitionLoader.h
"
24
25
namespace
rqt_multiplot
{
26
27
/*****************************************************************************/
28
/* Constructors and Destructor */
29
/*****************************************************************************/
30
31
MessageDefinitionLoader::MessageDefinitionLoader
(QObject* parent) :
32
QObject(parent),
33
impl_(this) {
34
connect(&
impl_
, SIGNAL(started()),
this
, SLOT(
threadStarted
()));
35
connect(&
impl_
, SIGNAL(finished()),
this
, SLOT(
threadFinished
()));
36
}
37
38
MessageDefinitionLoader::~MessageDefinitionLoader
() {
39
impl_
.quit();
40
impl_
.wait();
41
}
42
43
MessageDefinitionLoader::Impl::Impl
(QObject* parent) :
44
QThread(parent) {
45
}
46
47
MessageDefinitionLoader::Impl::~Impl
() {
48
terminate();
49
wait
();
50
}
51
52
/*****************************************************************************/
53
/* Accessors */
54
/*****************************************************************************/
55
56
QString
MessageDefinitionLoader::getType
()
const
{
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
69
QString
MessageDefinitionLoader::getError
()
const
{
70
QMutexLocker lock(&
impl_
.
mutex_
);
71
72
return
impl_
.
error_
;
73
}
74
75
bool
MessageDefinitionLoader::isLoading
()
const
{
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
90
void
MessageDefinitionLoader::wait
() {
91
impl_
.wait();
92
}
93
94
void
MessageDefinitionLoader::Impl::run
() {
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
114
void
MessageDefinitionLoader::threadStarted
() {
115
emit
loadingStarted
();
116
}
117
118
void
MessageDefinitionLoader::threadFinished
() {
119
if
(
impl_
.
error_
.isEmpty())
120
emit
loadingFinished
();
121
else
122
emit
loadingFailed
(
impl_
.
error_
);
123
}
124
125
}
rqt_multiplot::MessageDefinitionLoader::loadingFinished
void loadingFinished()
rqt_multiplot::MessageDefinitionLoader::getError
QString getError() const
Definition:
MessageDefinitionLoader.cpp:69
rqt_multiplot::MessageDefinitionLoader::getDefinition
variant_topic_tools::MessageDefinition getDefinition() const
Definition:
MessageDefinitionLoader.cpp:63
rqt_multiplot::MessageDefinitionLoader::MessageDefinitionLoader
MessageDefinitionLoader(QObject *parent=0)
Definition:
MessageDefinitionLoader.cpp:31
rqt_multiplot::MessageDefinitionLoader::wait
void wait()
Definition:
MessageDefinitionLoader.cpp:90
rqt_multiplot::MessageDefinitionLoader::load
void load(const QString &type)
Definition:
MessageDefinitionLoader.cpp:83
rqt_multiplot::MessageDefinitionLoader::threadStarted
void threadStarted()
Definition:
MessageDefinitionLoader.cpp:114
rqt_multiplot::MessageDefinitionLoader::loadingStarted
void loadingStarted()
rqt_multiplot::DataTypeRegistry::mutex_
static QMutex mutex_
Definition:
DataTypeRegistry.h:31
rqt_multiplot::MessageDefinitionLoader::isLoading
bool isLoading() const
Definition:
MessageDefinitionLoader.cpp:75
rqt_multiplot::MessageDefinitionLoader::threadFinished
void threadFinished()
Definition:
MessageDefinitionLoader.cpp:118
rqt_multiplot::MessageDefinitionLoader::impl_
Impl impl_
Definition:
MessageDefinitionLoader.h:65
DataTypeRegistry.h
rqt_multiplot::MessageDefinitionLoader::loadingFailed
void loadingFailed(const QString &error)
rqt_multiplot::MessageDefinitionLoader::Impl::mutex_
QMutex mutex_
Definition:
MessageDefinitionLoader.h:59
rqt_multiplot::MessageDefinitionLoader::Impl::type_
QString type_
Definition:
MessageDefinitionLoader.h:60
rqt_multiplot::MessageDefinitionLoader::Impl::~Impl
virtual ~Impl()
Definition:
MessageDefinitionLoader.cpp:47
rqt_multiplot::MessageDefinitionLoader::Impl::definition_
variant_topic_tools::MessageDefinition definition_
Definition:
MessageDefinitionLoader.h:61
rqt_multiplot::MessageDefinitionLoader::getType
QString getType() const
Definition:
MessageDefinitionLoader.cpp:56
rqt_multiplot::MessageDefinitionLoader::Impl::error_
QString error_
Definition:
MessageDefinitionLoader.h:62
rqt_multiplot
Definition:
BagQuery.h:33
rqt_multiplot::MessageDefinitionLoader::~MessageDefinitionLoader
~MessageDefinitionLoader()
Definition:
MessageDefinitionLoader.cpp:38
ros::Exception
MessageDefinitionLoader.h
rqt_multiplot::MessageDefinitionLoader::Impl::run
void run()
Definition:
MessageDefinitionLoader.cpp:94
rqt_multiplot::MessageDefinitionLoader::Impl::Impl
Impl(QObject *parent=0)
Definition:
MessageDefinitionLoader.cpp:43
rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44