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