From 4befaeeedf81b5a41badce4bdfbd945fc594a890 Mon Sep 17 00:00:00 2001 From: Abdoulbari Zakir Date: Thu, 31 Oct 2024 16:53:32 +0100 Subject: [PATCH] dirty --- src/api/API.cpp | 2 +- src/api/private/API.h | 2 +- .../file-tree-study-loader/FileTreeStudyLoader.cpp | 8 ++++---- .../antares/file-tree-study-loader/FileTreeStudyLoader.h | 4 +++- .../include/antares/study-loader/IStudyLoader.h | 2 +- src/tests/src/api_internal/test_api.cpp | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/api/API.cpp b/src/api/API.cpp index c1ba723925..158394c6c7 100644 --- a/src/api/API.cpp +++ b/src/api/API.cpp @@ -32,7 +32,7 @@ namespace Antares::API { -SimulationResults APIInternal::run(const IStudyLoader& study_loader) +SimulationResults APIInternal::run(IStudyLoader& study_loader) { try { diff --git a/src/api/private/API.h b/src/api/private/API.h index 91f8a4e2d3..3eea891c3e 100644 --- a/src/api/private/API.h +++ b/src/api/private/API.h @@ -46,7 +46,7 @@ class APIInternal * load the study that will be simulated. * @return SimulationResults object which contains the results of the simulation. */ - SimulationResults run(const IStudyLoader& study_loader); + SimulationResults run(IStudyLoader& study_loader); private: std::shared_ptr study_; diff --git a/src/libs/antares/file-tree-study-loader/FileTreeStudyLoader.cpp b/src/libs/antares/file-tree-study-loader/FileTreeStudyLoader.cpp index 7e9ce70c1d..5471b42dcd 100644 --- a/src/libs/antares/file-tree-study-loader/FileTreeStudyLoader.cpp +++ b/src/libs/antares/file-tree-study-loader/FileTreeStudyLoader.cpp @@ -31,17 +31,17 @@ namespace Antares FileTreeStudyLoader::FileTreeStudyLoader(std::filesystem::path study_path): study_path_{std::move(study_path)} { - study_path_c_str_ = study_path_.string().c_str(); + study_path_str_ = study_path_.string(); + argv_ = {"", study_path_str_.c_str(), "--parallel"}; } -std::unique_ptr FileTreeStudyLoader::load() const +std::unique_ptr FileTreeStudyLoader::load() { using namespace std::literals::string_literals; Antares::Solver::Application application; constexpr unsigned int argc = 3; - std::array argv{"", study_path_c_str_, "--parallel"}; - application.prepare(argc, argv.data()); + application.prepare(argc, argv_.data()); return application.acquireStudy(); } diff --git a/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h b/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h index ceb62d47a8..31e8897a6e 100644 --- a/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h +++ b/src/libs/antares/file-tree-study-loader/include/antares/file-tree-study-loader/FileTreeStudyLoader.h @@ -55,10 +55,12 @@ class FileTreeStudyLoader: public IStudyLoader * * @return std::shared_ptr A shared_ptr to the loaded Study object. */ - [[nodiscard]] std::unique_ptr load() const override; + [[nodiscard]] std::unique_ptr load() override; private: std::filesystem::path study_path_; + std::string study_path_str_ = ""; const char* study_path_c_str_ = nullptr; + std::vector argv_; }; } // namespace Antares diff --git a/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h b/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h index 7d6f25373b..4c8c694ac2 100644 --- a/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h +++ b/src/libs/antares/study-loader/include/antares/study-loader/IStudyLoader.h @@ -43,6 +43,6 @@ class IStudyLoader * @brief The load method is used to load a study. * @return A shared pointer to a Study object. */ - [[nodiscard]] virtual std::unique_ptr load() const = 0; + [[nodiscard]] virtual std::unique_ptr load() = 0; }; } // namespace Antares diff --git a/src/tests/src/api_internal/test_api.cpp b/src/tests/src/api_internal/test_api.cpp index d8b52d3332..e42d0a7b8b 100644 --- a/src/tests/src/api_internal/test_api.cpp +++ b/src/tests/src/api_internal/test_api.cpp @@ -37,7 +37,7 @@ class InMemoryStudyLoader: public Antares::IStudyLoader { } - [[nodiscard]] std::unique_ptr load() const override + [[nodiscard]] std::unique_ptr load() override { if (!success_) {