Skip to content

Commit

Permalink
Move json reader where it is used (#948)
Browse files Browse the repository at this point in the history
Json reader is specifically made for and used by StudyUpdater

---------

Co-authored-by: Peter Mitri <[email protected]>
  • Loading branch information
JasonMarechal25 and pet-mit authored Nov 26, 2024
1 parent 2715a1f commit b714503
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 220 deletions.
1 change: 0 additions & 1 deletion src/cpp/helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ target_sources(helpers PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/ArchiveReader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ArchiveWriter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/FileInBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/JsonXpansionReader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/OptionsParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/AreaParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/helpers/AntaresArchiveUpdater.h
Expand Down
12 changes: 8 additions & 4 deletions src/cpp/study-updater/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
add_library(xpansion_study_updater_lib)
target_sources(xpansion_study_updater_lib PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/JsonXpansionReader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/LinkCapacitiesCSVWriter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StudyUpdateStrategy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/LinkParametersCSVOverwriter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StudyUpdateLinkCapacitiesStrategy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StudyUpdateLinkParameterStrategy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StudyUpdateRunner.cpp
${CMAKE_CURRENT_SOURCE_DIR}/LinkParametersCSVOverwriter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StudyUpdateStrategy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/StudyUpdater.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/LinkCapacitiesCSVWriter.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/StudyUpdateStrategy.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/LinkParametersCSVOverwriter.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/StudyUpdateLinkCapacitiesStrategy.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/StudyUpdateLinkParameterStrategy.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/StudyUpdateRunner.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/LinkParametersCSVOverwriter.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/StudyUpdateStrategy.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/study-updater/StudyUpdater.h
${CMAKE_CURRENT_SOURCE_DIR}/private/JsonXpansionReader.h
)

target_link_libraries(xpansion_study_updater_lib
Expand All @@ -29,6 +31,8 @@ target_link_libraries(xpansion_study_updater_lib
target_include_directories(xpansion_study_updater_lib
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/private>
)

add_library(${PROJECT_NAME}::xpansion_study_updater_lib ALIAS xpansion_study_updater_lib)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "antares-xpansion/helpers/JsonXpansionReader.h"
#include "JsonXpansionReader.h"

#include <json/json.h>

Expand Down
3 changes: 1 addition & 2 deletions src/cpp/study-updater/LinkParametersCSVOverwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

#include "antares-xpansion/study-updater/LinkParametersCSVOverwriter.h"

#include "antares-xpansion/helpers/JsonXpansionReader.h"
#include "JsonXpansionReader.h"
#include "antares-xpansion/lpnamer/problem_modifier/LinkdataRecord.h"
#include "antares-xpansion/study-updater/StudyUpdater.h"

bool LinkParametersCSVOverWriter::open(
const std::filesystem::path& linkdataFilename_l) {
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/study-updater/StudyUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <utility>

#include "antares-xpansion/helpers/JsonXpansionReader.h"
#include "JsonXpansionReader.h"
#include "antares-xpansion/study-updater/StudyUpdateLinkCapacitiesStrategy.h"
#include "antares-xpansion/study-updater/StudyUpdateLinkParameterStrategy.h"
#include "antares-xpansion/study-updater/StudyUpdateStrategy.h"
Expand Down
17 changes: 9 additions & 8 deletions tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ endif()
# --------------------------------------------------------------------------
# unit tests
# --------------------------------------------------------------------------
add_subdirectory(tests_utils)
add_subdirectory(solvers_interface)
add_subdirectory(logger)
add_subdirectory(json_output_writer)
add_subdirectory(benders)
add_subdirectory(full_run)
add_subdirectory(helpers)
add_subdirectory(json_output_writer)
add_subdirectory(logger)
add_subdirectory(lp_namer)
add_subdirectory(sensitivity)
add_subdirectory(outer_loop)
add_subdirectory(restart_benders)
add_subdirectory(sensitivity)
add_subdirectory(solvers_interface)
add_subdirectory(study_updater)
add_subdirectory(tests_utils)
add_subdirectory(zip_mps)
add_subdirectory(benders)
add_subdirectory(full_run)
add_subdirectory(outer_loop)
2 changes: 0 additions & 2 deletions tests/cpp/helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
add_executable (helpers_test
JsonXpansionReaderTest.cc
AntaresVersionProviderTest.cpp
OptionsParserTest.cpp)

Expand All @@ -18,7 +17,6 @@ target_link_libraries (helpers_test PRIVATE
antaresXpansion::lp_namer_model
antaresXpansion::lp_namer_input_reader
antaresXpansion::lp_namer_problem_modifier
${JSONCPP_LIB}
${PROJECT_NAME}::benders_sequential_core
)

Expand Down
201 changes: 0 additions & 201 deletions tests/cpp/helpers/JsonXpansionReaderTest.cc

This file was deleted.

21 changes: 21 additions & 0 deletions tests/cpp/study_updater/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
add_executable(study_updater_test)
target_sources(study_updater_test PRIVATE
JsonXpansionReaderTest.cc
)

# Get source dir to include private headers
# Better way would be to rework test and use StudyUpdater::update as entry point
get_target_property(STUDY_UPDATER_SOURCE_DIR ${PROJECT_NAME}::xpansion_study_updater_lib SOURCE_DIR)

target_include_directories(study_updater_test
PRIVATE
${STUDY_UPDATER_SOURCE_DIR}/private # for private headers
)

target_link_libraries(study_updater_test
PRIVATE
GTest::Main
${PROJECT_NAME}::xpansion_study_updater_lib
)
add_test(NAME study_updater_test COMMAND study_updater_test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
set_property(TEST study_updater_test PROPERTY LABELS unit)
Loading

0 comments on commit b714503

Please sign in to comment.