@@ -1,48 +1,48 | |||||
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 | #if defined(sqpApp) |
|
13 | #if defined(sqpApp) | |
14 | #undef sqpApp |
|
14 | #undef sqpApp | |
15 | #endif |
|
15 | #endif | |
16 | #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance())) |
|
16 | #define sqpApp (static_cast<SqpApplication *>(QCoreApplication::instance())) | |
17 |
|
17 | |||
18 | class DataSourceController; |
|
18 | class DataSourceController; | |
19 | class VariableController; |
|
19 | class VariableController; | |
20 | class VisualizationController; |
|
20 | class VisualizationController; | |
21 |
|
21 | |||
22 | /** |
|
22 | /** | |
23 | * @brief The SqpApplication class aims to make the link between SciQlop |
|
23 | * @brief The SqpApplication class aims to make the link between SciQlop | |
24 | * and its plugins. This is the intermediate class that SciQlop has to use |
|
24 | * and its plugins. This is the intermediate class that SciQlop has to use | |
25 | * in the way to connect a data source. Please first use load method to initialize |
|
25 | * in the way to connect a data source. Please first use load method to initialize | |
26 | * a plugin specified by its metadata name (JSON plugin source) then others specifics |
|
26 | * a plugin specified by its metadata name (JSON plugin source) then others specifics | |
27 | * method will be able to access it. |
|
27 | * method will be able to access it. | |
28 | * You can load a data source driver plugin then create a data source. |
|
28 | * You can load a data source driver plugin then create a data source. | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | class SqpApplication : public QApplication { |
|
31 | class SqpApplication : public QApplication { | |
32 | Q_OBJECT |
|
32 | Q_OBJECT | |
33 | public: |
|
33 | public: | |
34 | explicit SqpApplication(int &argc, char **argv); |
|
34 | explicit SqpApplication(int &argc, char **argv); | |
35 | virtual ~SqpApplication(); |
|
35 | virtual ~SqpApplication(); | |
36 | void initialize(); |
|
36 | void initialize(); | |
37 |
|
37 | |||
38 | /// Accessors for the differents sciqlop controllers |
|
38 | /// Accessors for the differents sciqlop controllers | |
39 |
DataSourceController &dataSourceController() |
|
39 | DataSourceController &dataSourceController() noexcept; | |
40 |
VariableController &variableController() |
|
40 | VariableController &variableController() noexcept; | |
41 |
VisualizationController &visualizationController() |
|
41 | VisualizationController &visualizationController() noexcept; | |
42 |
|
42 | |||
43 | private: |
|
43 | private: | |
44 | class SqpApplicationPrivate; |
|
44 | class SqpApplicationPrivate; | |
45 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; |
|
45 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; | |
46 | }; |
|
46 | }; | |
47 |
|
47 | |||
48 | #endif // SCIQLOP_SQPAPPLICATION_H |
|
48 | #endif // SCIQLOP_SQPAPPLICATION_H |
@@ -1,91 +1,91 | |||||
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 | #include <Variable/VariableController.h> |
|
5 | #include <Variable/VariableController.h> | |
6 | #include <Visualization/VisualizationController.h> |
|
6 | #include <Visualization/VisualizationController.h> | |
7 |
|
7 | |||
8 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
8 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | |
9 |
|
9 | |||
10 | class SqpApplication::SqpApplicationPrivate { |
|
10 | class SqpApplication::SqpApplicationPrivate { | |
11 | public: |
|
11 | public: | |
12 | SqpApplicationPrivate() |
|
12 | SqpApplicationPrivate() | |
13 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
13 | : m_DataSourceController{std::make_unique<DataSourceController>()}, | |
14 | m_VariableController{std::make_unique<VariableController>()}, |
|
14 | m_VariableController{std::make_unique<VariableController>()}, | |
15 | m_VisualizationController{std::make_unique<VisualizationController>()} |
|
15 | m_VisualizationController{std::make_unique<VisualizationController>()} | |
16 | { |
|
16 | { | |
17 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
17 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | |
18 | m_VariableController->moveToThread(&m_VariableControllerThread); |
|
18 | m_VariableController->moveToThread(&m_VariableControllerThread); | |
19 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
19 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | virtual ~SqpApplicationPrivate() |
|
22 | virtual ~SqpApplicationPrivate() | |
23 | { |
|
23 | { | |
24 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); |
|
24 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); | |
25 | m_DataSourceControllerThread.quit(); |
|
25 | m_DataSourceControllerThread.quit(); | |
26 | m_DataSourceControllerThread.wait(); |
|
26 | m_DataSourceControllerThread.wait(); | |
27 |
|
27 | |||
28 | m_VariableControllerThread.quit(); |
|
28 | m_VariableControllerThread.quit(); | |
29 | m_VariableControllerThread.wait(); |
|
29 | m_VariableControllerThread.wait(); | |
30 |
|
30 | |||
31 | m_VisualizationControllerThread.quit(); |
|
31 | m_VisualizationControllerThread.quit(); | |
32 | m_VisualizationControllerThread.wait(); |
|
32 | m_VisualizationControllerThread.wait(); | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
35 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
36 | std::unique_ptr<VariableController> m_VariableController; |
|
36 | std::unique_ptr<VariableController> m_VariableController; | |
37 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
37 | std::unique_ptr<VisualizationController> m_VisualizationController; | |
38 | QThread m_DataSourceControllerThread; |
|
38 | QThread m_DataSourceControllerThread; | |
39 | QThread m_VariableControllerThread; |
|
39 | QThread m_VariableControllerThread; | |
40 | QThread m_VisualizationControllerThread; |
|
40 | QThread m_VisualizationControllerThread; | |
41 | }; |
|
41 | }; | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | SqpApplication::SqpApplication(int &argc, char **argv) |
|
44 | SqpApplication::SqpApplication(int &argc, char **argv) | |
45 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} |
|
45 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | |
46 | { |
|
46 | { | |
47 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); |
|
47 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); | |
48 |
|
48 | |||
49 | connect(&impl->m_DataSourceControllerThread, &QThread::started, |
|
49 | connect(&impl->m_DataSourceControllerThread, &QThread::started, | |
50 | impl->m_DataSourceController.get(), &DataSourceController::initialize); |
|
50 | impl->m_DataSourceController.get(), &DataSourceController::initialize); | |
51 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
51 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, | |
52 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
52 | impl->m_DataSourceController.get(), &DataSourceController::finalize); | |
53 |
|
53 | |||
54 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), |
|
54 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | |
55 | &VariableController::initialize); |
|
55 | &VariableController::initialize); | |
56 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), |
|
56 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | |
57 | &VariableController::finalize); |
|
57 | &VariableController::finalize); | |
58 |
|
58 | |||
59 | connect(&impl->m_VisualizationControllerThread, &QThread::started, |
|
59 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |
60 | impl->m_VisualizationController.get(), &VisualizationController::initialize); |
|
60 | impl->m_VisualizationController.get(), &VisualizationController::initialize); | |
61 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, |
|
61 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |
62 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
62 | impl->m_VisualizationController.get(), &VisualizationController::finalize); | |
63 |
|
63 | |||
64 |
|
64 | |||
65 | impl->m_DataSourceControllerThread.start(); |
|
65 | impl->m_DataSourceControllerThread.start(); | |
66 | impl->m_VariableControllerThread.start(); |
|
66 | impl->m_VariableControllerThread.start(); | |
67 | impl->m_VisualizationControllerThread.start(); |
|
67 | impl->m_VisualizationControllerThread.start(); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | SqpApplication::~SqpApplication() |
|
70 | SqpApplication::~SqpApplication() | |
71 | { |
|
71 | { | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | void SqpApplication::initialize() |
|
74 | void SqpApplication::initialize() | |
75 | { |
|
75 | { | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 |
DataSourceController &SqpApplication::dataSourceController() |
|
78 | DataSourceController &SqpApplication::dataSourceController() noexcept | |
79 | { |
|
79 | { | |
80 | return *impl->m_DataSourceController; |
|
80 | return *impl->m_DataSourceController; | |
81 | } |
|
81 | } | |
82 |
|
82 | |||
83 |
VariableController &SqpApplication::variableController() |
|
83 | VariableController &SqpApplication::variableController() noexcept | |
84 | { |
|
84 | { | |
85 | return *impl->m_VariableController; |
|
85 | return *impl->m_VariableController; | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 |
VisualizationController &SqpApplication::visualizationController() |
|
88 | VisualizationController &SqpApplication::visualizationController() noexcept | |
89 | { |
|
89 | { | |
90 | return *impl->m_VisualizationController; |
|
90 | return *impl->m_VisualizationController; | |
91 | } |
|
91 | } |
General Comments 0
You need to be logged in to leave comments.
Login now