DataSeries.h
59 lines
| 1.7 KiB
| text/x-c
|
CLexer
|
r125 | #ifndef SCIQLOP_DATASERIES_H | ||
#define SCIQLOP_DATASERIES_H | ||||
#include <Data/ArrayData.h> | ||||
#include <Data/IDataSeries.h> | ||||
#include <memory> | ||||
/** | ||||
* @brief The DataSeries class is the base (abstract) implementation of IDataSeries. | ||||
* | ||||
* It proposes to set a dimension for the values data | ||||
* | ||||
* @tparam Dim The dimension of the values data | ||||
* | ||||
*/ | ||||
template <int Dim> | ||||
class DataSeries : public IDataSeries { | ||||
public: | ||||
/// @sa IDataSeries::xAxisData() | ||||
std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; } | ||||
/// @sa IDataSeries::xAxisUnit() | ||||
|
r177 | Unit xAxisUnit() const override { return m_XAxisUnit; } | ||
|
r125 | |||
/// @return the values dataset | ||||
std::shared_ptr<ArrayData<Dim> > valuesData() const { return m_ValuesData; } | ||||
/// @sa IDataSeries::valuesUnit() | ||||
|
r177 | Unit valuesUnit() const override { return m_ValuesUnit; } | ||
|
r125 | |||
r233 | /// @sa IDataSeries::merge() | |||
void merge(IDataSeries *dataSeries) override | ||||
{ | ||||
if (auto dimDataSeries = dynamic_cast<DataSeries<Dim> *>(dataSeries)) { | ||||
m_XAxisData->merge(dimDataSeries->xAxisData().get()); | ||||
m_ValuesData->merge(dimDataSeries->valuesData().get()); | ||||
} | ||||
} | ||||
|
r125 | protected: | ||
/// Protected ctor (DataSeries is abstract) | ||||
|
r188 | explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit, | ||
std::shared_ptr<ArrayData<Dim> > valuesData, const Unit &valuesUnit) | ||||
|
r125 | : m_XAxisData{xAxisData}, | ||
|
r188 | m_XAxisUnit{xAxisUnit}, | ||
|
r125 | m_ValuesData{valuesData}, | ||
|
r188 | m_ValuesUnit{valuesUnit} | ||
|
r125 | { | ||
} | ||||
private: | ||||
std::shared_ptr<ArrayData<1> > m_XAxisData; | ||||
|
r177 | Unit m_XAxisUnit; | ||
|
r125 | std::shared_ptr<ArrayData<Dim> > m_ValuesData; | ||
|
r177 | Unit m_ValuesUnit; | ||
|
r125 | }; | ||
#endif // SCIQLOP_DATASERIES_H | ||||