diff --git a/core/include/Data/ArrayData.h b/core/include/Data/ArrayData.h index 5be205f..c466119 100644 --- a/core/include/Data/ArrayData.h +++ b/core/include/Data/ArrayData.h @@ -44,9 +44,9 @@ public: * @remarks this method is only available for a unidimensional ArrayData */ template > - QVector data() const noexcept + const QVector &data() const noexcept { - return m_Data.at(0); + return m_Data[0]; } /** @@ -61,10 +61,10 @@ public: // TODO Comment template > - void merge(ArrayData<1> *arrayData) + void merge(const ArrayData<1> &arrayData) { if (!m_Data.empty()) { - m_Data[0] += arrayData->data(); + m_Data[0] += arrayData.data(); } } diff --git a/core/include/Data/DataSeries.h b/core/include/Data/DataSeries.h index 31825bd..46ee991 100644 --- a/core/include/Data/DataSeries.h +++ b/core/include/Data/DataSeries.h @@ -40,8 +40,8 @@ public: void merge(IDataSeries *dataSeries) override { if (auto dimDataSeries = dynamic_cast *>(dataSeries)) { - m_XAxisData->merge(dimDataSeries->xAxisData().get()); - m_ValuesData->merge(dimDataSeries->valuesData().get()); + m_XAxisData->merge(*dimDataSeries->xAxisData()); + m_ValuesData->merge(*dimDataSeries->valuesData()); } else { qCWarning(LOG_DataSeries()) diff --git a/core/include/Data/SqpDateTime.h b/core/include/Data/SqpDateTime.h index dc43dc1..c0f73c1 100644 --- a/core/include/Data/SqpDateTime.h +++ b/core/include/Data/SqpDateTime.h @@ -2,6 +2,10 @@ #define SCIQLOP_SQPDATETIME_H #include + +#include +#include + /** * @brief The SqpDateTime struct holds the information of time parameters */ @@ -22,6 +26,16 @@ struct SqpDateTime { } }; +inline QDebug operator<<(QDebug d, SqpDateTime obj) +{ + auto tendDateTimeStart = QDateTime::fromMSecsSinceEpoch(obj.m_TStart * 1000); + auto tendDateTimeEnd = QDateTime::fromMSecsSinceEpoch(obj.m_TEnd * 1000); + + // QDebug << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; + d << "ts: " << tendDateTimeStart << " te: " << tendDateTimeEnd; + return d; +} + // Required for using shared_ptr in signals/slots Q_DECLARE_METATYPE(SqpDateTime) diff --git a/core/include/Variable/Variable.h b/core/include/Variable/Variable.h index c6688c0..f654f78 100644 --- a/core/include/Variable/Variable.h +++ b/core/include/Variable/Variable.h @@ -42,7 +42,7 @@ public slots: void onAddDataSeries(std::shared_ptr dataSeries) noexcept; signals: - void dataCacheUpdated(); + void updated(); private: diff --git a/core/include/Variable/VariableCacheController.h b/core/include/Variable/VariableCacheController.h index 2fd48b2..dd7b988 100644 --- a/core/include/Variable/VariableCacheController.h +++ b/core/include/Variable/VariableCacheController.h @@ -5,10 +5,15 @@ #include +#include + #include class Variable; +Q_DECLARE_LOGGING_CATEGORY(LOG_VariableCacheController) + + /// This class aims to store in the cache all of the dateTime already requested to the variable. class VariableCacheController : public QObject { Q_OBJECT @@ -25,6 +30,8 @@ public: QVector dateCacheList(std::shared_ptr variable) const noexcept; + void displayCache(std::shared_ptr variable); + private: class VariableCacheControllerPrivate; spimpl::unique_impl_ptr impl; diff --git a/core/include/Variable/VariableController.h b/core/include/Variable/VariableController.h index 603c1e9..2da1749 100644 --- a/core/include/Variable/VariableController.h +++ b/core/include/Variable/VariableController.h @@ -30,14 +30,13 @@ public: void setTimeController(TimeController *timeController) noexcept; - /// Request the data loading of the variable whithin dateTime - void requestDataLoading(std::shared_ptr variable, const SqpDateTime &dateTime); - signals: /// Signal emitted when a variable has been created void variableCreated(std::shared_ptr variable); public slots: + /// Request the data loading of the variable whithin dateTime + void onRequestDataLoading(std::shared_ptr variable, const SqpDateTime &dateTime); /** * Creates a new variable and adds it to the model * @param name the name of the new variable diff --git a/core/src/Variable/Variable.cpp b/core/src/Variable/Variable.cpp index ff099c6..899ca31 100644 --- a/core/src/Variable/Variable.cpp +++ b/core/src/Variable/Variable.cpp @@ -67,7 +67,7 @@ void Variable::onAddDataSeries(std::shared_ptr dataSeries) noexcept if (impl->m_DataSeries) { impl->m_DataSeries->merge(dataSeries.get()); - emit dataCacheUpdated(); + emit updated(); } } diff --git a/core/src/Variable/VariableCacheController.cpp b/core/src/Variable/VariableCacheController.cpp index 34cb514..f151b4d 100644 --- a/core/src/Variable/VariableCacheController.cpp +++ b/core/src/Variable/VariableCacheController.cpp @@ -3,6 +3,8 @@ #include "Variable/Variable.h" #include +Q_LOGGING_CATEGORY(LOG_VariableCacheController, "VariableCacheController") + struct VariableCacheController::VariableCacheControllerPrivate { std::unordered_map, QVector > @@ -156,15 +158,26 @@ void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataBySt // ts localised between to interval: let's localized te addInCacheDataByEnd(dateTime, dateTimeList, notInCache, cacheIndex, currentTStart); } - else if (dateTime.m_TStart < currentDateTimeI.m_TEnd) { - // ts not localised before the current interval: we need to look at the next interval - // We can assume now current tstart is the last interval tend, because data between them are - // in the cache - addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex, - currentDateTimeI.m_TEnd); + else if (currentTStart < currentDateTimeI.m_TEnd) { + if (dateTime.m_TEnd > currentDateTimeI.m_TEnd) { + // ts not localised before the current interval: we need to look at the next interval + // We can assume now current tstart is the last interval tend, because data between them + // are + // in the cache + addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex, + currentDateTimeI.m_TEnd); + } } else { // ts not localised before the current interval: we need to look at the next interval addInCacheDataByStart(dateTime, dateTimeList, notInCache, ++cacheIndex, currentTStart); } } + + +void VariableCacheController::displayCache(std::shared_ptr variable) +{ + auto variableDateTimeList = impl->m_VariableToSqpDateTimeListMap.at(variable); + qCInfo(LOG_VariableCacheController()) << tr("VariableCacheController::displayCache") + << variableDateTimeList; +} diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index 90d1368..355cee0 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -9,7 +9,6 @@ #include