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