From 462cefb59d8a428a2429f038f3d92a26e016d834 2017-06-30 10:08:36 From: mperrinel Date: 2017-06-30 10:08:36 Subject: [PATCH] Correction MR --- diff --git a/core/include/Variable/VariableCacheController.h b/core/include/Variable/VariableCacheController.h index dd7b988..57ef371 100644 --- a/core/include/Variable/VariableCacheController.h +++ b/core/include/Variable/VariableCacheController.h @@ -30,7 +30,7 @@ public: QVector dateCacheList(std::shared_ptr variable) const noexcept; - void displayCache(std::shared_ptr variable); + void displayCache(std::shared_ptr variable) const; private: class VariableCacheControllerPrivate; diff --git a/core/src/Variable/VariableCacheController.cpp b/core/src/Variable/VariableCacheController.cpp index f151b4d..8c22487 100644 --- a/core/src/Variable/VariableCacheController.cpp +++ b/core/src/Variable/VariableCacheController.cpp @@ -50,8 +50,13 @@ void VariableCacheController::addDateTime(std::shared_ptr variable, // will be compared to the next interval. The old one is remove from the list // C: if it is superior, we do the same with the next interval of the list - impl->addDateTimeRecurse(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable), - 0); + try { + impl->addDateTimeRecurse(dateTime, + impl->m_VariableToSqpDateTimeListMap.at(variable), 0); + } + catch (const std::out_of_range &e) { + qCInfo(LOG_VariableCacheController()) << e.what(); + } } } } @@ -67,8 +72,13 @@ VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr // We assume that the list is ordered in a way that l(0) < l(1). We assume also a < b // (with a & b of type SqpDateTime) means ts(b) > te(a) - impl->addInCacheDataByStart(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable), - notInCache, 0, dateTime.m_TStart); + try { + impl->addInCacheDataByStart(dateTime, impl->m_VariableToSqpDateTimeListMap.at(variable), + notInCache, 0, dateTime.m_TStart); + } + catch (const std::out_of_range &e) { + qCInfo(LOG_VariableCacheController()) << e.what(); + } return notInCache; } @@ -76,7 +86,13 @@ VariableCacheController::provideNotInCacheDateTimeList(std::shared_ptr QVector VariableCacheController::dateCacheList(std::shared_ptr variable) const noexcept { - return impl->m_VariableToSqpDateTimeListMap.at(variable); + try { + return impl->m_VariableToSqpDateTimeListMap.at(variable); + } + catch (const std::out_of_range &e) { + qCInfo(LOG_VariableCacheController()) << e.what(); + return QVector{}; + } } void VariableCacheController::VariableCacheControllerPrivate::addDateTimeRecurse( @@ -175,9 +191,15 @@ void VariableCacheController::VariableCacheControllerPrivate::addInCacheDataBySt } -void VariableCacheController::displayCache(std::shared_ptr variable) +void VariableCacheController::displayCache(std::shared_ptr variable) const { - auto variableDateTimeList = impl->m_VariableToSqpDateTimeListMap.at(variable); - qCInfo(LOG_VariableCacheController()) << tr("VariableCacheController::displayCache") - << variableDateTimeList; + auto variableDateTimeList = impl->m_VariableToSqpDateTimeListMap.find(variable); + if (variableDateTimeList != impl->m_VariableToSqpDateTimeListMap.end()) { + qCInfo(LOG_VariableCacheController()) << tr("VariableCacheController::displayCache") + << variableDateTimeList->second; + } + else { + qCWarning(LOG_VariableCacheController()) + << tr("Cannot display a variable that is not in the cache"); + } }