##// END OF EJS Templates
@@ -0,0 +1,30
1 #ifndef SCIQLOP_NETWORKCONTROLLER_H
2 #define SCIQLOP_NETWORKCONTROLLER_H
3
4 #include <QLoggingCategory>
5 #include <QObject>
6
7 #include <Common/spimpl.h>
8
9 Q_DECLARE_LOGGING_CATEGORY(LOG_NetworkController)
10
11 /**
12 * @brief The NetworkController class aims to handle all network connection of SciQlop.
13 */
14 class NetworkController : public QObject {
15 Q_OBJECT
16 public:
17 explicit NetworkController(QObject *parent = 0);
18
19
20 void initialize();
21 void finalize();
22
23 private:
24 void waitForFinish();
25
26 class NetworkControllerPrivate;
27 spimpl::unique_impl_ptr<NetworkControllerPrivate> impl;
28 };
29
30 #endif // SCIQLOP_NETWORKCONTROLLER_H
@@ -0,0 +1,33
1 #include "Network/NetworkController.h"
2
3 #include <QMutex>
4 #include <QThread>
5
6 Q_LOGGING_CATEGORY(LOG_NetworkController, "NetworkController")
7
8 struct NetworkController::NetworkControllerPrivate {
9 explicit NetworkControllerPrivate(NetworkController *parent) : m_WorkingMutex{} {}
10 QMutex m_WorkingMutex;
11 };
12
13 NetworkController::NetworkController(QObject *parent)
14 : QObject(parent), impl{spimpl::make_unique_impl<NetworkControllerPrivate>(this)}
15 {
16 }
17
18 void NetworkController::initialize()
19 {
20 qCDebug(LOG_NetworkController()) << tr("NetworkController init") << QThread::currentThread();
21 impl->m_WorkingMutex.lock();
22 qCDebug(LOG_NetworkController()) << tr("NetworkController init END");
23 }
24
25 void NetworkController::finalize()
26 {
27 impl->m_WorkingMutex.unlock();
28 }
29
30 void NetworkController::waitForFinish()
31 {
32 QMutexLocker locker{&impl->m_WorkingMutex};
33 }
@@ -1,42 +1,38
1 #ifndef SCIQLOP_IDATAPROVIDER_H
1 #ifndef SCIQLOP_IDATAPROVIDER_H
2 #define SCIQLOP_IDATAPROVIDER_H
2 #define SCIQLOP_IDATAPROVIDER_H
3
3
4 #include <memory>
4 #include <memory>
5
5
6 #include <QObject>
6 #include <QObject>
7
7
8 #include <Common/MetaTypes.h>
8 #include <Common/MetaTypes.h>
9
9
10 #include <Data/SqpDateTime.h>
10 #include <Data/SqpDateTime.h>
11
11
12 class DataProviderParameters;
12 class DataProviderParameters;
13 class IDataSeries;
13 class IDataSeries;
14
14
15 /**
15 /**
16 * @brief The IDataProvider interface aims to declare a data provider.
16 * @brief The IDataProvider interface aims to declare a data provider.
17 *
17 *
18 * A data provider is an entity that generates data and returns it according to various parameters
18 * A data provider is an entity that generates data and returns it according to various parameters
19 * (time interval, product to retrieve the data, etc.)
19 * (time interval, product to retrieve the data, etc.)
20 *
20 *
21 * @sa IDataSeries
21 * @sa IDataSeries
22 */
22 */
23 class IDataProvider : public QObject {
23 class IDataProvider : public QObject {
24
24
25 Q_OBJECT
25 Q_OBJECT
26 public:
26 public:
27 virtual ~IDataProvider() noexcept = default;
27 virtual ~IDataProvider() noexcept = default;
28
28
29 virtual std::shared_ptr<IDataSeries>
30 retrieveData(const DataProviderParameters &parameters) const = 0;
31
32
33 virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0;
29 virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0;
34
30
35 signals:
31 signals:
36 void dataProvided(std::shared_ptr<IDataSeries> dateSerie, const SqpDateTime &dateTime);
32 void dataProvided(std::shared_ptr<IDataSeries> dateSerie, const SqpDateTime &dateTime);
37 };
33 };
38
34
39 // Required for using shared_ptr in signals/slots
35 // Required for using shared_ptr in signals/slots
40 SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_PTR_REGISTRY, std::shared_ptr<IDataProvider>)
36 SCIQLOP_REGISTER_META_TYPE(IDATAPROVIDER_PTR_REGISTRY, std::shared_ptr<IDataProvider>)
41
37
42 #endif // SCIQLOP_IDATAPROVIDER_H
38 #endif // SCIQLOP_IDATAPROVIDER_H
@@ -1,211 +1,197
1 #include <Variable/Variable.h>
1 #include <Variable/Variable.h>
2 #include <Variable/VariableCacheController.h>
2 #include <Variable/VariableCacheController.h>
3 #include <Variable/VariableController.h>
3 #include <Variable/VariableController.h>
4 #include <Variable/VariableModel.h>
4 #include <Variable/VariableModel.h>
5
5
6 #include <Data/DataProviderParameters.h>
6 #include <Data/DataProviderParameters.h>
7 #include <Data/IDataProvider.h>
7 #include <Data/IDataProvider.h>
8 #include <Data/IDataSeries.h>
8 #include <Data/IDataSeries.h>
9 #include <Time/TimeController.h>
9 #include <Time/TimeController.h>
10
10
11 #include <QDateTime>
11 #include <QDateTime>
12 #include <QMutex>
12 #include <QMutex>
13 #include <QThread>
13 #include <QThread>
14 #include <QtCore/QItemSelectionModel>
14 #include <QtCore/QItemSelectionModel>
15
15
16 #include <unordered_map>
16 #include <unordered_map>
17
17
18 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
18 Q_LOGGING_CATEGORY(LOG_VariableController, "VariableController")
19
19
20 namespace {
21
22 /// @todo Generates default dataseries, according to the provider passed in parameter. This method
23 /// will be deleted when the timerange is recovered from SciQlop
24 std::shared_ptr<IDataSeries> generateDefaultDataSeries(const IDataProvider &provider,
25 const SqpDateTime &dateTime) noexcept
26 {
27 auto parameters = DataProviderParameters{dateTime};
28
29 return provider.retrieveData(parameters);
30 }
31
32 } // namespace
33
34 struct VariableController::VariableControllerPrivate {
20 struct VariableController::VariableControllerPrivate {
35 explicit VariableControllerPrivate(VariableController *parent)
21 explicit VariableControllerPrivate(VariableController *parent)
36 : m_WorkingMutex{},
22 : m_WorkingMutex{},
37 m_VariableModel{new VariableModel{parent}},
23 m_VariableModel{new VariableModel{parent}},
38 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
24 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
39 m_VariableCacheController{std::make_unique<VariableCacheController>()}
25 m_VariableCacheController{std::make_unique<VariableCacheController>()}
40 {
26 {
41 }
27 }
42
28
43 QMutex m_WorkingMutex;
29 QMutex m_WorkingMutex;
44 /// Variable model. The VariableController has the ownership
30 /// Variable model. The VariableController has the ownership
45 VariableModel *m_VariableModel;
31 VariableModel *m_VariableModel;
46 QItemSelectionModel *m_VariableSelectionModel;
32 QItemSelectionModel *m_VariableSelectionModel;
47
33
48
34
49 TimeController *m_TimeController{nullptr};
35 TimeController *m_TimeController{nullptr};
50 std::unique_ptr<VariableCacheController> m_VariableCacheController;
36 std::unique_ptr<VariableCacheController> m_VariableCacheController;
51
37
52 std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> >
38 std::unordered_map<std::shared_ptr<Variable>, std::shared_ptr<IDataProvider> >
53 m_VariableToProviderMap;
39 m_VariableToProviderMap;
54 };
40 };
55
41
56 VariableController::VariableController(QObject *parent)
42 VariableController::VariableController(QObject *parent)
57 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
43 : QObject{parent}, impl{spimpl::make_unique_impl<VariableControllerPrivate>(this)}
58 {
44 {
59 qCDebug(LOG_VariableController()) << tr("VariableController construction")
45 qCDebug(LOG_VariableController()) << tr("VariableController construction")
60 << QThread::currentThread();
46 << QThread::currentThread();
61 }
47 }
62
48
63 VariableController::~VariableController()
49 VariableController::~VariableController()
64 {
50 {
65 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
51 qCDebug(LOG_VariableController()) << tr("VariableController destruction")
66 << QThread::currentThread();
52 << QThread::currentThread();
67 this->waitForFinish();
53 this->waitForFinish();
68 }
54 }
69
55
70 VariableModel *VariableController::variableModel() noexcept
56 VariableModel *VariableController::variableModel() noexcept
71 {
57 {
72 return impl->m_VariableModel;
58 return impl->m_VariableModel;
73 }
59 }
74
60
75 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
61 QItemSelectionModel *VariableController::variableSelectionModel() noexcept
76 {
62 {
77 return impl->m_VariableSelectionModel;
63 return impl->m_VariableSelectionModel;
78 }
64 }
79
65
80 void VariableController::setTimeController(TimeController *timeController) noexcept
66 void VariableController::setTimeController(TimeController *timeController) noexcept
81 {
67 {
82 impl->m_TimeController = timeController;
68 impl->m_TimeController = timeController;
83 }
69 }
84
70
85 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept
71 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noexcept
86 {
72 {
87 if (!variable) {
73 if (!variable) {
88 qCCritical(LOG_VariableController()) << "Can't delete variable: variable is null";
74 qCCritical(LOG_VariableController()) << "Can't delete variable: variable is null";
89 return;
75 return;
90 }
76 }
91
77
92 // Spreads in SciQlop that the variable will be deleted, so that potential receivers can
78 // Spreads in SciQlop that the variable will be deleted, so that potential receivers can
93 // make some treatments before the deletion
79 // make some treatments before the deletion
94 emit variableAboutToBeDeleted(variable);
80 emit variableAboutToBeDeleted(variable);
95
81
96 // Deletes provider
82 // Deletes provider
97 auto nbProvidersDeleted = impl->m_VariableToProviderMap.erase(variable);
83 auto nbProvidersDeleted = impl->m_VariableToProviderMap.erase(variable);
98 qCDebug(LOG_VariableController())
84 qCDebug(LOG_VariableController())
99 << tr("Number of providers deleted for variable %1: %2")
85 << tr("Number of providers deleted for variable %1: %2")
100 .arg(variable->name(), QString::number(nbProvidersDeleted));
86 .arg(variable->name(), QString::number(nbProvidersDeleted));
101
87
102 // Clears cache
88 // Clears cache
103 impl->m_VariableCacheController->clear(variable);
89 impl->m_VariableCacheController->clear(variable);
104
90
105 // Deletes from model
91 // Deletes from model
106 impl->m_VariableModel->deleteVariable(variable);
92 impl->m_VariableModel->deleteVariable(variable);
107 }
93 }
108
94
109 void VariableController::deleteVariables(
95 void VariableController::deleteVariables(
110 const QVector<std::shared_ptr<Variable> > &variables) noexcept
96 const QVector<std::shared_ptr<Variable> > &variables) noexcept
111 {
97 {
112 for (auto variable : qAsConst(variables)) {
98 for (auto variable : qAsConst(variables)) {
113 deleteVariable(variable);
99 deleteVariable(variable);
114 }
100 }
115 }
101 }
116
102
117 void VariableController::createVariable(const QString &name,
103 void VariableController::createVariable(const QString &name,
118 std::shared_ptr<IDataProvider> provider) noexcept
104 std::shared_ptr<IDataProvider> provider) noexcept
119 {
105 {
120
106
121 if (!impl->m_TimeController) {
107 if (!impl->m_TimeController) {
122 qCCritical(LOG_VariableController())
108 qCCritical(LOG_VariableController())
123 << tr("Impossible to create variable: The time controller is null");
109 << tr("Impossible to create variable: The time controller is null");
124 return;
110 return;
125 }
111 }
126
112
127
113
128 /// @todo : for the moment :
114 /// @todo : for the moment :
129 /// - the provider is only used to retrieve data from the variable for its initialization, but
115 /// - the provider is only used to retrieve data from the variable for its initialization, but
130 /// it will be retained later
116 /// it will be retained later
131 /// - default data are generated for the variable, without taking into account the timerange set
117 /// - default data are generated for the variable, without taking into account the timerange set
132 /// in sciqlop
118 /// in sciqlop
133 auto dateTime = impl->m_TimeController->dateTime();
119 auto dateTime = impl->m_TimeController->dateTime();
134 if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime)) {
120 if (auto newVariable = impl->m_VariableModel->createVariable(name, dateTime)) {
135
121
136 // store the provider
122 // store the provider
137 impl->m_VariableToProviderMap[newVariable] = provider;
123 impl->m_VariableToProviderMap[newVariable] = provider;
138
124
139 auto addDateTimeAcquired = [ this, varW = std::weak_ptr<Variable>{newVariable} ](
125 auto addDateTimeAcquired = [ this, varW = std::weak_ptr<Variable>{newVariable} ](
140 auto dataSeriesAcquired, auto dateTimeToPutInCache)
126 auto dataSeriesAcquired, auto dateTimeToPutInCache)
141 {
127 {
142 if (auto variable = varW.lock()) {
128 if (auto variable = varW.lock()) {
143 impl->m_VariableCacheController->addDateTime(variable, dateTimeToPutInCache);
129 impl->m_VariableCacheController->addDateTime(variable, dateTimeToPutInCache);
144 variable->setDataSeries(dataSeriesAcquired);
130 variable->setDataSeries(dataSeriesAcquired);
145 }
131 }
146 };
132 };
147
133
148 connect(provider.get(), &IDataProvider::dataProvided, addDateTimeAcquired);
134 connect(provider.get(), &IDataProvider::dataProvided, addDateTimeAcquired);
149 this->onRequestDataLoading(newVariable, dateTime);
135 this->onRequestDataLoading(newVariable, dateTime);
150 }
136 }
151 }
137 }
152
138
153 void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime)
139 void VariableController::onDateTimeOnSelection(const SqpDateTime &dateTime)
154 {
140 {
155 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
141 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
156 << QThread::currentThread()->objectName();
142 << QThread::currentThread()->objectName();
157 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
143 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
158
144
159 for (const auto &selectedRow : qAsConst(selectedRows)) {
145 for (const auto &selectedRow : qAsConst(selectedRows)) {
160 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
146 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
161 selectedVariable->setDateTime(dateTime);
147 selectedVariable->setDateTime(dateTime);
162 this->onRequestDataLoading(selectedVariable, dateTime);
148 this->onRequestDataLoading(selectedVariable, dateTime);
163 }
149 }
164 }
150 }
165 }
151 }
166
152
167
153
168 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
154 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable,
169 const SqpDateTime &dateTime)
155 const SqpDateTime &dateTime)
170 {
156 {
171 qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading"
157 qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading"
172 << QThread::currentThread()->objectName();
158 << QThread::currentThread()->objectName();
173 // we want to load data of the variable for the dateTime.
159 // we want to load data of the variable for the dateTime.
174 // First we check if the cache contains some of them.
160 // First we check if the cache contains some of them.
175 // For the other, we ask the provider to give them.
161 // For the other, we ask the provider to give them.
176 if (variable) {
162 if (variable) {
177
163
178 auto dateTimeListNotInCache
164 auto dateTimeListNotInCache
179 = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
165 = impl->m_VariableCacheController->provideNotInCacheDateTimeList(variable, dateTime);
180
166
181 if (!dateTimeListNotInCache.empty()) {
167 if (!dateTimeListNotInCache.empty()) {
182 // Ask the provider for each data on the dateTimeListNotInCache
168 // Ask the provider for each data on the dateTimeListNotInCache
183 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
169 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
184 std::move(dateTimeListNotInCache));
170 std::move(dateTimeListNotInCache));
185 }
171 }
186 else {
172 else {
187 emit variable->updated();
173 emit variable->updated();
188 }
174 }
189 }
175 }
190 else {
176 else {
191 qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null");
177 qCCritical(LOG_VariableController()) << tr("Impossible to load data of a variable null");
192 }
178 }
193 }
179 }
194
180
195
181
196 void VariableController::initialize()
182 void VariableController::initialize()
197 {
183 {
198 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
184 qCDebug(LOG_VariableController()) << tr("VariableController init") << QThread::currentThread();
199 impl->m_WorkingMutex.lock();
185 impl->m_WorkingMutex.lock();
200 qCDebug(LOG_VariableController()) << tr("VariableController init END");
186 qCDebug(LOG_VariableController()) << tr("VariableController init END");
201 }
187 }
202
188
203 void VariableController::finalize()
189 void VariableController::finalize()
204 {
190 {
205 impl->m_WorkingMutex.unlock();
191 impl->m_WorkingMutex.unlock();
206 }
192 }
207
193
208 void VariableController::waitForFinish()
194 void VariableController::waitForFinish()
209 {
195 {
210 QMutexLocker locker{&impl->m_WorkingMutex};
196 QMutexLocker locker{&impl->m_WorkingMutex};
211 }
197 }
@@ -1,50 +1,52
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 NetworkController;
19 class TimeController;
20 class TimeController;
20 class VariableController;
21 class VariableController;
21 class VisualizationController;
22 class VisualizationController;
22
23
23 /**
24 /**
24 * @brief The SqpApplication class aims to make the link between SciQlop
25 * @brief The SqpApplication class aims to make the link between SciQlop
25 * and its plugins. This is the intermediate class that SciQlop has to use
26 * and its plugins. This is the intermediate class that SciQlop has to use
26 * in the way to connect a data source. Please first use load method to initialize
27 * in the way to connect a data source. Please first use load method to initialize
27 * a plugin specified by its metadata name (JSON plugin source) then others specifics
28 * a plugin specified by its metadata name (JSON plugin source) then others specifics
28 * method will be able to access it.
29 * method will be able to access it.
29 * You can load a data source driver plugin then create a data source.
30 * You can load a data source driver plugin then create a data source.
30 */
31 */
31
32
32 class SqpApplication : public QApplication {
33 class SqpApplication : public QApplication {
33 Q_OBJECT
34 Q_OBJECT
34 public:
35 public:
35 explicit SqpApplication(int &argc, char **argv);
36 explicit SqpApplication(int &argc, char **argv);
36 virtual ~SqpApplication();
37 virtual ~SqpApplication();
37 void initialize();
38 void initialize();
38
39
39 /// Accessors for the differents sciqlop controllers
40 /// Accessors for the differents sciqlop controllers
40 DataSourceController &dataSourceController() noexcept;
41 DataSourceController &dataSourceController() noexcept;
42 NetworkController &networkController() noexcept;
41 TimeController &timeController() noexcept;
43 TimeController &timeController() noexcept;
42 VariableController &variableController() noexcept;
44 VariableController &variableController() noexcept;
43 VisualizationController &visualizationController() noexcept;
45 VisualizationController &visualizationController() noexcept;
44
46
45 private:
47 private:
46 class SqpApplicationPrivate;
48 class SqpApplicationPrivate;
47 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
49 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
48 };
50 };
49
51
50 #endif // SCIQLOP_SQPAPPLICATION_H
52 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,124 +1,140
1 #include "SqpApplication.h"
1 #include "SqpApplication.h"
2
2
3 #include <Data/IDataProvider.h>
3 #include <Data/IDataProvider.h>
4 #include <DataSource/DataSourceController.h>
4 #include <DataSource/DataSourceController.h>
5 #include <Network/NetworkController.h>
5 #include <QThread>
6 #include <QThread>
6 #include <Time/TimeController.h>
7 #include <Time/TimeController.h>
7 #include <Variable/Variable.h>
8 #include <Variable/Variable.h>
8 #include <Variable/VariableController.h>
9 #include <Variable/VariableController.h>
9 #include <Visualization/VisualizationController.h>
10 #include <Visualization/VisualizationController.h>
10
11
11 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
12 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
12
13
13 class SqpApplication::SqpApplicationPrivate {
14 class SqpApplication::SqpApplicationPrivate {
14 public:
15 public:
15 SqpApplicationPrivate()
16 SqpApplicationPrivate()
16 : m_DataSourceController{std::make_unique<DataSourceController>()},
17 : m_DataSourceController{std::make_unique<DataSourceController>()},
18 m_NetworkController{std::make_unique<NetworkController>()},
17 m_TimeController{std::make_unique<TimeController>()},
19 m_TimeController{std::make_unique<TimeController>()},
18 m_VariableController{std::make_unique<VariableController>()},
20 m_VariableController{std::make_unique<VariableController>()},
19 m_VisualizationController{std::make_unique<VisualizationController>()}
21 m_VisualizationController{std::make_unique<VisualizationController>()}
20 {
22 {
21 QThread::currentThread()->setObjectName("MainThread");
22 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
23 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
24 m_VariableController->moveToThread(&m_VariableControllerThread);
25 m_VariableControllerThread.setObjectName("VariableControllerThread");
26 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
27 m_VisualizationControllerThread.setObjectName("VisualizationControllerThread");
28
29 // /////////////////////////////// //
23 // /////////////////////////////// //
30 // Connections between controllers //
24 // Connections between controllers //
31 // /////////////////////////////// //
25 // /////////////////////////////// //
32
26
33 // VariableController <-> DataSourceController
27 // VariableController <-> DataSourceController
34 connect(m_DataSourceController.get(),
28 connect(m_DataSourceController.get(),
35 SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)),
29 SIGNAL(variableCreationRequested(const QString &, std::shared_ptr<IDataProvider>)),
36 m_VariableController.get(),
30 m_VariableController.get(),
37 SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>)));
31 SLOT(createVariable(const QString &, std::shared_ptr<IDataProvider>)));
38
32
39 // VariableController <-> VisualizationController
33 // VariableController <-> VisualizationController
40 connect(m_VariableController.get(),
34 connect(m_VariableController.get(),
41 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
35 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)),
42 m_VisualizationController.get(),
36 m_VisualizationController.get(),
43 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
37 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), Qt::DirectConnection);
44
38
45
39
40 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
41 m_NetworkController->moveToThread(&m_NetworkControllerThread);
42 m_VariableController->moveToThread(&m_VariableControllerThread);
43 m_VisualizationController->moveToThread(&m_VisualizationControllerThread);
44
45
46 // Additionnal init
46 // Additionnal init
47 m_VariableController->setTimeController(m_TimeController.get());
47 m_VariableController->setTimeController(m_TimeController.get());
48 }
48 }
49
49
50 virtual ~SqpApplicationPrivate()
50 virtual ~SqpApplicationPrivate()
51 {
51 {
52 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
52 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
53 m_DataSourceControllerThread.quit();
53 m_DataSourceControllerThread.quit();
54 m_DataSourceControllerThread.wait();
54 m_DataSourceControllerThread.wait();
55
55
56 m_NetworkControllerThread.quit();
57 m_NetworkControllerThread.wait();
58
56 m_VariableControllerThread.quit();
59 m_VariableControllerThread.quit();
57 m_VariableControllerThread.wait();
60 m_VariableControllerThread.wait();
58
61
59 m_VisualizationControllerThread.quit();
62 m_VisualizationControllerThread.quit();
60 m_VisualizationControllerThread.wait();
63 m_VisualizationControllerThread.wait();
61 }
64 }
62
65
63 std::unique_ptr<DataSourceController> m_DataSourceController;
66 std::unique_ptr<DataSourceController> m_DataSourceController;
64 std::unique_ptr<VariableController> m_VariableController;
67 std::unique_ptr<VariableController> m_VariableController;
65 std::unique_ptr<TimeController> m_TimeController;
68 std::unique_ptr<TimeController> m_TimeController;
69 std::unique_ptr<NetworkController> m_NetworkController;
66 std::unique_ptr<VisualizationController> m_VisualizationController;
70 std::unique_ptr<VisualizationController> m_VisualizationController;
67 QThread m_DataSourceControllerThread;
71 QThread m_DataSourceControllerThread;
72 QThread m_NetworkControllerThread;
68 QThread m_VariableControllerThread;
73 QThread m_VariableControllerThread;
69 QThread m_VisualizationControllerThread;
74 QThread m_VisualizationControllerThread;
70 };
75 };
71
76
72
77
73 SqpApplication::SqpApplication(int &argc, char **argv)
78 SqpApplication::SqpApplication(int &argc, char **argv)
74 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
79 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
75 {
80 {
76 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
81 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
77
82
78 connect(&impl->m_DataSourceControllerThread, &QThread::started,
83 connect(&impl->m_DataSourceControllerThread, &QThread::started,
79 impl->m_DataSourceController.get(), &DataSourceController::initialize);
84 impl->m_DataSourceController.get(), &DataSourceController::initialize);
80 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
85 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
81 impl->m_DataSourceController.get(), &DataSourceController::finalize);
86 impl->m_DataSourceController.get(), &DataSourceController::finalize);
82
87
88 connect(&impl->m_NetworkControllerThread, &QThread::started, impl->m_NetworkController.get(),
89 &NetworkController::initialize);
90 connect(&impl->m_NetworkControllerThread, &QThread::finished, impl->m_NetworkController.get(),
91 &NetworkController::finalize);
92
83 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
93 connect(&impl->m_VariableControllerThread, &QThread::started, impl->m_VariableController.get(),
84 &VariableController::initialize);
94 &VariableController::initialize);
85 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
95 connect(&impl->m_VariableControllerThread, &QThread::finished, impl->m_VariableController.get(),
86 &VariableController::finalize);
96 &VariableController::finalize);
87
97
88 connect(&impl->m_VisualizationControllerThread, &QThread::started,
98 connect(&impl->m_VisualizationControllerThread, &QThread::started,
89 impl->m_VisualizationController.get(), &VisualizationController::initialize);
99 impl->m_VisualizationController.get(), &VisualizationController::initialize);
90 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
100 connect(&impl->m_VisualizationControllerThread, &QThread::finished,
91 impl->m_VisualizationController.get(), &VisualizationController::finalize);
101 impl->m_VisualizationController.get(), &VisualizationController::finalize);
92
102
93 impl->m_DataSourceControllerThread.start();
103 impl->m_DataSourceControllerThread.start();
104 impl->m_NetworkControllerThread.start();
94 impl->m_VariableControllerThread.start();
105 impl->m_VariableControllerThread.start();
95 impl->m_VisualizationControllerThread.start();
106 impl->m_VisualizationControllerThread.start();
96 }
107 }
97
108
98 SqpApplication::~SqpApplication()
109 SqpApplication::~SqpApplication()
99 {
110 {
100 }
111 }
101
112
102 void SqpApplication::initialize()
113 void SqpApplication::initialize()
103 {
114 {
104 }
115 }
105
116
106 DataSourceController &SqpApplication::dataSourceController() noexcept
117 DataSourceController &SqpApplication::dataSourceController() noexcept
107 {
118 {
108 return *impl->m_DataSourceController;
119 return *impl->m_DataSourceController;
109 }
120 }
110
121
122 NetworkController &SqpApplication::networkController() noexcept
123 {
124 return *impl->m_NetworkController;
125 }
126
111 TimeController &SqpApplication::timeController() noexcept
127 TimeController &SqpApplication::timeController() noexcept
112 {
128 {
113 return *impl->m_TimeController;
129 return *impl->m_TimeController;
114 }
130 }
115
131
116 VariableController &SqpApplication::variableController() noexcept
132 VariableController &SqpApplication::variableController() noexcept
117 {
133 {
118 return *impl->m_VariableController;
134 return *impl->m_VariableController;
119 }
135 }
120
136
121 VisualizationController &SqpApplication::visualizationController() noexcept
137 VisualizationController &SqpApplication::visualizationController() noexcept
122 {
138 {
123 return *impl->m_VisualizationController;
139 return *impl->m_VisualizationController;
124 }
140 }
@@ -1,28 +1,26
1 #ifndef SCIQLOP_COSINUSPROVIDER_H
1 #ifndef SCIQLOP_COSINUSPROVIDER_H
2 #define SCIQLOP_COSINUSPROVIDER_H
2 #define SCIQLOP_COSINUSPROVIDER_H
3
3
4 #include "MockPluginGlobal.h"
4 #include "MockPluginGlobal.h"
5
5
6 #include <Data/IDataProvider.h>
6 #include <Data/IDataProvider.h>
7
7
8 #include <QLoggingCategory>
8 #include <QLoggingCategory>
9
9
10 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider)
10 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider)
11
11
12 /**
12 /**
13 * @brief The CosinusProvider class is an example of how a data provider can generate data
13 * @brief The CosinusProvider class is an example of how a data provider can generate data
14 */
14 */
15 class SCIQLOP_MOCKPLUGIN_EXPORT CosinusProvider : public IDataProvider {
15 class SCIQLOP_MOCKPLUGIN_EXPORT CosinusProvider : public IDataProvider {
16 public:
16 public:
17 /// @sa IDataProvider::retrieveData()
18 std::shared_ptr<IDataSeries>
19 retrieveData(const DataProviderParameters &parameters) const override;
20
21 void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) override;
17 void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) override;
22
18
23
19
24 private:
20 private:
21 /// @sa IDataProvider::retrieveData()
22 std::shared_ptr<IDataSeries> retrieveData(const DataProviderParameters &parameters) const;
25 std::shared_ptr<IDataSeries> retrieveDataSeries(const SqpDateTime &dateTime);
23 std::shared_ptr<IDataSeries> retrieveDataSeries(const SqpDateTime &dateTime);
26 };
24 };
27
25
28 #endif // SCIQLOP_COSINUSPROVIDER_H
26 #endif // SCIQLOP_COSINUSPROVIDER_H
General Comments 0
You need to be logged in to leave comments. Login now