@@ -49,6 +49,32 public: | |||
|
49 | 49 | return m_Data.at(0); |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | /** | |
|
53 | * @return the data as a vector | |
|
54 | * @remarks this method is only available for a unidimensional ArrayData | |
|
55 | */ | |
|
56 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
|
57 | const QVector<double> &data(double tStart, double tEnd) const noexcept | |
|
58 | { | |
|
59 | return m_Data.at(tStart); | |
|
60 | } | |
|
61 | ||
|
62 | // TODO Comment | |
|
63 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
|
64 | void merge(ArrayData<1> *arrayData) | |
|
65 | { | |
|
66 | if (!m_Data.empty()) { | |
|
67 | m_Data[0] += arrayData->data(); | |
|
68 | } | |
|
69 | } | |
|
70 | ||
|
71 | template <int D = Dim, typename = std::enable_if_t<D == 1> > | |
|
72 | int size() | |
|
73 | { | |
|
74 | return m_Data[0].size(); | |
|
75 | } | |
|
76 | ||
|
77 | ||
|
52 | 78 | private: |
|
53 | 79 | QVector<QVector<double> > m_Data; |
|
54 | 80 | }; |
@@ -29,6 +29,15 public: | |||
|
29 | 29 | /// @sa IDataSeries::valuesUnit() |
|
30 | 30 | Unit valuesUnit() const override { return m_ValuesUnit; } |
|
31 | 31 | |
|
32 | /// @sa IDataSeries::merge() | |
|
33 | void merge(IDataSeries *dataSeries) override | |
|
34 | { | |
|
35 | if (auto dimDataSeries = dynamic_cast<DataSeries<Dim> *>(dataSeries)) { | |
|
36 | m_XAxisData->merge(dimDataSeries->xAxisData().get()); | |
|
37 | m_ValuesData->merge(dimDataSeries->valuesData().get()); | |
|
38 | } | |
|
39 | } | |
|
40 | ||
|
32 | 41 | protected: |
|
33 | 42 | /// Protected ctor (DataSeries is abstract) |
|
34 | 43 | explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit, |
@@ -5,6 +5,8 | |||
|
5 | 5 | |
|
6 | 6 | #include <QObject> |
|
7 | 7 | |
|
8 | #include <Data/SqpDateTime.h> | |
|
9 | ||
|
8 | 10 | class DataProviderParameters; |
|
9 | 11 | class IDataSeries; |
|
10 | 12 | |
@@ -16,14 +18,21 class IDataSeries; | |||
|
16 | 18 | * |
|
17 | 19 | * @sa IDataSeries |
|
18 | 20 | */ |
|
19 | class IDataProvider { | |
|
21 | class IDataProvider : public QObject { | |
|
22 | ||
|
23 | Q_OBJECT | |
|
20 | 24 | public: |
|
21 | 25 | virtual ~IDataProvider() noexcept = default; |
|
22 | 26 | |
|
23 | 27 | virtual std::unique_ptr<IDataSeries> |
|
24 | 28 | retrieveData(const DataProviderParameters ¶meters) const = 0; |
|
25 | }; | |
|
26 | 29 | |
|
30 | ||
|
31 | virtual void requestDataLoading(const QVector<SqpDateTime> &dateTimeList) = 0; | |
|
32 | ||
|
33 | signals: | |
|
34 | void dataProvided(std::shared_ptr<IDataSeries> dateSerie, SqpDateTime dateTime); | |
|
35 | }; | |
|
27 | 36 | // Required for using shared_ptr in signals/slots |
|
28 | 37 | Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>) |
|
29 | 38 |
@@ -1,10 +1,12 | |||
|
1 | 1 | #ifndef SCIQLOP_IDATASERIES_H |
|
2 | 2 | #define SCIQLOP_IDATASERIES_H |
|
3 | 3 | |
|
4 | #include <QString> | |
|
5 | 4 | |
|
6 | 5 | #include <memory> |
|
7 | 6 | |
|
7 | #include <QObject> | |
|
8 | #include <QString> | |
|
9 | ||
|
8 | 10 | template <int Dim> |
|
9 | 11 | class ArrayData; |
|
10 | 12 | |
@@ -42,6 +44,11 public: | |||
|
42 | 44 | virtual Unit xAxisUnit() const = 0; |
|
43 | 45 | |
|
44 | 46 | virtual Unit valuesUnit() const = 0; |
|
47 | ||
|
48 | virtual void merge(IDataSeries *dataSeries) = 0; | |
|
45 | 49 | }; |
|
46 | 50 | |
|
51 | // Required for using shared_ptr in signals/slots | |
|
52 | Q_DECLARE_METATYPE(std::shared_ptr<IDataSeries>) | |
|
53 | ||
|
47 | 54 | #endif // SCIQLOP_IDATASERIES_H |
General Comments 0
You need to be logged in to leave comments.
Login now