##// END OF EJS Templates
Add merge API and implement it for the DataSeries
perrinel -
r233:508df86e5db1
parent child
Show More
@@ -49,6 +49,32 public:
49 return m_Data.at(0);
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 private:
78 private:
53 QVector<QVector<double> > m_Data;
79 QVector<QVector<double> > m_Data;
54 };
80 };
@@ -29,6 +29,15 public:
29 /// @sa IDataSeries::valuesUnit()
29 /// @sa IDataSeries::valuesUnit()
30 Unit valuesUnit() const override { return m_ValuesUnit; }
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 protected:
41 protected:
33 /// Protected ctor (DataSeries is abstract)
42 /// Protected ctor (DataSeries is abstract)
34 explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit,
43 explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit,
@@ -5,6 +5,8
5
5
6 #include <QObject>
6 #include <QObject>
7
7
8 #include <Data/SqpDateTime.h>
9
8 class DataProviderParameters;
10 class DataProviderParameters;
9 class IDataSeries;
11 class IDataSeries;
10
12
@@ -16,14 +18,21 class IDataSeries;
16 *
18 *
17 * @sa IDataSeries
19 * @sa IDataSeries
18 */
20 */
19 class IDataProvider {
21 class IDataProvider : public QObject {
22
23 Q_OBJECT
20 public:
24 public:
21 virtual ~IDataProvider() noexcept = default;
25 virtual ~IDataProvider() noexcept = default;
22
26
23 virtual std::unique_ptr<IDataSeries>
27 virtual std::unique_ptr<IDataSeries>
24 retrieveData(const DataProviderParameters &parameters) const = 0;
28 retrieveData(const DataProviderParameters &parameters) 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 // Required for using shared_ptr in signals/slots
36 // Required for using shared_ptr in signals/slots
28 Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>)
37 Q_DECLARE_METATYPE(std::shared_ptr<IDataProvider>)
29
38
@@ -1,10 +1,12
1 #ifndef SCIQLOP_IDATASERIES_H
1 #ifndef SCIQLOP_IDATASERIES_H
2 #define SCIQLOP_IDATASERIES_H
2 #define SCIQLOP_IDATASERIES_H
3
3
4 #include <QString>
5
4
6 #include <memory>
5 #include <memory>
7
6
7 #include <QObject>
8 #include <QString>
9
8 template <int Dim>
10 template <int Dim>
9 class ArrayData;
11 class ArrayData;
10
12
@@ -42,6 +44,11 public:
42 virtual Unit xAxisUnit() const = 0;
44 virtual Unit xAxisUnit() const = 0;
43
45
44 virtual Unit valuesUnit() const = 0;
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 #endif // SCIQLOP_IDATASERIES_H
54 #endif // SCIQLOP_IDATASERIES_H
General Comments 0
You need to be logged in to leave comments. Login now