00001 /****************************************************************************** 00002 * Copyright (C) 2015 by Ralf Kaestner * 00003 * ralf.kaestner@gmail.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the Lesser GNU General Public License as published by* 00007 * the Free Software Foundation; either version 3 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * Lesser GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the Lesser GNU General Public License * 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 00017 ******************************************************************************/ 00018 00019 #ifndef RQT_MULTIPLOT_MESSAGE_DEFINITION_LOADER_H 00020 #define RQT_MULTIPLOT_MESSAGE_DEFINITION_LOADER_H 00021 00022 #include <QMutex> 00023 #include <QObject> 00024 #include <QString> 00025 #include <QThread> 00026 00027 #include <variant_topic_tools/MessageDefinition.h> 00028 00029 namespace rqt_multiplot { 00030 class MessageDefinitionLoader : 00031 public QObject { 00032 Q_OBJECT 00033 public: 00034 MessageDefinitionLoader(QObject* parent = 0); 00035 ~MessageDefinitionLoader(); 00036 00037 QString getType() const; 00038 variant_topic_tools::MessageDefinition getDefinition() const; 00039 QString getError() const; 00040 bool isLoading() const; 00041 00042 void load(const QString& type); 00043 void wait(); 00044 00045 signals: 00046 void loadingStarted(); 00047 void loadingFinished(); 00048 void loadingFailed(const QString& error); 00049 00050 private: 00051 class Impl : 00052 public QThread { 00053 public: 00054 Impl(QObject* parent = 0); 00055 virtual ~Impl(); 00056 00057 void run(); 00058 00059 mutable QMutex mutex_; 00060 QString type_; 00061 variant_topic_tools::MessageDefinition definition_; 00062 QString error_; 00063 }; 00064 00065 Impl impl_; 00066 00067 private slots: 00068 void threadStarted(); 00069 void threadFinished(); 00070 }; 00071 }; 00072 00073 #endif