##// END OF EJS Templates
Calls purge() method when setting cache range or data series of a variable
Alexandre Leroux -
r677:0efbd3cc5e8d
parent child
Show More
@@ -57,7 +57,6 public:
57
57
58 QVector<SqpRange> provideNotInCacheRangeList(const SqpRange &range) const noexcept;
58 QVector<SqpRange> provideNotInCacheRangeList(const SqpRange &range) const noexcept;
59 QVector<SqpRange> provideInCacheRangeList(const SqpRange &range) const noexcept;
59 QVector<SqpRange> provideInCacheRangeList(const SqpRange &range) const noexcept;
60 void setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
61 void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
60 void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
62
61
63 signals:
62 signals:
@@ -24,6 +24,14 struct Variable::VariablePrivate {
24 void lockWrite() { m_Lock.lockForWrite(); }
24 void lockWrite() { m_Lock.lockForWrite(); }
25 void unlock() { m_Lock.unlock(); }
25 void unlock() { m_Lock.unlock(); }
26
26
27 void purgeDataSeries()
28 {
29 if (m_DataSeries) {
30 m_DataSeries->purge(m_CacheRange.m_TStart, m_CacheRange.m_TEnd);
31 }
32 updateRealRange();
33 }
34
27 /// Updates real range according to current variable range and data series
35 /// Updates real range according to current variable range and data series
28 void updateRealRange()
36 void updateRealRange()
29 {
37 {
@@ -94,7 +102,10 SqpRange Variable::cacheRange() const noexcept
94 void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
102 void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
95 {
103 {
96 impl->lockWrite();
104 impl->lockWrite();
105 if (cacheRange != impl->m_CacheRange) {
97 impl->m_CacheRange = cacheRange;
106 impl->m_CacheRange = cacheRange;
107 impl->purgeDataSeries();
108 }
98 impl->unlock();
109 impl->unlock();
99 }
110 }
100
111
@@ -103,20 +114,6 SqpRange Variable::realRange() const noexcept
103 return impl->m_RealRange;
114 return impl->m_RealRange;
104 }
115 }
105
116
106 void Variable::setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
107 {
108 qCDebug(LOG_Variable()) << "TORM Variable::setDataSeries"
109 << QThread::currentThread()->objectName();
110 if (!dataSeries) {
111 /// @todo ALX : log
112 return;
113 }
114 impl->lockWrite();
115 impl->m_DataSeries = dataSeries->clone();
116 impl->updateRealRange();
117 impl->unlock();
118 }
119
120 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
117 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
121 {
118 {
122 qCDebug(LOG_Variable()) << "TORM Variable::mergeDataSeries"
119 qCDebug(LOG_Variable()) << "TORM Variable::mergeDataSeries"
@@ -127,7 +124,6 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
127 }
124 }
128
125
129 // Add or merge the data
126 // Add or merge the data
130 // Inits the data series of the variable
131 impl->lockWrite();
127 impl->lockWrite();
132 if (!impl->m_DataSeries) {
128 if (!impl->m_DataSeries) {
133 impl->m_DataSeries = dataSeries->clone();
129 impl->m_DataSeries = dataSeries->clone();
@@ -135,13 +131,8 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
135 else {
131 else {
136 impl->m_DataSeries->merge(dataSeries.get());
132 impl->m_DataSeries->merge(dataSeries.get());
137 }
133 }
134 impl->purgeDataSeries();
138 impl->unlock();
135 impl->unlock();
139
140 // sub the data
141 auto subData = this->dataSeries()->subDataSeries(this->cacheRange());
142 qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries sub" << subData->range();
143 this->setDataSeries(subData);
144 qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries set" << this->dataSeries()->range();
145 }
136 }
146
137
147 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
138 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
General Comments 0
You need to be logged in to leave comments. Login now