@@ -1,82 +1,82 | |||||
1 | #ifndef SCIQLOP_ARRAYDATA_H |
|
1 | #ifndef SCIQLOP_ARRAYDATA_H | |
2 | #define SCIQLOP_ARRAYDATA_H |
|
2 | #define SCIQLOP_ARRAYDATA_H | |
3 |
|
3 | |||
4 | #include <QVector> |
|
4 | #include <QVector> | |
5 |
|
5 | |||
6 | /** |
|
6 | /** | |
7 | * @brief The ArrayData class represents a dataset for a data series. |
|
7 | * @brief The ArrayData class represents a dataset for a data series. | |
8 | * |
|
8 | * | |
9 | * A dataset can be unidimensional or two-dimensional. This property is determined by the Dim |
|
9 | * A dataset can be unidimensional or two-dimensional. This property is determined by the Dim | |
10 | * template-parameter. |
|
10 | * template-parameter. | |
11 | * |
|
11 | * | |
12 | * @tparam Dim the dimension of the ArrayData (one or two) |
|
12 | * @tparam Dim the dimension of the ArrayData (one or two) | |
13 | * @sa IDataSeries |
|
13 | * @sa IDataSeries | |
14 | */ |
|
14 | */ | |
15 | template <int Dim> |
|
15 | template <int Dim> | |
16 | class ArrayData { |
|
16 | class ArrayData { | |
17 | public: |
|
17 | public: | |
18 | /** |
|
18 | /** | |
19 | * Ctor for a unidimensional ArrayData |
|
19 | * Ctor for a unidimensional ArrayData | |
20 | * @param nbColumns the number of values the ArrayData will hold |
|
20 | * @param nbColumns the number of values the ArrayData will hold | |
21 | */ |
|
21 | */ | |
22 | template <int D = Dim, typename = std::enable_if_t<D == 1> > |
|
22 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
23 | explicit ArrayData(int nbColumns) : m_Data{1, QVector<double>{}} |
|
23 | explicit ArrayData(int nbColumns) : m_Data{1, QVector<double>{}} | |
24 | { |
|
24 | { | |
25 | m_Data[0].resize(nbColumns); |
|
25 | m_Data[0].resize(nbColumns); | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | /** |
|
28 | /** | |
29 | * Sets a data at a specified index. The index has to be valid to be effective |
|
29 | * Sets a data at a specified index. The index has to be valid to be effective | |
30 | * @param index the index to which the data will be set |
|
30 | * @param index the index to which the data will be set | |
31 | * @param data the data to set |
|
31 | * @param data the data to set | |
32 | * @remarks this method is only available for a unidimensional ArrayData |
|
32 | * @remarks this method is only available for a unidimensional ArrayData | |
33 | */ |
|
33 | */ | |
34 | template <int D = Dim, typename = std::enable_if_t<D == 1> > |
|
34 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
35 | void setData(int index, double data) noexcept |
|
35 | void setData(int index, double data) noexcept | |
36 | { |
|
36 | { | |
37 | if (index >= 0 && index < m_Data.at(0).size()) { |
|
37 | if (index >= 0 && index < m_Data.at(0).size()) { | |
38 | m_Data[0].replace(index, data); |
|
38 | m_Data[0].replace(index, data); | |
39 | } |
|
39 | } | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | /** |
|
42 | /** | |
43 | * @return the data as a vector |
|
43 | * @return the data as a vector | |
44 | * @remarks this method is only available for a unidimensional ArrayData |
|
44 | * @remarks this method is only available for a unidimensional ArrayData | |
45 | */ |
|
45 | */ | |
46 | template <int D = Dim, typename = std::enable_if_t<D == 1> > |
|
46 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
47 | QVector<double> data() const noexcept |
|
47 | const QVector<double> &data() const noexcept | |
48 | { |
|
48 | { | |
49 |
return m_Data |
|
49 | return m_Data[0]; | |
50 | } |
|
50 | } | |
51 |
|
51 | |||
52 | /** |
|
52 | /** | |
53 | * @return the data as a vector |
|
53 | * @return the data as a vector | |
54 | * @remarks this method is only available for a unidimensional ArrayData |
|
54 | * @remarks this method is only available for a unidimensional ArrayData | |
55 | */ |
|
55 | */ | |
56 | template <int D = Dim, typename = std::enable_if_t<D == 1> > |
|
56 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
57 | const QVector<double> &data(double tStart, double tEnd) const noexcept |
|
57 | const QVector<double> &data(double tStart, double tEnd) const noexcept | |
58 | { |
|
58 | { | |
59 | return m_Data.at(tStart); |
|
59 | return m_Data.at(tStart); | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | // TODO Comment |
|
62 | // TODO Comment | |
63 | template <int D = Dim, typename = std::enable_if_t<D == 1> > |
|
63 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
64 |
void merge(ArrayData<1> |
|
64 | void merge(const ArrayData<1> &arrayData) | |
65 | { |
|
65 | { | |
66 | if (!m_Data.empty()) { |
|
66 | if (!m_Data.empty()) { | |
67 |
m_Data[0] += arrayData |
|
67 | m_Data[0] += arrayData.data(); | |
68 | } |
|
68 | } | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | template <int D = Dim, typename = std::enable_if_t<D == 1> > |
|
71 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
72 | int size() |
|
72 | int size() | |
73 | { |
|
73 | { | |
74 | return m_Data[0].size(); |
|
74 | return m_Data[0].size(); | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 |
|
77 | |||
78 | private: |
|
78 | private: | |
79 | QVector<QVector<double> > m_Data; |
|
79 | QVector<QVector<double> > m_Data; | |
80 | }; |
|
80 | }; | |
81 |
|
81 | |||
82 | #endif // SCIQLOP_ARRAYDATA_H |
|
82 | #endif // SCIQLOP_ARRAYDATA_H |
General Comments 0
You need to be logged in to leave comments.
Login now