##// END OF EJS Templates
Removed old IDataProvider interface, added small tweak in downloader...
jeandet -
r28:a05b0ab23493
parent child
Show More
@@ -27,6 +27,7 DEPRECATE(
27 27 *
28 28 * A data provider is an entity that generates data and returns it according to various parameters
29 29 * (time interval, product to retrieve the data, etc.)
30 * Since its client mihgt use it from different threads it has to be either stateless and/or thread safe
30 31 *
31 32 * @sa IDataSeries
32 33 */
@@ -37,71 +38,13 public:
37 38 virtual ~IDataProvider() noexcept = default;
38 39 virtual std::shared_ptr<IDataProvider> clone() const = 0;
39 40
40 DEPRECATE(
41 /**
42 * @brief requestDataLoading provide datas for the data identified by acqIdentifier and
43 * parameters
44 */
45 virtual void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters &parameters)
46 = 0;
47 )
48
49 41 // Synchronous call -> asyncGetData may be written for asynchronous get
50 virtual IDataSeries* getData(const DataProviderParameters &parameters)
51 {
52 Q_UNUSED(parameters);
53 return nullptr;
54 }
55
56
57 DEPRECATE(
58 /**
59 * @brief requestDataAborting stop data loading of the data identified by acqIdentifier
60 */
61 virtual void requestDataAborting(QUuid acqIdentifier) = 0;
62 )
63
64 virtual void abort(QUuid requestID){Q_UNUSED(requestID);}
42 virtual IDataSeries* getData(const DataProviderParameters &parameters) = 0;
65 43
66 44 signals:
67 DEPRECATE(
68 /**
69 * @brief dataProvided send dataSeries under dateTime and that corresponds of the data
70 * identified by acqIdentifier
71 */
72 void dataProvided(QUuid acqIdentifier, std::shared_ptr<IDataSeries> dateSeriesAcquired,
73 const DateTimeRange &dataRangeAcquired);
74 )
75
76 void finished(QUuid requestID, std::shared_ptr<IDataSeries> dataSerie,
77 const DateTimeRange &range);
78
79 DEPRECATE(
80 /**
81 * @brief dataProvidedProgress notify the progression of the data identifier by acqIdentifier
82 */
83 void dataProvidedProgress(QUuid acqIdentifier, double progress);
84 )
85 45
86 46 void progress(QUuid requestID, double progress);
87 47
88 DEPRECATE(
89 /**
90 * @brief dataProvidedFailed notify that data acquisition has failed
91 */
92 void dataProvidedFailed(QUuid acqIdentifier);
93 )
94
95 void failed(QUuid requestID);
96
97 /**
98 * @brief requestConstructed send a request for the data identified by acqIdentifier
99 * @callback is the methode call by the reply of the request when it is finished.
100 */
101 DEPRECATE(
102 void requestConstructed(std::shared_ptr<QNetworkRequest> request, QUuid acqIdentifier,
103 std::function<void(QNetworkReply *, QUuid)> callback);
104 )
105 48 };
106 49
107 50 // Required for using shared_ptr in signals/slots
@@ -57,7 +57,9 public:
57 57 std::vector<IDataSeries*> data;
58 58 for(auto range:_ranges)
59 59 {
60 data.push_back(_provider->getData(DataProviderParameters{{range}, _variable->metadata()}));
60 auto ds = _provider->getData(DataProviderParameters{{range}, _variable->metadata()});
61 if(ds)
62 data.push_back(ds);
61 63 }
62 64 _variable->updateData(data, _range, _cacheRange, true);
63 65 emit transactionComplete();
@@ -10,6 +10,7
10 10 #include <QPair>
11 11 #include <QCoreApplication>
12 12 #include <QReadWriteLock>
13 #include <QThread>
13 14
14 15 class Downloader::p_Downloader
15 16 {
@@ -56,7 +57,10 public:
56 57 QNetworkRequest request = buildRequest(url, user, passwd);
57 58 QNetworkReply *reply = manager.get(request);
58 59 while (!reply->isFinished())
60 {
59 61 QCoreApplication::processEvents();
62 QThread::usleep(10000);
63 }
60 64 QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
61 65 Response resp = Response(reply->readAll(), status_code.toInt());
62 66 delete reply;
@@ -117,7 +117,7 class VariableController2::VariableController2Private
117 117 QMap<QUuid,std::shared_ptr<VariableSynchronizationGroup2>> _synchronizationGroups;
118 118 QReadWriteLock _lock{QReadWriteLock::Recursive};
119 119 }_maps;
120 QThreadPool _ThreadPool;
120 QThreadPool* _ThreadPool;
121 121 VCTransactionsQueues _transactions;
122 122 std::unique_ptr<VariableCacheStrategy> _cacheStrategy;
123 123
@@ -153,7 +153,7 class VariableController2::VariableController2Private
153 153 this->_transactionComplete(groupID, transaction);
154 154 }
155 155 );
156 _ThreadPool.start(exe);
156 _ThreadPool->start(exe);
157 157 }
158 158 }
159 159 }
@@ -229,7 +229,8 public:
229 229 :_cacheStrategy(VariableCacheStrategyFactory::createCacheStrategy(CacheStrategy::SingleThreshold))
230 230 {
231 231 Q_UNUSED(parent);
232 this->_ThreadPool.setMaxThreadCount(32);
232 this->_ThreadPool = new QThreadPool();
233 this->_ThreadPool->setMaxThreadCount(32);
233 234 }
234 235
235 236 /*
@@ -239,10 +240,7 public:
239 240 */
240 241 ~VariableController2Private()
241 242 {
242 while (this->_ThreadPool.activeThreadCount())
243 {
244 this->_ThreadPool.waitForDone(100);
245 }
243 delete this->_ThreadPool;
246 244 }
247 245
248 246 std::shared_ptr<Variable> createVariable(const QString &name, const QVariantHash &metadata, std::shared_ptr<IDataProvider> provider)
@@ -330,7 +328,7 std::shared_ptr<Variable> VariableController2::createVariable(const QString &nam
330 328 auto var = impl->createVariable(name, metadata, provider);
331 329 emit variableAdded(var);
332 330 if(!DateTimeRangeHelper::hasnan(range))
333 impl->changeRange(var,range);
331 impl->asyncChangeRange(var,range);
334 332 else
335 333 SCIQLOP_ERROR(VariableController2, "Creating a variable with default constructed DateTimeRange is an error");
336 334 return var;
@@ -42,19 +42,6 public:
42 42 return serie;
43 43 }
44 44
45
46
47 void requestDataLoading(QUuid acqIdentifier, const DataProviderParameters &parameters) override
48 {
49 Q_UNUSED(acqIdentifier)
50 Q_UNUSED(parameters)
51 }
52
53 void requestDataAborting(QUuid acqIdentifier) override
54 {
55 Q_UNUSED(acqIdentifier)
56 }
57
58 45 };
59 46
60 47
General Comments 0
You need to be logged in to leave comments. Login now