From 5292428caa59ccd230464bba350a527cc1ab0285 Mon Sep 17 00:00:00 2001 From: Abdoulbari Zakir Date: Mon, 1 Jul 2024 18:26:48 +0200 Subject: [PATCH] test --- .../hydro/management/HydroErrorsCollector.h | 12 +++------- .../hydro/management/HydroErrorsCollector.cpp | 22 +++++++++++-------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/solver/hydro/include/antares/solver/hydro/management/HydroErrorsCollector.h b/src/solver/hydro/include/antares/solver/hydro/management/HydroErrorsCollector.h index de46d98110..4ff8b4a842 100644 --- a/src/solver/hydro/include/antares/solver/hydro/management/HydroErrorsCollector.h +++ b/src/solver/hydro/include/antares/solver/hydro/management/HydroErrorsCollector.h @@ -30,12 +30,6 @@ namespace Antares class HydroErrorsCollector { public: - struct AreaSingleErrorMessage - { - std::string message = ""; - unsigned int message_number = 0; - }; - class AreaReference { public: @@ -44,7 +38,7 @@ class HydroErrorsCollector AreaReference& operator<<(const T& msg); private: - AreaSingleErrorMessage& areaSingleErrorMessage_; + std::string& areaSingleErrorMessage_; }; AreaReference operator()(const std::string& name); @@ -52,7 +46,7 @@ class HydroErrorsCollector void CheckForErrors() const; private: - std::multimap areasErrorMap_; + std::multimap areasErrorMap_; }; template @@ -60,7 +54,7 @@ HydroErrorsCollector::AreaReference& HydroErrorsCollector::AreaReference::operat { std::ostringstream strfy; strfy << msg; - areaSingleErrorMessage_.message += strfy.str(); + areaSingleErrorMessage_ += strfy.str(); return *this; } diff --git a/src/solver/hydro/management/HydroErrorsCollector.cpp b/src/solver/hydro/management/HydroErrorsCollector.cpp index 8864738fc4..9c3d445a11 100644 --- a/src/solver/hydro/management/HydroErrorsCollector.cpp +++ b/src/solver/hydro/management/HydroErrorsCollector.cpp @@ -1,5 +1,7 @@ #include "antares/solver/hydro/management/HydroErrorsCollector.h" +#include + #include #include "antares/antares/fatal-error.h" @@ -11,9 +13,17 @@ void HydroErrorsCollector::CheckForErrors() const { if (!areasErrorMap_.empty()) { - for (const auto& [area_name, area_msg]: areasErrorMap_) + for (const auto& key: areasErrorMap_ | std::views::keys) { - logs.error() << "In Area " << area_name << area_msg.message; + auto first_elements = areasErrorMap_ + | std::views::filter([&key](const auto& p) + { return p.first == key; }) + | std::views::take(10); + + for (const auto& value: first_elements) + { + logs.error() << "In Area " << value.first << ": " << value.second << " "; + } } throw FatalError("Hydro validation has failed !"); } @@ -21,13 +31,7 @@ void HydroErrorsCollector::CheckForErrors() const HydroErrorsCollector::AreaReference::AreaReference(HydroErrorsCollector* collector, const std::string& name): - areaSingleErrorMessage_( - collector->areasErrorMap_ - .insert( - - {name, - {.message = "", .message_number = (unsigned int)collector->areasErrorMap_.count(name)}}) - ->second) + areaSingleErrorMessage_(collector->areasErrorMap_.insert({name, ""})->second) { }