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