diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h index 8c1d0bb..117dd08 100644 --- a/core/include/Variable/Variable.h +++ b/core/include/Variable/Variable.h @@ -57,7 +57,6 @@ public: QVector provideNotInCacheRangeList(const SqpRange &range) const noexcept; QVector provideInCacheRangeList(const SqpRange &range) const noexcept; - void setDataSeries(std::shared_ptr dataSeries) noexcept; void mergeDataSeries(std::shared_ptr dataSeries) noexcept; signals: diff --git a/core/src/Variable/Variable.cpp b/core/src/Variable/Variable.cpp index 554dcf3..960b3bf 100644 --- a/core/src/Variable/Variable.cpp +++ b/core/src/Variable/Variable.cpp @@ -24,6 +24,14 @@ struct Variable::VariablePrivate { void lockWrite() { m_Lock.lockForWrite(); } void unlock() { m_Lock.unlock(); } + void purgeDataSeries() + { + if (m_DataSeries) { + m_DataSeries->purge(m_CacheRange.m_TStart, m_CacheRange.m_TEnd); + } + updateRealRange(); + } + /// Updates real range according to current variable range and data series void updateRealRange() { @@ -94,7 +102,10 @@ SqpRange Variable::cacheRange() const noexcept void Variable::setCacheRange(const SqpRange &cacheRange) noexcept { impl->lockWrite(); - impl->m_CacheRange = cacheRange; + if (cacheRange != impl->m_CacheRange) { + impl->m_CacheRange = cacheRange; + impl->purgeDataSeries(); + } impl->unlock(); } @@ -103,20 +114,6 @@ SqpRange Variable::realRange() const noexcept return impl->m_RealRange; } -void Variable::setDataSeries(std::shared_ptr dataSeries) noexcept -{ - qCDebug(LOG_Variable()) << "TORM Variable::setDataSeries" - << QThread::currentThread()->objectName(); - if (!dataSeries) { - /// @todo ALX : log - return; - } - impl->lockWrite(); - impl->m_DataSeries = dataSeries->clone(); - impl->updateRealRange(); - impl->unlock(); -} - void Variable::mergeDataSeries(std::shared_ptr dataSeries) noexcept { qCDebug(LOG_Variable()) << "TORM Variable::mergeDataSeries" @@ -127,7 +124,6 @@ void Variable::mergeDataSeries(std::shared_ptr dataSeries) noexcept } // Add or merge the data - // Inits the data series of the variable impl->lockWrite(); if (!impl->m_DataSeries) { impl->m_DataSeries = dataSeries->clone(); @@ -135,13 +131,8 @@ void Variable::mergeDataSeries(std::shared_ptr dataSeries) noexcept else { impl->m_DataSeries->merge(dataSeries.get()); } + impl->purgeDataSeries(); impl->unlock(); - - // sub the data - auto subData = this->dataSeries()->subDataSeries(this->cacheRange()); - qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries sub" << subData->range(); - this->setDataSeries(subData); - qCDebug(LOG_Variable()) << "TORM: Variable::mergeDataSeries set" << this->dataSeries()->range(); } std::shared_ptr Variable::dataSeries() const noexcept