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