##// END OF EJS Templates
Update DataSeries to make it compatible with the new arraydata
perrinel -
r295:93cf201f35ca
parent child
Show More
@@ -1,70 +1,70
1 1 #ifndef SCIQLOP_DATASERIES_H
2 2 #define SCIQLOP_DATASERIES_H
3 3
4 4 #include <Data/ArrayData.h>
5 5 #include <Data/IDataSeries.h>
6 6
7 7 #include <QLoggingCategory>
8 8
9 9 #include <memory>
10 10
11 11
12 12 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSeries)
13 13 Q_LOGGING_CATEGORY(LOG_DataSeries, "DataSeries")
14 14
15 15
16 16 /**
17 17 * @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
18 18 *
19 19 * It proposes to set a dimension for the values ​​data
20 20 *
21 21 * @tparam Dim The dimension of the values data
22 22 *
23 23 */
24 24 template <int Dim>
25 25 class DataSeries : public IDataSeries {
26 26 public:
27 27 /// @sa IDataSeries::xAxisData()
28 28 std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; }
29 29
30 30 /// @sa IDataSeries::xAxisUnit()
31 31 Unit xAxisUnit() const override { return m_XAxisUnit; }
32 32
33 33 /// @return the values dataset
34 34 std::shared_ptr<ArrayData<Dim> > valuesData() const { return m_ValuesData; }
35 35
36 36 /// @sa IDataSeries::valuesUnit()
37 37 Unit valuesUnit() const override { return m_ValuesUnit; }
38 38
39 39 /// @sa IDataSeries::merge()
40 40 void merge(IDataSeries *dataSeries) override
41 41 {
42 42 if (auto dimDataSeries = dynamic_cast<DataSeries<Dim> *>(dataSeries)) {
43 m_XAxisData->merge(dimDataSeries->xAxisData().get());
44 m_ValuesData->merge(dimDataSeries->valuesData().get());
43 m_XAxisData->merge(*dimDataSeries->xAxisData());
44 m_ValuesData->merge(*dimDataSeries->valuesData());
45 45 }
46 46 else {
47 47 qCWarning(LOG_DataSeries())
48 48 << QObject::tr("Dection of a type of IDataSeries we cannot merge with !");
49 49 }
50 50 }
51 51
52 52 protected:
53 53 /// Protected ctor (DataSeries is abstract)
54 54 explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit,
55 55 std::shared_ptr<ArrayData<Dim> > valuesData, const Unit &valuesUnit)
56 56 : m_XAxisData{xAxisData},
57 57 m_XAxisUnit{xAxisUnit},
58 58 m_ValuesData{valuesData},
59 59 m_ValuesUnit{valuesUnit}
60 60 {
61 61 }
62 62
63 63 private:
64 64 std::shared_ptr<ArrayData<1> > m_XAxisData;
65 65 Unit m_XAxisUnit;
66 66 std::shared_ptr<ArrayData<Dim> > m_ValuesData;
67 67 Unit m_ValuesUnit;
68 68 };
69 69
70 70 #endif // SCIQLOP_DATASERIES_H
General Comments 0
You need to be logged in to leave comments. Login now