##// END OF EJS Templates
Updates IDataProvider::requestDataLoading() method's signature...
Alexandre Leroux -
r408:49f712bf7e59
parent child
Show More
@@ -9,7 +9,7
9 9 * @sa IDataProvider
10 10 */
11 11 struct DataProviderParameters {
12 SqpDateTime m_Time;
12 QVector<SqpDateTime> m_Times;
13 13 };
14 14
15 15 #endif // SCIQLOP_DATAPROVIDERPARAMETERS_H
@@ -30,10 +30,9 public:
30 30 virtual ~IDataProvider() noexcept = default;
31 31
32 32 /**
33 * @brief requestDataLoading provide datas for the data identified by identifier for all
34 * SqpDateTime of dateTimeList
33 * @brief requestDataLoading provide datas for the data identified by identifier and parameters
35 34 */
36 virtual void requestDataLoading(QUuid identifier, const QVector<SqpDateTime> &dateTimeList) = 0;
35 virtual void requestDataLoading(QUuid identifier, const DataProviderParameters &parameters) = 0;
37 36
38 37 signals:
39 38 /**
@@ -186,7 +186,7 void VariableController::onRequestDataLoading(std::shared_ptr<Variable> variable
186 186 // Ask the provider for each data on the dateTimeListNotInCache
187 187 auto identifier = impl->m_VariableToIdentifier.at(variable);
188 188 impl->m_VariableToProviderMap.at(variable)->requestDataLoading(
189 identifier, std::move(dateTimeListNotInCache));
189 identifier, DataProviderParameters{std::move(dateTimeListNotInCache)});
190 190 }
191 191 else {
192 192 emit variable->updated();
@@ -21,10 +21,10 class SCIQLOP_AMDA_EXPORT AmdaProvider : public IDataProvider {
21 21 public:
22 22 explicit AmdaProvider();
23 23
24 void requestDataLoading(QUuid token, const QVector<SqpDateTime> &dateTimeList) override;
24 void requestDataLoading(QUuid token, const DataProviderParameters &parameters) override;
25 25
26 26 private:
27 void retrieveData(QUuid token, const DataProviderParameters &parameters);
27 void retrieveData(QUuid token, const SqpDateTime &dateTime);
28 28
29 29 class AmdaProviderPrivate;
30 30 spimpl::unique_impl_ptr<AmdaProviderPrivate> impl;
@@ -38,7 +38,7 QString dateFormat(double sqpDateTime) noexcept
38 38 } // namespace
39 39
40 40 struct AmdaProvider::AmdaProviderPrivate {
41 DataProviderParameters m_Params{};
41 SqpDateTime m_DateTime{};
42 42 std::unique_ptr<QNetworkAccessManager> m_AccessManager{nullptr};
43 43 QNetworkReply *m_Reply{nullptr};
44 44 // std::unique_ptr<QTemporaryFile> m_File{nullptr};
@@ -56,22 +56,23 AmdaProvider::AmdaProvider() : impl{spimpl::make_unique_impl<AmdaProviderPrivate
56 56 }
57 57 }
58 58
59 void AmdaProvider::requestDataLoading(QUuid token, const QVector<SqpDateTime> &dateTimeList)
59 void AmdaProvider::requestDataLoading(QUuid token, const DataProviderParameters &parameters)
60 60 {
61 61 // NOTE: Try to use multithread if possible
62 for (const auto &dateTime : dateTimeList) {
63 retrieveData(token, DataProviderParameters{dateTime});
62 const auto times = parameters.m_Times;
63 for (const auto &dateTime : qAsConst(times)) {
64 retrieveData(token, dateTime);
64 65 }
65 66 }
66 67
67 void AmdaProvider::retrieveData(QUuid token, const DataProviderParameters &parameters)
68 void AmdaProvider::retrieveData(QUuid token, const SqpDateTime &dateTime)
68 69 {
69 70 // /////////// //
70 71 // Creates URL //
71 72 // /////////// //
72 73
73 auto startDate = dateFormat(parameters.m_Time.m_TStart);
74 auto endDate = dateFormat(parameters.m_Time.m_TEnd);
74 auto startDate = dateFormat(dateTime.m_TStart);
75 auto endDate = dateFormat(dateTime.m_TEnd);
75 76 auto productId = QStringLiteral("imf(0)");
76 77
77 78 auto url = QUrl{QString{AMDA_URL_FORMAT}.arg(startDate, endDate, productId)};
@@ -91,7 +92,7 void AmdaProvider::retrieveData(QUuid token, const DataProviderParameters &param
91 92
92 93 // Parse results file
93 94 if (auto dataSeries = AmdaResultParser::readTxt(tempFile->fileName())) {
94 emit dataProvided(impl->m_Token, dataSeries, impl->m_Params.m_Time);
95 emit dataProvided(impl->m_Token, dataSeries, impl->m_DateTime);
95 96 }
96 97 else {
97 98 /// @todo ALX : debug
@@ -123,6 +124,6 void AmdaProvider::retrieveData(QUuid token, const DataProviderParameters &param
123 124 // //////////////// //
124 125
125 126 impl->m_Token = token;
126 impl->m_Params = parameters;
127 impl->m_DateTime = dateTime;
127 128 emit requestConstructed(QNetworkRequest{url}, token, httpFinishedLambda);
128 129 }
@@ -14,13 +14,12 Q_DECLARE_LOGGING_CATEGORY(LOG_CosinusProvider)
14 14 */
15 15 class SCIQLOP_MOCKPLUGIN_EXPORT CosinusProvider : public IDataProvider {
16 16 public:
17 void requestDataLoading(QUuid token, const QVector<SqpDateTime> &dateTimeList) override;
17 void requestDataLoading(QUuid token, const DataProviderParameters &parameters) override;
18 18
19 19
20 20 private:
21 21 /// @sa IDataProvider::retrieveData()
22 std::shared_ptr<IDataSeries> retrieveData(const DataProviderParameters &parameters) const;
23 std::shared_ptr<IDataSeries> retrieveDataSeries(const SqpDateTime &dateTime);
22 std::shared_ptr<IDataSeries> retrieveData(const SqpDateTime &dateTime) const;
24 23 };
25 24
26 25 #endif // SCIQLOP_COSINUSPROVIDER_H
@@ -10,11 +10,8
10 10
11 11 Q_LOGGING_CATEGORY(LOG_CosinusProvider, "CosinusProvider")
12 12
13 std::shared_ptr<IDataSeries>
14 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
13 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(const SqpDateTime &dateTime) const
15 14 {
16 auto dateTime = parameters.m_Time;
17
18 15 auto dataIndex = 0;
19 16
20 17 // Gets the timerange from the parameters
@@ -38,13 +35,14 CosinusProvider::retrieveData(const DataProviderParameters &parameters) const
38 35 return scalarSeries;
39 36 }
40 37
41 void CosinusProvider::requestDataLoading(QUuid token, const QVector<SqpDateTime> &dateTimeList)
38 void CosinusProvider::requestDataLoading(QUuid token, const DataProviderParameters &parameters)
42 39 {
43 40 qCDebug(LOG_CosinusProvider()) << "CosinusProvider::requestDataLoading"
44 41 << QThread::currentThread()->objectName();
45 42 // NOTE: Try to use multithread if possible
46 for (const auto &dateTime : dateTimeList) {
47 auto scalarSeries = this->retrieveData(DataProviderParameters{dateTime});
43 const auto times = parameters.m_Times;
44 for (const auto &dateTime : qAsConst(times)) {
45 auto scalarSeries = this->retrieveData(dateTime);
48 46 emit dataProvided(token, scalarSeries, dateTime);
49 47 }
50 48 }
General Comments 0
You need to be logged in to leave comments. Login now