##// END OF EJS Templates
correction of merge
perrinel -
r1097:5b22e1d6dd6f
parent child
Show More
@@ -0,0 +1,51
1 #ifndef SCIQLOP_CATALOGUECONTROLLER_H
2 #define SCIQLOP_CATALOGUECONTROLLER_H
3
4 #include "CoreGlobal.h"
5
6 #include <Data/SqpRange.h>
7
8 #include <QLoggingCategory>
9 #include <QObject>
10 #include <QUuid>
11
12 #include <Common/spimpl.h>
13
14 Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueController)
15
16 class DataSourceItem;
17 class Variable;
18
19 /**
20 * @brief The CatalogueController class aims to make the link between SciQlop and its plugins.
21 * This is the intermediate class that SciQlop has to use in the way to connect a data source.
22 * Please first use register method to initialize a plugin specified by its metadata name (JSON
note

I don't think the catalogue has any connection with the plugins.

23 * plugin source) then others specifics method will be able to access it. You can load a data source
24 * driver plugin then create a data source.
25 */
26 class SCIQLOP_CORE_EXPORT CatalogueController : public QObject {
27 Q_OBJECT
28 public:
29 explicit CatalogueController(QObject *parent = 0);
30 virtual ~CatalogueController();
31
32 signals:
33 /// Signal emitted when a variable is about to be deleted from SciQlop
34 void variableAboutToBeDeleted(std::shared_ptr<Variable> variable);
35
36 /// Signal emitted when a data acquisition is requested on a range for a variable
37 void rangeChanged(std::shared_ptr<Variable> variable, const SqpRange &range);
38
39 public slots:
40 /// Manage init/end of the controller
41 void initialize();
42 void finalize();
43
44 private:
45 void waitForFinish();
46
47 class CatalogueControllerPrivate;
48 spimpl::unique_impl_ptr<CatalogueControllerPrivate> impl;
49 };
50
51 #endif // SCIQLOP_CATALOGUECONTROLLER_H
@@ -0,0 +1,52
1 #include <Catalogue/CatalogueController.h>
2
3 #include <Variable/Variable.h>
4
5 #include <CatalogueDao.h>
6
7 #include <QMutex>
8 #include <QThread>
9
10 #include <QDir>
11 #include <QStandardPaths>
12
13 Q_LOGGING_CATEGORY(LOG_CatalogueController, "CatalogueController")
14
15 class CatalogueController::CatalogueControllerPrivate {
16 public:
17 QMutex m_WorkingMutex;
18 CatalogueDao m_CatalogueDao;
19 };
20
21 CatalogueController::CatalogueController(QObject *parent)
22 : impl{spimpl::make_unique_impl<CatalogueControllerPrivate>()}
23 {
24 qCDebug(LOG_CatalogueController()) << tr("CatalogueController construction")
25 << QThread::currentThread();
26 }
27
28 CatalogueController::~CatalogueController()
29 {
30 qCDebug(LOG_CatalogueController()) << tr("CatalogueController destruction")
31 << QThread::currentThread();
32 this->waitForFinish();
33 }
34
35 void CatalogueController::initialize()
36 {
37 qCDebug(LOG_CatalogueController()) << tr("CatalogueController init")
38 << QThread::currentThread();
39 impl->m_WorkingMutex.lock();
40 impl->m_CatalogueDao.initialize();
41 qCDebug(LOG_CatalogueController()) << tr("CatalogueController init END");
42 }
43
44 void CatalogueController::finalize()
45 {
46 impl->m_WorkingMutex.unlock();
47 }
48
49 void CatalogueController::waitForFinish()
50 {
51 QMutexLocker locker{&impl->m_WorkingMutex};
52 }
@@ -1,188 +1,203
1 #include "SqpApplication.h"
1 #include "SqpApplication.h"
2
2
3 #include <Catalogue/CatalogueController.h>
3 #include <Data/IDataProvider.h>
4 #include <Data/IDataProvider.h>
4 #include <DataSource/DataSourceController.h>
5 #include <DataSource/DataSourceController.h>
5 #include <DragAndDrop/DragDropHelper.h>
6 #include <DragAndDrop/DragDropHelper.h>
6 #include <Network/NetworkController.h>
7 #include <Network/NetworkController.h>
7 #include <QThread>
8 #include <QThread>
8 #include <Time/TimeController.h>
9 #include <Time/TimeController.h>
9 #include <Variable/Variable.h>
10 #include <Variable/Variable.h>
10 #include <Variable/VariableController.h>
11 #include <Variable/VariableController.h>
11 #include <Variable/VariableModel.h>
12 #include <Variable/VariableModel.h>
12 #include <Visualization/VisualizationController.h>
13 #include <Visualization/VisualizationController.h>
13
14
14 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
15 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
15
16
16 class SqpApplication::SqpApplicationPrivate {
17 class SqpApplication::SqpApplicationPrivate {
17 public:
18 public:
18 SqpApplicationPrivate()
19 SqpApplicationPrivate()
19 : m_DataSourceController{std::make_unique<DataSourceController>()},
20 : m_DataSourceController{std::make_unique<DataSourceController>()},
20 m_VariableController{std::make_unique<VariableController>()},
21 m_VariableController{std::make_unique<VariableController>()},
21 m_TimeController{std::make_unique<TimeController>()},
22 m_TimeController{std::make_unique<TimeController>()},
22 m_NetworkController{std::make_unique<NetworkController>()},
23 m_NetworkController{std::make_unique<NetworkController>()},
23 m_VisualizationController{std::make_unique<VisualizationController>()},
24 m_VisualizationController{std::make_unique<VisualizationController>()},
24 m_DragDropHelper{std::make_unique<DragDropHelper>()},
25 m_DragDropHelper{std::make_unique<DragDropHelper>()},
26 m_CatalogueController{std::make_unique<CatalogueController>()},
25 m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None),
27 m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None),
26 m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor)
28 m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor)
27 {
29 {
28 // /////////////////////////////// //
30 // /////////////////////////////// //
29 // Connections between controllers //
31 // Connections between controllers //
30 // /////////////////////////////// //
32 // /////////////////////////////// //
31
33
32 // VariableController <-> DataSourceController
34 // VariableController <-> DataSourceController
33 connect(m_DataSourceController.get(),
35 connect(m_DataSourceController.get(),
34 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
36 SIGNAL(variableCreationRequested(const QString &, const QVariantHash &,
35 std::shared_ptr<IDataProvider>)),
37 std::shared_ptr<IDataProvider>)),
36 m_VariableController.get(),
38 m_VariableController.get(),
37 SLOT(createVariable(const QString &, const QVariantHash &,
39 SLOT(createVariable(const QString &, const QVariantHash &,
38 std::shared_ptr<IDataProvider>)));
40 std::shared_ptr<IDataProvider>)));
39
41
40 connect(m_VariableController->variableModel(), &VariableModel::requestVariable,
42 connect(m_VariableController->variableModel(), &VariableModel::requestVariable,
41 m_DataSourceController.get(), &DataSourceController::requestVariable);
43 m_DataSourceController.get(), &DataSourceController::requestVariable);
42
44
43 // VariableController <-> VisualizationController
45 // VariableController <-> VisualizationController
44 connect(m_VariableController.get(),
46 connect(m_VariableController.get(),
45 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
47 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
46 m_VisualizationController.get(),
48 m_VisualizationController.get(),
47 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
49 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
48
50
49 connect(m_VariableController.get(),
51 connect(m_VariableController.get(),
50 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)),
52 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)),
51 m_VisualizationController.get(),
53 m_VisualizationController.get(),
52 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
54 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpRange &)));
53
55
54
56
55 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
57 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
56 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
58 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
57 m_NetworkController->moveToThread(&m_NetworkControllerThread);
59 m_NetworkController->moveToThread(&m_NetworkControllerThread);
58 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
60 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
59 m_VariableController->moveToThread(&m_VariableControllerThread);
61 m_VariableController->moveToThread(&m_VariableControllerThread);
60 m_VariableControllerThread.setObjectName("VariableControllerThread");
62 m_VariableControllerThread.setObjectName("VariableControllerThread");
61 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
63 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
62 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
64 m_VisualizationControllerThread.setObjectName("VsualizationControllerThread");
65 m_CatalogueController->moveToThread(&m_CatalogueControllerThread);
66 m_CatalogueControllerThread.setObjectName("CatalogueControllerThread");
63
67
64
68
65 // Additionnal init
69 // Additionnal init
66 m_VariableController->setTimeController(m_TimeController.get());
70 m_VariableController->setTimeController(m_TimeController.get());
67 }
71 }
68
72
69 virtual ~SqpApplicationPrivate()
73 virtual ~SqpApplicationPrivate()
70 {
74 {
71 m_DataSourceControllerThread.quit();
75 m_DataSourceControllerThread.quit();
72 m_DataSourceControllerThread.wait();
76 m_DataSourceControllerThread.wait();
73
77
74 m_NetworkControllerThread.quit();
78 m_NetworkControllerThread.quit();
75 m_NetworkControllerThread.wait();
79 m_NetworkControllerThread.wait();
76
80
77 m_VariableControllerThread.quit();
81 m_VariableControllerThread.quit();
78 m_VariableControllerThread.wait();
82 m_VariableControllerThread.wait();
79
83
80 m_VisualizationControllerThread.quit();
84 m_VisualizationControllerThread.quit();
81 m_VisualizationControllerThread.wait();
85 m_VisualizationControllerThread.wait();
86
87 m_CatalogueControllerThread.quit();
88 m_CatalogueControllerThread.wait();
82 }
89 }
83
90
84 std::unique_ptr<DataSourceController> m_DataSourceController;
91 std::unique_ptr<DataSourceController> m_DataSourceController;
85 std::unique_ptr<VariableController> m_VariableController;
92 std::unique_ptr<VariableController> m_VariableController;
86 std::unique_ptr<TimeController> m_TimeController;
93 std::unique_ptr<TimeController> m_TimeController;
87 std::unique_ptr<NetworkController> m_NetworkController;
94 std::unique_ptr<NetworkController> m_NetworkController;
88 std::unique_ptr<VisualizationController> m_VisualizationController;
95 std::unique_ptr<VisualizationController> m_VisualizationController;
96 std::unique_ptr<CatalogueController> m_CatalogueController;
89 QThread m_DataSourceControllerThread;
97 QThread m_DataSourceControllerThread;
90 QThread m_NetworkControllerThread;
98 QThread m_NetworkControllerThread;
91 QThread m_VariableControllerThread;
99 QThread m_VariableControllerThread;
92 QThread m_VisualizationControllerThread;
100 QThread m_VisualizationControllerThread;
101 QThread m_CatalogueControllerThread;
93
102
94 std::unique_ptr<DragDropHelper> m_DragDropHelper;
103 std::unique_ptr<DragDropHelper> m_DragDropHelper;
95
104
96 SqpApplication::PlotsInteractionMode m_PlotInterractionMode;
105 SqpApplication::PlotsInteractionMode m_PlotInterractionMode;
97 SqpApplication::PlotsCursorMode m_PlotCursorMode;
106 SqpApplication::PlotsCursorMode m_PlotCursorMode;
98 };
107 };
99
108
100
109
101 SqpApplication::SqpApplication(int &argc, char **argv)
110 SqpApplication::SqpApplication(int &argc, char **argv)
102 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
111 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
103 {
112 {
104 qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread();
113 qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread();
105
114
106 connect(&impl->m_DataSourceControllerThread, &QThread::started,
115 connect(&impl->m_DataSourceControllerThread, &QThread::started,
107 impl->m_DataSourceController.get(), &DataSourceController::initialize);
116 impl->m_DataSourceController.get(), &DataSourceController::initialize);
108 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
117 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
109 impl->m_DataSourceController.get(), &DataSourceController::finalize);
118 impl->m_DataSourceController.get(), &DataSourceController::finalize);
110
119
111 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
120 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
112 &NetworkController::initialize);
121 &NetworkController::initialize);
113 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
122 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
114 &NetworkController::finalize);
123 &NetworkController::finalize);
115
124
116 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
125 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
117 &VariableController::initialize);
126 &VariableController::initialize);
118 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
127 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
119 &VariableController::finalize);
128 &VariableController::finalize);
120
129
121 connect(&impl->m_VisualizationControllerThread, &QThread::started,
130 connect(&impl->m_VisualizationControllerThread, &QThread::started,
122 impl->m_VisualizationController.get(), &VisualizationController::initialize);
131 impl->m_VisualizationController.get(), &VisualizationController::initialize);
123 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
132 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
124 impl->m_VisualizationController.get(), &VisualizationController::finalize);
133 impl->m_VisualizationController.get(), &VisualizationController::finalize);
125
134
135 connect(&impl->m_CatalogueControllerThread, &QThread::started,
136 impl->m_CatalogueController.get(), &CatalogueController::initialize);
137 connect(&impl->m_CatalogueControllerThread, &QThread::finished,
138 impl->m_CatalogueController.get(), &CatalogueController::finalize);
139
126 impl->m_DataSourceControllerThread.start();
140 impl->m_DataSourceControllerThread.start();
127 impl->m_NetworkControllerThread.start();
141 impl->m_NetworkControllerThread.start();
128 impl->m_VariableControllerThread.start();
142 impl->m_VariableControllerThread.start();
129 impl->m_VisualizationControllerThread.start();
143 impl->m_VisualizationControllerThread.start();
144 impl->m_CatalogueControllerThread.start();
130 }
145 }
131
146
132 SqpApplication::~SqpApplication()
147 SqpApplication::~SqpApplication()
133 {
148 {
134 }
149 }
135
150
136 void SqpApplication::initialize()
151 void SqpApplication::initialize()
137 {
152 {
138 }
153 }
139
154
140 DataSourceController &SqpApplication::dataSourceController() noexcept
155 DataSourceController &SqpApplication::dataSourceController() noexcept
141 {
156 {
142 return *impl->m_DataSourceController;
157 return *impl->m_DataSourceController;
143 }
158 }
144
159
145 NetworkController &SqpApplication::networkController() noexcept
160 NetworkController &SqpApplication::networkController() noexcept
146 {
161 {
147 return *impl->m_NetworkController;
162 return *impl->m_NetworkController;
148 }
163 }
149
164
150 TimeController &SqpApplication::timeController() noexcept
165 TimeController &SqpApplication::timeController() noexcept
151 {
166 {
152 return *impl->m_TimeController;
167 return *impl->m_TimeController;
153 }
168 }
154
169
155 VariableController &SqpApplication::variableController() noexcept
170 VariableController &SqpApplication::variableController() noexcept
156 {
171 {
157 return *impl->m_VariableController;
172 return *impl->m_VariableController;
158 }
173 }
159
174
160 VisualizationController &SqpApplication::visualizationController() noexcept
175 VisualizationController &SqpApplication::visualizationController() noexcept
161 {
176 {
162 return *impl->m_VisualizationController;
177 return *impl->m_VisualizationController;
163 }
178 }
164
179
165 DragDropHelper &SqpApplication::dragDropHelper() noexcept
180 DragDropHelper &SqpApplication::dragDropHelper() noexcept
166 {
181 {
167 return *impl->m_DragDropHelper;
182 return *impl->m_DragDropHelper;
168 }
183 }
169
184
170 SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const
185 SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const
171 {
186 {
172 return impl->m_PlotInterractionMode;
187 return impl->m_PlotInterractionMode;
173 }
188 }
174
189
175 void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode)
190 void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode)
176 {
191 {
177 impl->m_PlotInterractionMode = mode;
192 impl->m_PlotInterractionMode = mode;
178 }
193 }
179
194
180 SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const
195 SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const
181 {
196 {
182 return impl->m_PlotCursorMode;
197 return impl->m_PlotCursorMode;
183 }
198 }
184
199
185 void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode)
200 void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode)
186 {
201 {
187 impl->m_PlotCursorMode = mode;
202 impl->m_PlotCursorMode = mode;
188 }
203 }
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

You need to be logged in to leave comments. Login now