@@ -0,0 +1,31 | |||||
|
1 | #ifndef SCIQLOP_VARIABLECONTROLLER_H | |||
|
2 | #define SCIQLOP_VARIABLECONTROLLER_H | |||
|
3 | ||||
|
4 | #include <QLoggingCategory> | |||
|
5 | #include <QObject> | |||
|
6 | ||||
|
7 | #include <Common/spimpl.h> | |||
|
8 | ||||
|
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableController) | |||
|
10 | ||||
|
11 | /** | |||
|
12 | * @brief The VariableController class aims to handle the variables in SciQlop. | |||
|
13 | */ | |||
|
14 | class VariableController : public QObject { | |||
|
15 | Q_OBJECT | |||
|
16 | public: | |||
|
17 | explicit VariableController(QObject *parent = 0); | |||
|
18 | virtual ~VariableController(); | |||
|
19 | ||||
|
20 | public slots: | |||
|
21 | void initialize(); | |||
|
22 | void finalize(); | |||
|
23 | ||||
|
24 | private: | |||
|
25 | void waitForFinish(); | |||
|
26 | ||||
|
27 | class VariableControllerPrivate; | |||
|
28 | spimpl::unique_impl_ptr<VariableControllerPrivate> impl; | |||
|
29 | }; | |||
|
30 | ||||
|
31 | #endif // SCIQLOP_VARIABLECONTROLLER_H |
@@ -0,0 +1,46 | |||||
|
1 | #include <Variable/VariableController.h> | |||
|
2 | ||||
|
3 | #include <QMutex> | |||
|
4 | #include <QThread> | |||
|
5 | ||||
|
6 | Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController") | |||
|
7 | ||||
|
8 | struct VariableController::VariableControllerPrivate { | |||
|
9 | explicit VariableControllerPrivate() | |||
|
10 | : m_WorkingMutex{} | |||
|
11 | { | |||
|
12 | } | |||
|
13 | ||||
|
14 | QMutex m_WorkingMutex; | |||
|
15 | }; | |||
|
16 | ||||
|
17 | VariableController::VariableController(QObject *parent) | |||
|
18 | : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>()} | |||
|
19 | { | |||
|
20 | qCDebug(LOG_VariableController()) | |||
|
21 | << tr("VariableController construction") << QThread::currentThread(); | |||
|
22 | } | |||
|
23 | ||||
|
24 | VariableController::~VariableController() | |||
|
25 | { | |||
|
26 | qCDebug(LOG_VariableController()) | |||
|
27 | << tr("VariableController destruction") << QThread::currentThread(); | |||
|
28 | this->waitForFinish(); | |||
|
29 | } | |||
|
30 | ||||
|
31 | void VariableController::initialize() | |||
|
32 | { | |||
|
33 | qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread(); | |||
|
34 | impl->m_WorkingMutex.lock(); | |||
|
35 | qCDebug(LOG_VariableController()) << tr("VariableController init END"); | |||
|
36 | } | |||
|
37 | ||||
|
38 | void VariableController::finalize() | |||
|
39 | { | |||
|
40 | impl->m_WorkingMutex.unlock(); | |||
|
41 | } | |||
|
42 | ||||
|
43 | void VariableController::waitForFinish() | |||
|
44 | { | |||
|
45 | QMutexLocker locker{&impl->m_WorkingMutex}; | |||
|
46 | } |
@@ -1,46 +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 VisualizationController; |
|
20 | class VisualizationController; | |
20 |
|
21 | |||
21 | /** |
|
22 | /** | |
22 | * @brief The SqpApplication class aims to make the link between SciQlop |
|
23 | * @brief The SqpApplication class aims to make the link between SciQlop | |
23 | * 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 | |
24 | * 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 | |
25 | * 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 | |
26 | * method will be able to access it. |
|
27 | * method will be able to access it. | |
27 | * 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. | |
28 | */ |
|
29 | */ | |
29 |
|
30 | |||
30 | class SqpApplication : public QApplication { |
|
31 | class SqpApplication : public QApplication { | |
31 | Q_OBJECT |
|
32 | Q_OBJECT | |
32 | public: |
|
33 | public: | |
33 | explicit SqpApplication(int &argc, char **argv); |
|
34 | explicit SqpApplication(int &argc, char **argv); | |
34 | virtual ~SqpApplication(); |
|
35 | virtual ~SqpApplication(); | |
35 | void initialize(); |
|
36 | void initialize(); | |
36 |
|
37 | |||
37 | /// Accessors for the differents sciqlop controllers |
|
38 | /// Accessors for the differents sciqlop controllers | |
38 | DataSourceController &dataSourceController() const noexcept; |
|
39 | DataSourceController &dataSourceController() const noexcept; | |
|
40 | VariableController &variableController() const noexcept; | |||
39 | VisualizationController &visualizationController() const noexcept; |
|
41 | VisualizationController &visualizationController() const noexcept; | |
40 |
|
42 | |||
41 | private: |
|
43 | private: | |
42 | class SqpApplicationPrivate; |
|
44 | class SqpApplicationPrivate; | |
43 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; |
|
45 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; | |
44 | }; |
|
46 | }; | |
45 |
|
47 | |||
46 | #endif // SCIQLOP_SQPAPPLICATION_H |
|
48 | #endif // SCIQLOP_SQPAPPLICATION_H |
@@ -1,72 +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 <Visualization/VisualizationController.h> |
|
6 | #include <Visualization/VisualizationController.h> | |
6 |
|
7 | |||
7 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
8 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | |
8 |
|
9 | |||
9 | class SqpApplication::SqpApplicationPrivate { |
|
10 | class SqpApplication::SqpApplicationPrivate { | |
10 | public: |
|
11 | public: | |
11 | SqpApplicationPrivate() |
|
12 | SqpApplicationPrivate() | |
12 | : m_DataSourceController{std::make_unique<DataSourceController>()}, |
|
13 | : m_DataSourceController{std::make_unique<DataSourceController>()}, | |
|
14 | m_VariableController{std::make_unique<VariableController>()}, | |||
13 | m_VisualizationController{std::make_unique<VisualizationController>()} |
|
15 | m_VisualizationController{std::make_unique<VisualizationController>()} | |
14 | { |
|
16 | { | |
15 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); |
|
17 | m_DataSourceController->moveToThread(&m_DataSourceControllerThread); | |
|
18 | m_VariableController->moveToThread(&m_VariableControllerThread); | |||
16 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); |
|
19 | m_VisualizationController->moveToThread(&m_VisualizationControllerThread); | |
17 | } |
|
20 | } | |
18 |
|
21 | |||
19 | virtual ~SqpApplicationPrivate() |
|
22 | virtual ~SqpApplicationPrivate() | |
20 | { |
|
23 | { | |
21 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); |
|
24 | qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction"); | |
22 | m_DataSourceControllerThread.quit(); |
|
25 | m_DataSourceControllerThread.quit(); | |
23 | m_DataSourceControllerThread.wait(); |
|
26 | m_DataSourceControllerThread.wait(); | |
24 |
|
27 | |||
|
28 | m_VariableControllerThread.quit(); | |||
|
29 | m_VariableControllerThread.wait(); | |||
|
30 | ||||
25 | m_VisualizationControllerThread.quit(); |
|
31 | m_VisualizationControllerThread.quit(); | |
26 | m_VisualizationControllerThread.wait(); |
|
32 | m_VisualizationControllerThread.wait(); | |
27 | } |
|
33 | } | |
28 |
|
34 | |||
29 | std::unique_ptr<DataSourceController> m_DataSourceController; |
|
35 | std::unique_ptr<DataSourceController> m_DataSourceController; | |
|
36 | std::unique_ptr<VariableController> m_VariableController; | |||
30 | std::unique_ptr<VisualizationController> m_VisualizationController; |
|
37 | std::unique_ptr<VisualizationController> m_VisualizationController; | |
31 | QThread m_DataSourceControllerThread; |
|
38 | QThread m_DataSourceControllerThread; | |
|
39 | QThread m_VariableControllerThread; | |||
32 | QThread m_VisualizationControllerThread; |
|
40 | QThread m_VisualizationControllerThread; | |
33 | }; |
|
41 | }; | |
34 |
|
42 | |||
35 |
|
43 | |||
36 | SqpApplication::SqpApplication(int &argc, char **argv) |
|
44 | SqpApplication::SqpApplication(int &argc, char **argv) | |
37 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} |
|
45 | : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()} | |
38 | { |
|
46 | { | |
39 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); |
|
47 | qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction"); | |
40 |
|
48 | |||
41 | connect(&impl->m_DataSourceControllerThread, &QThread::started, |
|
49 | connect(&impl->m_DataSourceControllerThread, &QThread::started, | |
42 | impl->m_DataSourceController.get(), &DataSourceController::initialize); |
|
50 | impl->m_DataSourceController.get(), &DataSourceController::initialize); | |
43 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, |
|
51 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, | |
44 | impl->m_DataSourceController.get(), &DataSourceController::finalize); |
|
52 | impl->m_DataSourceController.get(), &DataSourceController::finalize); | |
45 |
|
53 | |||
|
54 | connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(), | |||
|
55 | &VariableController::initialize); | |||
|
56 | connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(), | |||
|
57 | &VariableController::finalize); | |||
|
58 | ||||
46 | connect(&impl->m_VisualizationControllerThread, &QThread::started, |
|
59 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |
47 | impl->m_VisualizationController.get(), &VisualizationController::initialize); |
|
60 | impl->m_VisualizationController.get(), &VisualizationController::initialize); | |
48 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, |
|
61 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |
49 | impl->m_VisualizationController.get(), &VisualizationController::finalize); |
|
62 | impl->m_VisualizationController.get(), &VisualizationController::finalize); | |
50 |
|
63 | |||
51 |
|
64 | |||
52 | impl->m_DataSourceControllerThread.start(); |
|
65 | impl->m_DataSourceControllerThread.start(); | |
|
66 | impl->m_VariableControllerThread.start(); | |||
53 | impl->m_VisualizationControllerThread.start(); |
|
67 | impl->m_VisualizationControllerThread.start(); | |
54 | } |
|
68 | } | |
55 |
|
69 | |||
56 | SqpApplication::~SqpApplication() |
|
70 | SqpApplication::~SqpApplication() | |
57 | { |
|
71 | { | |
58 | } |
|
72 | } | |
59 |
|
73 | |||
60 | void SqpApplication::initialize() |
|
74 | void SqpApplication::initialize() | |
61 | { |
|
75 | { | |
62 | } |
|
76 | } | |
63 |
|
77 | |||
64 | DataSourceController &SqpApplication::dataSourceController() const noexcept |
|
78 | DataSourceController &SqpApplication::dataSourceController() const noexcept | |
65 | { |
|
79 | { | |
66 | return *impl->m_DataSourceController; |
|
80 | return *impl->m_DataSourceController; | |
67 | } |
|
81 | } | |
68 |
|
82 | |||
|
83 | VariableController &SqpApplication::variableController() const noexcept | |||
|
84 | { | |||
|
85 | return *impl->m_VariableController; | |||
|
86 | } | |||
|
87 | ||||
69 | VisualizationController &SqpApplication::visualizationController() const noexcept |
|
88 | VisualizationController &SqpApplication::visualizationController() const noexcept | |
70 | { |
|
89 | { | |
71 | return *impl->m_VisualizationController; |
|
90 | return *impl->m_VisualizationController; | |
72 | } |
|
91 | } |
General Comments 0
You need to be logged in to leave comments.
Login now