From 508df86e5db16f17c2c6517ce71cf40bb5a69bb3 2017-06-23 14:26:20 From: mperrinel Date: 2017-06-23 14:26:20 Subject: [PATCH] Add merge API and implement it for the DataSeries --- diff --git a/core/include/Data/ArrayData.h b/core/include/Data/ArrayData.h index b08f0c2..5be205f 100644 --- a/core/include/Data/ArrayData.h +++ b/core/include/Data/ArrayData.h @@ -49,6 +49,32 @@ public: return m_Data.at(0); } + /** + * @return the data as a vector + * @remarks this method is only available for a unidimensional ArrayData + */ + template > + const QVector &data(double tStart, double tEnd) const noexcept + { + return m_Data.at(tStart); + } + + // TODO Comment + template > + void merge(ArrayData<1> *arrayData) + { + if (!m_Data.empty()) { + m_Data[0] += arrayData->data(); + } + } + + template > + int size() + { + return m_Data[0].size(); + } + + private: QVector > m_Data; }; diff --git a/core/include/Data/DataSeries.h b/core/include/Data/DataSeries.h index f9de7dc..6232a63 100644 --- a/core/include/Data/DataSeries.h +++ b/core/include/Data/DataSeries.h @@ -29,6 +29,15 @@ public: /// @sa IDataSeries::valuesUnit() Unit valuesUnit() const override { return m_ValuesUnit; } + /// @sa IDataSeries::merge() + void merge(IDataSeries *dataSeries) override + { + if (auto dimDataSeries = dynamic_cast *>(dataSeries)) { + m_XAxisData->merge(dimDataSeries->xAxisData().get()); + m_ValuesData->merge(dimDataSeries->valuesData().get()); + } + } + protected: /// Protected ctor (DataSeries is abstract) explicit DataSeries(std::shared_ptr > xAxisData, const Unit &xAxisUnit, diff --git a/core/include/Data/IDataProvider.h b/core/include/Data/IDataProvider.h index 628d123..5d025cf 100644 --- a/core/include/Data/IDataProvider.h +++ b/core/include/Data/IDataProvider.h @@ -5,6 +5,8 @@ #include +#include + class DataProviderParameters; class IDataSeries; @@ -16,14 +18,21 @@ class IDataSeries; * * @sa IDataSeries */ -class IDataProvider { +class IDataProvider : public QObject { + + Q_OBJECT public: virtual ~IDataProvider() noexcept = default; virtual std::unique_ptr retrieveData(const DataProviderParameters ¶meters) const = 0; -}; + + virtual void requestDataLoading(const QVector &dateTimeList) = 0; + +signals: + void dataProvided(std::shared_ptr dateSerie, SqpDateTime dateTime); +}; // Required for using shared_ptr in signals/slots Q_DECLARE_METATYPE(std::shared_ptr) diff --git a/core/include/Data/IDataSeries.h b/core/include/Data/IDataSeries.h index 26a80a1..bbea31f 100644 --- a/core/include/Data/IDataSeries.h +++ b/core/include/Data/IDataSeries.h @@ -1,10 +1,12 @@ #ifndef SCIQLOP_IDATASERIES_H #define SCIQLOP_IDATASERIES_H -#include #include +#include +#include + template class ArrayData; @@ -42,6 +44,11 @@ public: virtual Unit xAxisUnit() const = 0; virtual Unit valuesUnit() const = 0; + + virtual void merge(IDataSeries *dataSeries) = 0; }; +// Required for using shared_ptr in signals/slots +Q_DECLARE_METATYPE(std::shared_ptr) + #endif // SCIQLOP_IDATASERIES_H