IDataSeries.h
72 lines
| 2.0 KiB
| text/x-c
|
CLexer
Alexandre Leroux
|
r117 | #ifndef SCIQLOP_IDATASERIES_H | ||
#define SCIQLOP_IDATASERIES_H | ||||
Alexandre Leroux
|
r285 | #include <Common/MetaTypes.h> | ||
r510 | #include <Data/SqpRange.h> | |||
Alexandre Leroux
|
r117 | |||
#include <memory> | ||||
r217 | #include <QString> | |||
Alexandre Leroux
|
r117 | template <int Dim> | ||
class ArrayData; | ||||
Alexandre Leroux
|
r164 | struct Unit { | ||
explicit Unit(const QString &name = {}, bool timeUnit = false) | ||||
: m_Name{name}, m_TimeUnit{timeUnit} | ||||
{ | ||||
} | ||||
Alexandre Leroux
|
r365 | inline bool operator==(const Unit &other) const | ||
{ | ||||
return std::tie(m_Name, m_TimeUnit) == std::tie(other.m_Name, other.m_TimeUnit); | ||||
} | ||||
inline bool operator!=(const Unit &other) const { return !(*this == other); } | ||||
Alexandre Leroux
|
r164 | QString m_Name; ///< Unit name | ||
Alexandre Leroux
|
r453 | bool m_TimeUnit; ///< The unit is a unit of time (UTC) | ||
Alexandre Leroux
|
r164 | }; | ||
Alexandre Leroux
|
r117 | /** | ||
* @brief The IDataSeries aims to declare a data series. | ||||
* | ||||
* A data series is an entity that contains at least : | ||||
* - one dataset representing the x-axis | ||||
* - one dataset representing the values | ||||
* | ||||
* Each dataset is represented by an ArrayData, and is associated with a unit. | ||||
* | ||||
* An ArrayData can be unidimensional or two-dimensional, depending on the implementation of the | ||||
* IDataSeries. The x-axis dataset is always unidimensional. | ||||
* | ||||
* @sa ArrayData | ||||
*/ | ||||
class IDataSeries { | ||||
public: | ||||
virtual ~IDataSeries() noexcept = default; | ||||
/// Returns the x-axis dataset | ||||
virtual std::shared_ptr<ArrayData<1> > xAxisData() = 0; | ||||
Alexandre Leroux
|
r287 | /// Returns the x-axis dataset (as const) | ||
virtual const std::shared_ptr<ArrayData<1> > xAxisData() const = 0; | ||||
Alexandre Leroux
|
r164 | virtual Unit xAxisUnit() const = 0; | ||
Alexandre Leroux
|
r117 | |||
Alexandre Leroux
|
r164 | virtual Unit valuesUnit() const = 0; | ||
r217 | ||||
virtual void merge(IDataSeries *dataSeries) = 0; | ||||
r510 | virtual std::shared_ptr<IDataSeries> subData(const SqpRange &range) = 0; | |||
Alexandre Leroux
|
r287 | |||
virtual std::unique_ptr<IDataSeries> clone() const = 0; | ||||
r510 | virtual SqpRange range() const = 0; | |||
r336 | ||||
virtual void lockRead() = 0; | ||||
virtual void lockWrite() = 0; | ||||
virtual void unlock() = 0; | ||||
Alexandre Leroux
|
r117 | }; | ||
r217 | // Required for using shared_ptr in signals/slots | |||
Alexandre Leroux
|
r285 | SCIQLOP_REGISTER_META_TYPE(IDATASERIES_PTR_REGISTRY, std::shared_ptr<IDataSeries>) | ||
r217 | ||||
Alexandre Leroux
|
r117 | #endif // SCIQLOP_IDATASERIES_H | ||