##// END OF EJS Templates
Bypassed cache and merge mechanism, this seems to be broken...
jeandet -
r44:79fb0ced05d7
parent child
Show More
@@ -70,6 +70,10 public:
70 const DateTimeRange& newRange, const DateTimeRange& newCacheRange,
70 const DateTimeRange& newRange, const DateTimeRange& newCacheRange,
71 bool notify=true);
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 static QByteArray mimeData(const std::vector<std::shared_ptr<Variable> > &variables)
77 static QByteArray mimeData(const std::vector<std::shared_ptr<Variable> > &variables)
74 {
78 {
75 auto encodedData = QByteArray{};
79 auto encodedData = QByteArray{};
@@ -45,10 +45,12 class TransactionExe:public QObject,public QRunnable
45 std::vector<DateTimeRange> _ranges;
45 std::vector<DateTimeRange> _ranges;
46 DateTimeRange _range;
46 DateTimeRange _range;
47 DateTimeRange _cacheRange;
47 DateTimeRange _cacheRange;
48 bool _overwrite;
48 public:
49 public:
49 TransactionExe(const std::shared_ptr<Variable>& variable, const std::shared_ptr<IDataProvider>& provider,
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 const std::vector<DateTimeRange>& ranges, DateTimeRange range, DateTimeRange cacheRange,
51 :_variable{variable}, _provider{provider},_ranges{ranges},_range{range},_cacheRange{cacheRange}
52 bool overwrite=true)
53 :_variable{variable}, _provider{provider},_ranges{ranges},_range{range},_cacheRange{cacheRange}, _overwrite{overwrite}
52 {
54 {
53 setAutoDelete(true);
55 setAutoDelete(true);
54 }
56 }
@@ -61,7 +63,10 public:
61 if(ds)
63 if(ds)
62 data.push_back(ds);
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 emit transactionComplete();
70 emit transactionComplete();
66 }
71 }
67 signals:
72 signals:
@@ -94,12 +94,12 struct Variable::VariablePrivate {
94 updateRealRange();
94 updateRealRange();
95 updateNbPoints();
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 QWriteLocker lock{&m_Lock};
99 QWriteLocker lock{&m_Lock};
100 for(auto ds:dataseries)
100 for(auto ds:dataseries)
101 {
101 {
102 if(m_DataSeries)
102 if(!overwrite & bool(m_DataSeries))
103 m_DataSeries->merge(ds);
103 m_DataSeries->merge(ds);
104 else
104 else
105 m_DataSeries = ds->clone();
105 m_DataSeries = ds->clone();
@@ -193,6 +193,19 void Variable::updateData(const std::vector<IDataSeries *> &dataSeries, const Da
193 emit updated(this->ID());
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 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
209 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
197 {
210 {
198 return impl->dataSeries();
211 return impl->dataSeries();
@@ -16,7 +16,6
16 #include <QCoreApplication>
16 #include <QCoreApplication>
17
17
18
18
19
20 class VariableController2::VariableController2Private
19 class VariableController2::VariableController2Private
21 {
20 {
22 struct threadSafeVaraiblesMaps
21 struct threadSafeVaraiblesMaps
@@ -130,7 +129,7 class VariableController2::VariableController2Private
130 this->_processTransactions();
129 this->_processTransactions();
131 }
130 }
132
131
133 void _processTransactions()
132 void _processTransactions(bool fragmented=false)
134 {
133 {
135 auto nextTransactions = _transactions.nextTransactions();
134 auto nextTransactions = _transactions.nextTransactions();
136 auto pendingTransactions = _transactions.pendingTransactions();
135 auto pendingTransactions = _transactions.pendingTransactions();
@@ -145,18 +144,32 class VariableController2::VariableController2Private
145 {
144 {
146 auto provider = _maps.provider(ID);
145 auto provider = _maps.provider(ID);
147 auto variable = _maps.variable(ID);
146 auto variable = _maps.variable(ID);
148 auto [missingRanges, newCacheRange] = _computeMissingRanges(variable,range);
147 if(fragmented)
149
148 {
150 auto exe = new TransactionExe(variable, provider, missingRanges, range, newCacheRange);
149 auto [missingRanges, newCacheRange] = _computeMissingRanges(variable,range);
151 QObject::connect(exe,
150
152 &TransactionExe::transactionComplete,
151 auto exe = new TransactionExe(variable, provider, missingRanges, range, newCacheRange);
153 [groupID=groupID,transaction=newTransaction.value(),this]()
152 QObject::connect(exe,
154 {
153 &TransactionExe::transactionComplete,
155 this->_transactionComplete(groupID, transaction);
154 [groupID=groupID,transaction=newTransaction.value(),this]()
156 }
155 {
157 );
156 this->_transactionComplete(groupID, transaction);
158 _ThreadPool->start(exe);
157 }
159
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