diff --git a/.gitignore b/.gitignore index 2eb9ff0d..087e2175 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,7 @@ /.idea /src/schedule/cmake-*/* /src/schedule/.idea -/src/schedule/test/cmake-*/* +/test/test_schedule/cmake-*/* /.vscode /output /.vs/raptorxx/FileContentIndex diff --git a/CMakeLists.txt b/CMakeLists.txt index 39a7b1c5..417aed08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,13 +45,14 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/rel add_subdirectory(src/interfaces) add_subdirectory(src/logging) add_subdirectory(src/geometry) -add_subdirectory(src/geometry/test) add_subdirectory(src/schedule) -add_subdirectory(src/schedule/test) +add_subdirectory(test/test_schedule) add_subdirectory(src/schedule/benchmarks) add_subdirectory(src/raptor) -add_subdirectory(src/raptor/test) add_subdirectory(src/gtfsRaptorConfig) +# TESTS +add_subdirectory(test/test_raptor) +add_subdirectory(test/test_geometry) include(CTest) enable_testing() diff --git a/src/raptor/CMakeLists.txt b/src/raptor/CMakeLists.txt index 3e7ded57..ee492186 100644 --- a/src/raptor/CMakeLists.txt +++ b/src/raptor/CMakeLists.txt @@ -4,54 +4,8 @@ project("raptor" add_library(${PROJECT_NAME} SHARED) -target_sources(${PROJECT_NAME} PRIVATE - src/Leg.h - src/LegImpl.cpp - src/LegImpl.h - src/RaptorAlgorithmFactory.cpp - src/RaptorAlgorithmFactory.h - src/ConnectionImpl.cpp - src/ConnectionImpl.h - src/utils/RaptorData.cpp - src/utils/RaptorData.h - src/utils/RaptorDataBuilder.cpp - src/utils/RaptorDataBuilder.h - src/utils/RouteBuilder.cpp - src/RaptorRouter.cpp - src/RaptorRouter.h - src/Query.cpp - src/Query.h - src/utils/StopLabelsAndTimes.cpp - src/utils/StopLabelsAndTimes.h - src/FootpathRelaxer.cpp - src/FootpathRelaxer.h - src/RouteScanner.cpp - src/RouteScanner.h - src/QueryConfig.cpp - src/data/ActiveTrip.h - src/data/raptorRouteStructures.h - src/utils/RouteContainer.cpp - src/utils/RouteContainer.h - src/LabelPostprocessor.cpp - src/LabelPostprocessor.h - src/RaptorConnection.cpp - src/RaptorConnection.h - src/utils/LocalDateTime.cpp - src/utils/helperFunctions.h - PUBLIC - include/RaptorAlgorithm.h - include/config/QueryConfig.h - include/raptorTypes.h - include/IConnection.h - include/IRaptor.h - include/config/WalkingConfig.h - include/config/TransferConfig.h - include/usingTypes.h - include/config/TravelConfig.h - include/RouteBuilder.h - include/LocalDateTime.h - include/Connection.h -) +add_subdirectory(include) +add_subdirectory(src) target_include_directories(${PROJECT_NAME} PRIVATE diff --git a/src/raptor/include/CMakeLists.txt b/src/raptor/include/CMakeLists.txt new file mode 100644 index 00000000..0a3a7142 --- /dev/null +++ b/src/raptor/include/CMakeLists.txt @@ -0,0 +1,19 @@ +target_sources(${PROJECT_NAME} + PUBLIC + Connection.h + IConnection.h + IRaptor.h + LocalDateTime.h + RaptorAlgorithm.h + raptorRouteStructures.h + raptorTypes.h + RouteBuilder.h + usingTypes.h + RaptorDataBuilder.h + Leg.h + RaptorRouter.h + RaptorData.h + RouteContainer.h +) + +add_subdirectory(config) \ No newline at end of file diff --git a/src/raptor/src/Leg.h b/src/raptor/include/Leg.h similarity index 95% rename from src/raptor/src/Leg.h rename to src/raptor/include/Leg.h index 8553ac87..272c64c3 100644 --- a/src/raptor/src/Leg.h +++ b/src/raptor/include/Leg.h @@ -7,9 +7,11 @@ #include #include +#include + namespace raptor { - class Leg + class RAPTOR_API Leg { public: enum Type diff --git a/src/raptor/src/utils/RaptorData.h b/src/raptor/include/RaptorData.h similarity index 66% rename from src/raptor/src/utils/RaptorData.h rename to src/raptor/include/RaptorData.h index f40c2af5..0e875686 100644 --- a/src/raptor/src/utils/RaptorData.h +++ b/src/raptor/include/RaptorData.h @@ -4,19 +4,19 @@ #pragma once -#include +#include +#include namespace raptor { - class RaptorData - { + class RAPTOR_API RaptorData { StopRoutesIndexLookup lookup; StopContext stopContext; RouteTraversal routeTraversal; public: - explicit RaptorData(StopRoutesIndexLookup lookup, StopContext stopContext, RouteTraversal routeTraversal); + explicit RaptorData(StopRoutesIndexLookup lookup, StopContext stopContext, RouteTraversal routeTraversal); [[nodiscard]] const StopRoutesIndexLookup& getLookup() const; diff --git a/src/raptor/src/utils/RaptorDataBuilder.h b/src/raptor/include/RaptorDataBuilder.h similarity index 94% rename from src/raptor/src/utils/RaptorDataBuilder.h rename to src/raptor/include/RaptorDataBuilder.h index 96724e58..8234800f 100644 --- a/src/raptor/src/utils/RaptorDataBuilder.h +++ b/src/raptor/include/RaptorDataBuilder.h @@ -4,7 +4,7 @@ #pragma once -#include +#include "RaptorData.h" #include @@ -15,7 +15,6 @@ #include #include #include -// #include "RaptorAlgorithm.h" // Assuming RaptorAlgorithm is already converted to C++ namespace raptor { diff --git a/src/raptor/src/RaptorRouter.h b/src/raptor/include/RaptorRouter.h similarity index 98% rename from src/raptor/src/RaptorRouter.h rename to src/raptor/include/RaptorRouter.h index 841ce8ef..61658cbd 100644 --- a/src/raptor/src/RaptorRouter.h +++ b/src/raptor/include/RaptorRouter.h @@ -7,7 +7,7 @@ #include "config/QueryConfig.h" #include "RaptorAlgorithm.h" -#include "utils/RaptorData.h" +#include "RaptorData.h" #include #include diff --git a/src/raptor/include/RouteBuilder.h b/src/raptor/include/RouteBuilder.h index bafe2aef..c9d4e9e5 100644 --- a/src/raptor/include/RouteBuilder.h +++ b/src/raptor/include/RouteBuilder.h @@ -9,7 +9,7 @@ #include #include #include -#include "utils/RouteContainer.h" +#include "RouteContainer.h" #include diff --git a/src/raptor/src/utils/RouteContainer.h b/src/raptor/include/RouteContainer.h similarity index 88% rename from src/raptor/src/utils/RouteContainer.h rename to src/raptor/include/RouteContainer.h index 0b1ddbc2..62a29697 100644 --- a/src/raptor/src/utils/RouteContainer.h +++ b/src/raptor/include/RouteContainer.h @@ -4,17 +4,18 @@ #pragma once -#include "data/raptorRouteStructures.h" +#include "raptorRouteStructures.h" #include #include #include +#include namespace raptor { - class RouteContainer + class RAPTOR_API RouteContainer { public: RouteContainer(std::string id, const std::map& stopSequence, const std::map>& trips); diff --git a/src/raptor/include/config/CMakeLists.txt b/src/raptor/include/config/CMakeLists.txt new file mode 100644 index 00000000..1b456fc5 --- /dev/null +++ b/src/raptor/include/config/CMakeLists.txt @@ -0,0 +1,7 @@ +target_sources(${PROJECT_NAME} + PUBLIC + QueryConfig.h + TransferConfig.h + TravelConfig.h + WalkingConfig.h +) \ No newline at end of file diff --git a/src/raptor/src/data/raptorRouteStructures.h b/src/raptor/include/raptorRouteStructures.h similarity index 72% rename from src/raptor/src/data/raptorRouteStructures.h rename to src/raptor/include/raptorRouteStructures.h index 0eedea11..614516a4 100644 --- a/src/raptor/src/data/raptorRouteStructures.h +++ b/src/raptor/include/raptorRouteStructures.h @@ -10,10 +10,11 @@ #include #include #include +#include namespace raptor { - struct RouteStop + struct RAPTOR_API RouteStop { types::raptorIdx stopIndex; types::raptorIdx routeIndex; @@ -21,7 +22,7 @@ namespace raptor { ////////////////////////////////////////////////////////////////////////// - struct StopTime + struct RAPTOR_API StopTime { types::raptorInt arrival; types::raptorInt departure; @@ -29,31 +30,31 @@ namespace raptor { ////////////////////////////////////////////////////////////////////////// - struct Route + struct RAPTOR_API Route { std::string id; - types::raptorIdx firstRouteStopIndex; - types::raptorInt numberOfStops; - types::raptorIdx firstStopTimeIndex; - types::raptorInt numberOfTrips; + types::raptorIdx firstRouteStopIndex{}; + types::raptorInt numberOfStops{}; + types::raptorIdx firstStopTimeIndex{}; + types::raptorInt numberOfTrips{}; std::vector tripIds; }; ////////////////////////////////////////////////////////////////////////// - struct Stop + struct RAPTOR_API Stop { std::string id; - types::raptorIdx stopRouteIndex; - types::raptorInt numberOfRoutes; - types::raptorInt sameStopTransferTime; - int transferIndex; - types::raptorInt numberOfTransfers; + types::raptorIdx stopRouteIndex{}; + types::raptorInt numberOfRoutes{}; + types::raptorInt sameStopTransferTime{}; + int transferIndex{}; + types::raptorInt numberOfTransfers{}; }; ////////////////////////////////////////////////////////////////////////// - struct Transfer + struct RAPTOR_API Transfer { types::raptorIdx targetStopIndex; types::raptorInt duration; @@ -61,7 +62,7 @@ namespace raptor { ////////////////////////////////////////////////////////////////////////// - struct StopRoutesIndexLookup + struct RAPTOR_API StopRoutesIndexLookup { std::unordered_map stops; std::unordered_map routes; @@ -69,7 +70,7 @@ namespace raptor { ////////////////////////////////////////////////////////////////////////// - struct StopContext + struct RAPTOR_API StopContext { std::vector transfers; std::vector stops; @@ -78,7 +79,7 @@ namespace raptor { ////////////////////////////////////////////////////////////////////////// - struct RouteTraversal + struct RAPTOR_API RouteTraversal { std::vector routeStops; std::vector stopTimes; diff --git a/src/raptor/include/raptorTypes.h b/src/raptor/include/raptorTypes.h index 25167e45..e2826d13 100644 --- a/src/raptor/include/raptorTypes.h +++ b/src/raptor/include/raptorTypes.h @@ -7,6 +7,7 @@ #include #include +#include namespace raptor::utils { static constexpr auto INFINITY_VALUE = std::numeric_limits::max(); diff --git a/src/raptor/src/CMakeLists.txt b/src/raptor/src/CMakeLists.txt new file mode 100644 index 00000000..4db26e97 --- /dev/null +++ b/src/raptor/src/CMakeLists.txt @@ -0,0 +1,24 @@ +target_sources(${PROJECT_NAME} + PRIVATE + ConnectionImpl.cpp + ConnectionImpl.h + FootpathRelaxer.cpp + FootpathRelaxer.h + LabelPostprocessor.cpp + LabelPostprocessor.h + LegImpl.cpp + LegImpl.h + Query.cpp + Query.h + QueryConfig.cpp + RaptorAlgorithmFactory.cpp + RaptorAlgorithmFactory.h + RaptorConnection.cpp + RaptorConnection.h + RaptorRouter.cpp + RouteScanner.cpp + RouteScanner.h +) + +add_subdirectory(data) +add_subdirectory(utils) \ No newline at end of file diff --git a/src/raptor/src/FootpathRelaxer.h b/src/raptor/src/FootpathRelaxer.h index f8863236..591101cc 100644 --- a/src/raptor/src/FootpathRelaxer.h +++ b/src/raptor/src/FootpathRelaxer.h @@ -7,7 +7,7 @@ #include "utils/StopLabelsAndTimes.h" #include "usingTypes.h" -#include "utils/RaptorData.h" +#include "include/RaptorData.h" #include #include diff --git a/src/raptor/src/LabelPostprocessor.cpp b/src/raptor/src/LabelPostprocessor.cpp index d1a56abb..1725df4d 100644 --- a/src/raptor/src/LabelPostprocessor.cpp +++ b/src/raptor/src/LabelPostprocessor.cpp @@ -6,7 +6,7 @@ #include "LegImpl.h" #include "RaptorConnection.h" -#include "RaptorRouter.h" +#include "include/RaptorRouter.h" #include "RouteScanner.h" #include diff --git a/src/raptor/src/LabelPostprocessor.h b/src/raptor/src/LabelPostprocessor.h index 73418cf7..f5c7a295 100644 --- a/src/raptor/src/LabelPostprocessor.h +++ b/src/raptor/src/LabelPostprocessor.h @@ -6,7 +6,7 @@ #include "Connection.h" #include "RaptorConnection.h" -#include "data/raptorRouteStructures.h" +#include "include/raptorRouteStructures.h" #include "usingTypes.h" #include "utils/StopLabelsAndTimes.h" diff --git a/src/raptor/src/Query.h b/src/raptor/src/Query.h index 62d6d7e8..ffca5ba0 100644 --- a/src/raptor/src/Query.h +++ b/src/raptor/src/Query.h @@ -7,7 +7,7 @@ #include "config/QueryConfig.h" #include "utils/StopLabelsAndTimes.h" -#include "utils/RaptorData.h" +#include "include/RaptorData.h" #include #include diff --git a/src/raptor/src/RaptorConnection.h b/src/raptor/src/RaptorConnection.h index 027d1e55..16e4235e 100644 --- a/src/raptor/src/RaptorConnection.h +++ b/src/raptor/src/RaptorConnection.h @@ -4,7 +4,7 @@ #pragma once #include "Connection.h" -#include "Leg.h" +#include "include/Leg.h" #include "usingTypes.h" diff --git a/src/raptor/src/RouteScanner.h b/src/raptor/src/RouteScanner.h index ceaee8ca..fd5ed8df 100644 --- a/src/raptor/src/RouteScanner.h +++ b/src/raptor/src/RouteScanner.h @@ -7,7 +7,7 @@ #include "data/ActiveTrip.h" #include "utils/StopLabelsAndTimes.h" -#include "utils/RaptorData.h" +#include "include/RaptorData.h" #include #include @@ -23,7 +23,7 @@ namespace raptor { public: RouteScanner(StopLabelsAndTimes& stopLabelsAndTimes, const RaptorData& raptorData, types::raptorInt minimumTransferDuration); - std::unordered_set scan(types::raptorInt round, const std::unordered_set& markedStops) const; + [[nodiscard]] std::unordered_set scan(types::raptorInt round, const std::unordered_set& markedStops) const; private: [[nodiscard]] std::unordered_set getRoutesToScan(const std::unordered_set& markedStops) const; diff --git a/src/raptor/src/data/CMakeLists.txt b/src/raptor/src/data/CMakeLists.txt new file mode 100644 index 00000000..91b15e97 --- /dev/null +++ b/src/raptor/src/data/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(${PROJECT_NAME} + PRIVATE + ActiveTrip.h +) \ No newline at end of file diff --git a/src/raptor/src/utils/CMakeLists.txt b/src/raptor/src/utils/CMakeLists.txt new file mode 100644 index 00000000..7e8cf597 --- /dev/null +++ b/src/raptor/src/utils/CMakeLists.txt @@ -0,0 +1,11 @@ +target_sources(${PROJECT_NAME} + PRIVATE + helperFunctions.h + LocalDateTime.cpp + RaptorData.cpp + RaptorDataBuilder.cpp + RouteBuilder.cpp + RouteContainer.cpp + StopLabelsAndTimes.cpp + StopLabelsAndTimes.h +) \ No newline at end of file diff --git a/src/raptor/src/utils/RouteContainer.cpp b/src/raptor/src/utils/RouteContainer.cpp index 030757f7..5349278d 100644 --- a/src/raptor/src/utils/RouteContainer.cpp +++ b/src/raptor/src/utils/RouteContainer.cpp @@ -2,7 +2,7 @@ // Created by MichaelBrunner on 26/07/2024. // -#include "RouteContainer.h" +#include "include/RouteContainer.h" #include diff --git a/src/geometry/test/CMakeLists.txt b/test/test_geometry/CMakeLists.txt similarity index 100% rename from src/geometry/test/CMakeLists.txt rename to test/test_geometry/CMakeLists.txt diff --git a/src/geometry/test/test_kdTree.cpp b/test/test_geometry/test_kdTree.cpp similarity index 100% rename from src/geometry/test/test_kdTree.cpp rename to test/test_geometry/test_kdTree.cpp diff --git a/src/raptor/test/CMakeLists.txt b/test/test_raptor/CMakeLists.txt similarity index 69% rename from src/raptor/test/CMakeLists.txt rename to test/test_raptor/CMakeLists.txt index f8ec0391..138033bd 100644 --- a/src/raptor/test/CMakeLists.txt +++ b/test/test_raptor/CMakeLists.txt @@ -4,13 +4,7 @@ project("raptor_tests" add_executable(${PROJECT_NAME}) -target_sources(${PROJECT_NAME} PRIVATE - test_routeBuilder.cpp - test_raptorAlgorithm.cpp - RaptorRouterTestBuilder.h - RaptorRouterTestBuilder.cpp -) - +add_subdirectory(src) find_package(GTest CONFIG REQUIRED) find_package(spdlog CONFIG REQUIRED) @@ -27,9 +21,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE include(GoogleTest) gtest_discover_tests(${PROJECT_NAME}) -target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/src) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/logging/include) -target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/raptor/src) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/raptor/include) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/raptor/include/config) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src/schedule/include) diff --git a/test/test_raptor/src/CMakeLists.txt b/test/test_raptor/src/CMakeLists.txt new file mode 100644 index 00000000..2e2cdfc6 --- /dev/null +++ b/test/test_raptor/src/CMakeLists.txt @@ -0,0 +1,7 @@ +target_sources(${PROJECT_NAME} + PRIVATE + RaptorRouterTestBuilder.cpp + RaptorRouterTestBuilder.h + test_raptorAlgorithm.cpp + test_routeBuilder.cpp +) \ No newline at end of file diff --git a/src/raptor/test/RaptorRouterTestBuilder.cpp b/test/test_raptor/src/RaptorRouterTestBuilder.cpp similarity index 100% rename from src/raptor/test/RaptorRouterTestBuilder.cpp rename to test/test_raptor/src/RaptorRouterTestBuilder.cpp diff --git a/src/raptor/test/RaptorRouterTestBuilder.h b/test/test_raptor/src/RaptorRouterTestBuilder.h similarity index 98% rename from src/raptor/test/RaptorRouterTestBuilder.h rename to test/test_raptor/src/RaptorRouterTestBuilder.h index 0ce37881..5d585ea6 100644 --- a/src/raptor/test/RaptorRouterTestBuilder.h +++ b/test/test_raptor/src/RaptorRouterTestBuilder.h @@ -4,7 +4,7 @@ #pragma once -#include "utils/RaptorDataBuilder.h" +#include "RaptorDataBuilder.h" #include #include #include diff --git a/src/raptor/test/test_raptorAlgorithm.cpp b/test/test_raptor/src/test_raptorAlgorithm.cpp similarity index 100% rename from src/raptor/test/test_raptorAlgorithm.cpp rename to test/test_raptor/src/test_raptorAlgorithm.cpp diff --git a/src/raptor/test/test_routeBuilder.cpp b/test/test_raptor/src/test_routeBuilder.cpp similarity index 98% rename from src/raptor/test/test_routeBuilder.cpp rename to test/test_raptor/src/test_routeBuilder.cpp index 83257957..b8de160b 100644 --- a/src/raptor/test/test_routeBuilder.cpp +++ b/test/test_raptor/src/test_routeBuilder.cpp @@ -2,7 +2,8 @@ // Created by MichaelBrunner on 20/07/2024. // -#include "include/RouteBuilder.h" +#include +#include #include diff --git a/src/schedule/test/CMakeLists.txt b/test/test_schedule/CMakeLists.txt similarity index 87% rename from src/schedule/test/CMakeLists.txt rename to test/test_schedule/CMakeLists.txt index 0d9fb14a..e3456f86 100644 --- a/src/schedule/test/CMakeLists.txt +++ b/test/test_schedule/CMakeLists.txt @@ -39,12 +39,4 @@ set_target_properties(${PROJECT_NAME} PROPERTIES ) -message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}/src/schedule/test/test-data/") - -add_definitions(-DTEST_DATA_DIR="${CMAKE_SOURCE_DIR}/src/schedule/test/test-data/") - - - - - - +add_definitions(-DTEST_DATA_DIR="${CMAKE_SOURCE_DIR}/test/test_schedule/test-data/") \ No newline at end of file diff --git a/src/schedule/test/test-data/agency.txt b/test/test_schedule/test-data/agency.txt similarity index 100% rename from src/schedule/test/test-data/agency.txt rename to test/test_schedule/test-data/agency.txt diff --git a/src/schedule/test/test-data/calendar.txt b/test/test_schedule/test-data/calendar.txt similarity index 100% rename from src/schedule/test/test-data/calendar.txt rename to test/test_schedule/test-data/calendar.txt diff --git a/src/schedule/test/test-data/calendar_dates.txt b/test/test_schedule/test-data/calendar_dates.txt similarity index 100% rename from src/schedule/test/test-data/calendar_dates.txt rename to test/test_schedule/test-data/calendar_dates.txt diff --git a/src/schedule/test/test-data/routes.txt b/test/test_schedule/test-data/routes.txt similarity index 100% rename from src/schedule/test/test-data/routes.txt rename to test/test_schedule/test-data/routes.txt diff --git a/src/schedule/test/test-data/stop_times.txt b/test/test_schedule/test-data/stop_times.txt similarity index 100% rename from src/schedule/test/test-data/stop_times.txt rename to test/test_schedule/test-data/stop_times.txt diff --git a/src/schedule/test/test-data/stops.txt b/test/test_schedule/test-data/stops.txt similarity index 100% rename from src/schedule/test/test-data/stops.txt rename to test/test_schedule/test-data/stops.txt diff --git a/src/schedule/test/test-data/transfers.txt b/test/test_schedule/test-data/transfers.txt similarity index 100% rename from src/schedule/test/test-data/transfers.txt rename to test/test_schedule/test-data/transfers.txt diff --git a/src/schedule/test/test-data/trips.txt b/test/test_schedule/test-data/trips.txt similarity index 100% rename from src/schedule/test/test-data/trips.txt rename to test/test_schedule/test-data/trips.txt diff --git a/src/schedule/test/test_gtfsReaderCsv.cpp b/test/test_schedule/test_gtfsReaderCsv.cpp similarity index 100% rename from src/schedule/test/test_gtfsReaderCsv.cpp rename to test/test_schedule/test_gtfsReaderCsv.cpp diff --git a/src/schedule/test/test_gtfsReaderTxt.cpp b/test/test_schedule/test_gtfsReaderTxt.cpp similarity index 100% rename from src/schedule/test/test_gtfsReaderTxt.cpp rename to test/test_schedule/test_gtfsReaderTxt.cpp diff --git a/src/schedule/test/test_main.cpp b/test/test_schedule/test_main.cpp similarity index 100% rename from src/schedule/test/test_main.cpp rename to test/test_schedule/test_main.cpp