Skip to content

Commit

Permalink
Move JsonReader to Study updater where it's used
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 committed Oct 14, 2024
1 parent 0a314fb commit e1557e7
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/cpp/helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ target_sources(helpers PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/ArchiveWriter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Clock.cpp
${CMAKE_CURRENT_SOURCE_DIR}/FileInBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/JsonXpansionReader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/OptionsParser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/helpers/AntaresArchiveUpdater.h
${CMAKE_CURRENT_SOURCE_DIR}/include/antares-xpansion/helpers/AntaresArchiveUpdaterExeOptions.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
1 change: 1 addition & 0 deletions tests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ add_subdirectory(zip_mps)
add_subdirectory(benders)
add_subdirectory(full_run)
add_subdirectory(outer_loop)
add_subdirectory(study_updater)
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
22 changes: 22 additions & 0 deletions tests/cpp/study_updater/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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
${PROJECT_NAME}::xpansion_study_updater_lib
${JSONCPP_LIB}
GTest::Main
)
add_test(NAME study_updater_test COMMAND study_updater_test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
set_property(TEST study_updater_test PROPERTY LABELS unit)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <fstream>
#include <sstream>

#include "antares-xpansion/helpers/JsonXpansionReader.h"
#include "JsonXpansionReader.h"
#include "gtest/gtest.h"

class JsonXpansionReaderTest : public ::testing::Test {
Expand Down

0 comments on commit e1557e7

Please sign in to comment.