@@ -70,6 +70,10 public: | |||
|
70 | 70 | const DateTimeRange& newRange, const DateTimeRange& newCacheRange, |
|
71 | 71 | bool notify=true); |
|
72 | 72 | |
|
73 | void setData(const std::vector<IDataSeries*>& dataSeries, | |
|
74 | const DateTimeRange& newRange, const DateTimeRange& newCacheRange, | |
|
75 | bool notify=true); | |
|
76 | ||
|
73 | 77 | static QByteArray mimeData(const std::vector<std::shared_ptr<Variable> > &variables) |
|
74 | 78 | { |
|
75 | 79 | auto encodedData = QByteArray{}; |
@@ -45,10 +45,12 class TransactionExe:public QObject,public QRunnable | |||
|
45 | 45 | std::vector<DateTimeRange> _ranges; |
|
46 | 46 | DateTimeRange _range; |
|
47 | 47 | DateTimeRange _cacheRange; |
|
48 | bool _overwrite; | |
|
48 | 49 | public: |
|
49 | 50 | TransactionExe(const std::shared_ptr<Variable>& variable, const std::shared_ptr<IDataProvider>& provider, |
|
50 |
const std::vector<DateTimeRange>& ranges, DateTimeRange range, DateTimeRange cacheRange |
|
|
51 | :_variable{variable}, _provider{provider},_ranges{ranges},_range{range},_cacheRange{cacheRange} | |
|
51 | const std::vector<DateTimeRange>& ranges, DateTimeRange range, DateTimeRange cacheRange, | |
|
52 | bool overwrite=true) | |
|
53 | :_variable{variable}, _provider{provider},_ranges{ranges},_range{range},_cacheRange{cacheRange}, _overwrite{overwrite} | |
|
52 | 54 | { |
|
53 | 55 | setAutoDelete(true); |
|
54 | 56 | } |
@@ -61,7 +63,10 public: | |||
|
61 | 63 | if(ds) |
|
62 | 64 | data.push_back(ds); |
|
63 | 65 | } |
|
64 | _variable->updateData(data, _range, _cacheRange, true); | |
|
66 | if(_overwrite) | |
|
67 | _variable->setData(data,_range, _cacheRange, true); | |
|
68 | else | |
|
69 | _variable->updateData(data, _range, _cacheRange, true); | |
|
65 | 70 | emit transactionComplete(); |
|
66 | 71 | } |
|
67 | 72 | signals: |
@@ -94,12 +94,12 struct Variable::VariablePrivate { | |||
|
94 | 94 | updateRealRange(); |
|
95 | 95 | updateNbPoints(); |
|
96 | 96 | } |
|
97 | void mergeDataSeries(const std::vector<IDataSeries*>& dataseries) | |
|
97 | void mergeDataSeries(const std::vector<IDataSeries*>& dataseries, bool overwrite=false) | |
|
98 | 98 | { |
|
99 | 99 | QWriteLocker lock{&m_Lock}; |
|
100 | 100 | for(auto ds:dataseries) |
|
101 | 101 | { |
|
102 | if(m_DataSeries) | |
|
102 | if(!overwrite & bool(m_DataSeries)) | |
|
103 | 103 | m_DataSeries->merge(ds); |
|
104 | 104 | else |
|
105 | 105 | m_DataSeries = ds->clone(); |
@@ -193,6 +193,19 void Variable::updateData(const std::vector<IDataSeries *> &dataSeries, const Da | |||
|
193 | 193 | emit updated(this->ID()); |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | void Variable::setData(const std::vector<IDataSeries *> &dataSeries, const DateTimeRange &newRange, const DateTimeRange &newCacheRange, bool notify) | |
|
197 | { | |
|
198 | { | |
|
199 | QWriteLocker lock{&m_lock}; | |
|
200 | impl->mergeDataSeries(dataSeries, true); | |
|
201 | impl->setRange(newRange); | |
|
202 | impl->setCacheRange(newCacheRange); | |
|
203 | impl->purgeDataSeries(); | |
|
204 | } | |
|
205 | if(notify) | |
|
206 | emit updated(this->ID()); | |
|
207 | } | |
|
208 | ||
|
196 | 209 | std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept |
|
197 | 210 | { |
|
198 | 211 | return impl->dataSeries(); |
@@ -16,7 +16,6 | |||
|
16 | 16 | #include <QCoreApplication> |
|
17 | 17 | |
|
18 | 18 | |
|
19 | ||
|
20 | 19 | class VariableController2::VariableController2Private |
|
21 | 20 | { |
|
22 | 21 | struct threadSafeVaraiblesMaps |
@@ -130,7 +129,7 class VariableController2::VariableController2Private | |||
|
130 | 129 | this->_processTransactions(); |
|
131 | 130 | } |
|
132 | 131 | |
|
133 | void _processTransactions() | |
|
132 | void _processTransactions(bool fragmented=false) | |
|
134 | 133 | { |
|
135 | 134 | auto nextTransactions = _transactions.nextTransactions(); |
|
136 | 135 | auto pendingTransactions = _transactions.pendingTransactions(); |
@@ -145,18 +144,32 class VariableController2::VariableController2Private | |||
|
145 | 144 | { |
|
146 | 145 | auto provider = _maps.provider(ID); |
|
147 | 146 | auto variable = _maps.variable(ID); |
|
148 | auto [missingRanges, newCacheRange] = _computeMissingRanges(variable,range); | |
|
149 | ||
|
150 | auto exe = new TransactionExe(variable, provider, missingRanges, range, newCacheRange); | |
|
151 | QObject::connect(exe, | |
|
152 | &TransactionExe::transactionComplete, | |
|
153 | [groupID=groupID,transaction=newTransaction.value(),this]() | |
|
154 | { | |
|
155 |
|
|
|
156 |
|
|
|
157 | ); | |
|
158 | _ThreadPool->start(exe); | |
|
159 | ||
|
147 | if(fragmented) | |
|
148 | { | |
|
149 | auto [missingRanges, newCacheRange] = _computeMissingRanges(variable,range); | |
|
150 | ||
|
151 | auto exe = new TransactionExe(variable, provider, missingRanges, range, newCacheRange); | |
|
152 | QObject::connect(exe, | |
|
153 | &TransactionExe::transactionComplete, | |
|
154 | [groupID=groupID,transaction=newTransaction.value(),this]() | |
|
155 | { | |
|
156 | this->_transactionComplete(groupID, transaction); | |
|
157 | } | |
|
158 | ); | |
|
159 | _ThreadPool->start(exe); | |
|
160 | } | |
|
161 | else | |
|
162 | { | |
|
163 | auto exe = new TransactionExe(variable, provider, {range}, range, range); | |
|
164 | QObject::connect(exe, | |
|
165 | &TransactionExe::transactionComplete, | |
|
166 | [groupID=groupID,transaction=newTransaction.value(),this]() | |
|
167 | { | |
|
168 | this->_transactionComplete(groupID, transaction); | |
|
169 | } | |
|
170 | ); | |
|
171 | _ThreadPool->start(exe); | |
|
172 | } | |
|
160 | 173 | } |
|
161 | 174 | } |
|
162 | 175 | } |
General Comments 0
You need to be logged in to leave comments.
Login now