##// END OF EJS Templates
Add access to DataSourceController from SqpApplication
Alexandre Leroux -
r33:2b201d277e22
parent child
Show More
@@ -1,34 +1,38
1 1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 2 #define SCIQLOP_SQPAPPLICATION_H
3 3
4 4 #include "SqpApplication.h"
5 5
6 6 #include <QApplication>
7 7 #include <QLoggingCategory>
8 8
9 9 #include <Common/spimpl.h>
10 10
11 11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12 12
13 class DataSourceController;
14
13 15 /**
14 16 * @brief The SqpApplication class aims to make the link between SciQlop
15 17 * and its plugins. This is the intermediate class that SciQlop has to use
16 18 * in the way to connect a data source. Please first use load method to initialize
17 19 * a plugin specified by its metadata name (JSON plugin source) then others specifics
18 20 * method will be able to access it.
19 21 * You can load a data source driver plugin then create a data source.
20 22 */
21 23
22 24 class SqpApplication : public QApplication {
23 25 Q_OBJECT
24 26 public:
25 27 explicit SqpApplication(int &argc, char **argv);
26 28 virtual ~SqpApplication();
27 29 void initialize();
28 30
31 DataSourceController &dataSourceController() const noexcept;
32
29 33 private:
30 34 class SqpApplicationPrivate;
31 35 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
32 36 };
33 37
34 38 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,46 +1,51
1 1 #include "SqpApplication.h"
2 2
3 3 #include <DataSource/DataSourceController.h>
4 4 #include <QThread>
5 5
6 6 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
7 7
8 8 class SqpApplication::SqpApplicationPrivate {
9 9 public:
10 10 SqpApplicationPrivate() : m_DataSourceController{std::make_unique<DataSourceController>()}
11 11 {
12 12 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
13 13 }
14 14
15 15 virtual ~SqpApplicationPrivate()
16 16 {
17 17 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
18 18 m_DataSourceControllerThread.quit();
19 19 m_DataSourceControllerThread.wait();
20 20 }
21 21
22 22 std::unique_ptr<DataSourceController> m_DataSourceController;
23 23 QThread m_DataSourceControllerThread;
24 24 };
25 25
26 26
27 27 SqpApplication::SqpApplication(int &argc, char **argv)
28 28 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
29 29 {
30 30 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
31 31
32 32 connect(&impl->m_DataSourceControllerThread, &QThread::started,
33 33 impl->m_DataSourceController.get(), &DataSourceController::initialize);
34 34 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
35 35 impl->m_DataSourceController.get(), &DataSourceController::finalize);
36 36
37 37 impl->m_DataSourceControllerThread.start();
38 38 }
39 39
40 40 SqpApplication::~SqpApplication()
41 41 {
42 42 }
43 43
44 44 void SqpApplication::initialize()
45 45 {
46 46 }
47
48 DataSourceController &SqpApplication::dataSourceController() const noexcept
49 {
50 return *impl->m_DataSourceController;
51 }
General Comments 0
You need to be logged in to leave comments. Login now