##// END OF EJS Templates
Calls purge() method when setting cache range or data series of a variable
Alexandre Leroux -
r630:0efbd3cc5e8d
parent child
Show More
@@ -57,7 +57,6 public:
57 57
58 58 QVector<SqpRange> provideNotInCacheRangeList(const SqpRange &range) const noexcept;
59 59 QVector<SqpRange> provideInCacheRangeList(const SqpRange &range) const noexcept;
60 void setDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
61 60 void mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept;
62 61
63 62 signals:
@@ -24,6 +24,14 struct Variable::VariablePrivate {
24 24 void lockWrite() { m_Lock.lockForWrite(); }
25 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 35 /// Updates real range according to current variable range and data series
28 36 void updateRealRange()
29 37 {
@@ -94,7 +102,10 SqpRange Variable::cacheRange() const noexcept
94 102 void Variable::setCacheRange(const SqpRange &cacheRange) noexcept
95 103 {
96 104 impl->lockWrite();
97 impl->m_CacheRange = cacheRange;
105 if (cacheRange != impl->m_CacheRange) {
106 impl->m_CacheRange = cacheRange;
107 impl->purgeDataSeries();
108 }
98 109 impl->unlock();
99 110 }
100 111
@@ -103,20 +114,6 SqpRange Variable::realRange() const noexcept
103 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 117 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
121 118 {
122 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 126 // Add or merge the data
130 // Inits the data series of the variable
131 127 impl->lockWrite();
132 128 if (!impl->m_DataSeries) {
133 129 impl->m_DataSeries = dataSeries->clone();
@@ -135,13 +131,8 void Variable::mergeDataSeries(std::shared_ptr<IDataSeries> dataSeries) noexcept
135 131 else {
136 132 impl->m_DataSeries->merge(dataSeries.get());
137 133 }
134 impl->purgeDataSeries();
138 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 138 std::shared_ptr<IDataSeries> Variable::dataSeries() const noexcept
General Comments 0
You need to be logged in to leave comments. Login now