diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h index 5b731ab..eb9b144 100644 --- a/core/include/Variable/Variable.h +++ b/core/include/Variable/Variable.h @@ -40,6 +40,10 @@ public: SqpRange cacheRange() const noexcept; void setCacheRange(const SqpRange &cacheRange) noexcept; + /// @return the number of points hold by the variable. The number of points is updated each time + /// the data series changes + int nbPoints() const noexcept; + /// Returns the real range of the variable, i.e. the min and max x-axis values of the data /// series between the range of the variable. The real range is updated each time the variable /// range or the data series changed diff --git a/core/src/Variable/Variable.cpp b/core/src/Variable/Variable.cpp index 64874ba..ca1c3cb 100644 --- a/core/src/Variable/Variable.cpp +++ b/core/src/Variable/Variable.cpp @@ -16,7 +16,8 @@ struct Variable::VariablePrivate { m_Range{dateTime}, m_Metadata{metadata}, m_DataSeries{nullptr}, - m_RealRange{INVALID_RANGE} + m_RealRange{INVALID_RANGE}, + m_NbPoints{0} { } @@ -25,7 +26,8 @@ struct Variable::VariablePrivate { m_Range{other.m_Range}, m_Metadata{other.m_Metadata}, m_DataSeries{other.m_DataSeries != nullptr ? other.m_DataSeries->clone() : nullptr}, - m_RealRange{other.m_RealRange} + m_RealRange{other.m_RealRange}, + m_NbPoints{other.m_NbPoints} { } @@ -67,6 +69,7 @@ struct Variable::VariablePrivate { QVariantHash m_Metadata; std::shared_ptr m_DataSeries; SqpRange m_RealRange; + int m_NbPoints; QReadWriteLock m_Lock; }; @@ -135,6 +138,11 @@ void Variable::setCacheRange(const SqpRange &cacheRange) noexcept impl->unlock(); } +int Variable::nbPoints() const noexcept +{ + return impl->m_NbPoints; +} + SqpRange Variable::realRange() const noexcept { return impl->m_RealRange;