#ifndef SCIQLOP_VARIABLE_H #define SCIQLOP_VARIABLE_H #include #include #include #include #include #include "CoreGlobal.h" #include #include #include #include #include #include Q_DECLARE_LOGGING_CATEGORY(LOG_Variable) class IDataSeries; class QString; /** * @brief The Variable class represents a variable in SciQlop. */ class SCIQLOP_CORE_EXPORT Variable : public QObject { Q_OBJECT public: explicit Variable(const QString &name, const QVariantHash &metadata = {}); /// Copy ctor explicit Variable(const Variable &other); std::shared_ptr clone() const; QString name() const noexcept; void setName(const QString &name) noexcept; DateTimeRange range() const noexcept; void setRange(const DateTimeRange &range, bool notify=false) noexcept; DateTimeRange cacheRange() const noexcept; void setCacheRange(const DateTimeRange &cacheRange) noexcept; /// @return the number of points hold by the variable. The number of points is updated each time /// the data series changes unsigned 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 /// @return the real range, invalid range if the data series is null or empty /// @sa setDataSeries() /// @sa setRange() std::optional realRange() const noexcept; /// @return the data of the variable, nullptr if there is no data std::shared_ptr dataSeries() const noexcept; /// @return the type of data that the variable holds DataSeriesType type() const noexcept; QVariantHash metadata() const noexcept; void updateData(const std::vector& dataSeries, const DateTimeRange& newRange, const DateTimeRange& newCacheRange, bool notify=true); DEPRECATE( bool contains(const DateTimeRange &range) const noexcept; bool intersect(const DateTimeRange &range) const noexcept; bool isInside(const DateTimeRange &range) const noexcept; bool cacheContains(const DateTimeRange &range) const noexcept; bool cacheIntersect(const DateTimeRange &range) const noexcept; bool cacheIsInside(const DateTimeRange &range) const noexcept; QVector provideNotInCacheRangeList(const DateTimeRange &range) const noexcept; QVector provideInCacheRangeList(const DateTimeRange &range) const noexcept; void mergeDataSeries(std::shared_ptr dataSeries) noexcept; static QVector provideNotInCacheRangeList(const DateTimeRange &oldRange, const DateTimeRange &nextRange); static QVector provideInCacheRangeList(const DateTimeRange &oldRange, const DateTimeRange &nextRange); ) operator QUuid() {return _uuid;} QUuid ID(){return _uuid;} signals: void updated(); DEPRECATE( /// Signal emitted when when the data series of the variable is loaded for the first time void dataInitialized(); ) private: class VariablePrivate; spimpl::unique_impl_ptr impl; QUuid _uuid; QReadWriteLock m_lock; }; // Required for using shared_ptr in signals/slots SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_REGISTRY, std::shared_ptr) SCIQLOP_REGISTER_META_TYPE(VARIABLE_PTR_VECTOR_REGISTRY, QVector >) #endif // SCIQLOP_VARIABLE_H