diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b35091e0..008a947c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,8 +156,8 @@ add_executable(osrm-datastore src/tools/store.cpp $) add_library(osrm src/osrm/osrm.cpp $ $ $) add_library(osrm_contract src/osrm/contractor.cpp $ $) add_library(osrm_extract src/osrm/extractor.cpp $ $) -add_library(osrm_partition $ $) -add_library(osrm_customize $ $) +add_library(osrm_partition src/osrm/partitioner.cpp $ $) +add_library(osrm_customize src/osrm/customizer.cpp $ $) add_library(osrm_update $ $) add_library(osrm_store $ $) diff --git a/include/osrm/customizer.hpp b/include/osrm/customizer.hpp new file mode 100644 index 000000000..f086d2dce --- /dev/null +++ b/include/osrm/customizer.hpp @@ -0,0 +1,50 @@ +/* + +Copyright (c) 2017, Project OSRM contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef OSRM_CUSTOMIZER_HPP +#define OSRM_CUSTOMIZER_HPP + +namespace osrm +{ + +namespace customizer +{ +struct CustomizationConfig; +} // ns customizer + +/** + * Runs customize pipeline stage. + * + * \param config The user-provided customization configuration. + * \throws TODO + * \see Customizer, CustomizationConfig + */ +void customize(const customizer::CustomizationConfig &config); + +} // ns osrm + +#endif // OSRM_CUSTOMIZER_HPP diff --git a/include/osrm/customizer_config.hpp b/include/osrm/customizer_config.hpp new file mode 100644 index 000000000..ccd4e2b69 --- /dev/null +++ b/include/osrm/customizer_config.hpp @@ -0,0 +1,38 @@ +/* + +Copyright (c) 2017, Project OSRM contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef GLOBAL_CUSTOMIZER_CONFIG_HPP +#define GLOBAL_CUSTOMIZER_CONFIG_HPP + +#include "customizer/customizer_config.hpp" + +namespace osrm +{ +using customizer::CustomizationConfig; +} + +#endif diff --git a/include/osrm/partitioner.hpp b/include/osrm/partitioner.hpp new file mode 100644 index 000000000..429e4a588 --- /dev/null +++ b/include/osrm/partitioner.hpp @@ -0,0 +1,50 @@ +/* + +Copyright (c) 2017, Project OSRM contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef OSRM_PARTITIONER_HPP +#define OSRM_PARTITIONER_HPP + +namespace osrm +{ + +namespace partitioner +{ +struct PartitionerConfig; +} // ns partition + +/** + * Runs recursive partitioning process. + * + * \param config The user-provided partitioning configuration. + * \throws TODO + * \see Partitioner, PartitionerConfig + */ +void partition(const partitioner::PartitionerConfig &config); + +} // ns osrm + +#endif // OSRM_PARTITIONER_HPP diff --git a/include/osrm/partitioner_config.hpp b/include/osrm/partitioner_config.hpp new file mode 100644 index 000000000..d3883a692 --- /dev/null +++ b/include/osrm/partitioner_config.hpp @@ -0,0 +1,38 @@ +/* + +Copyright (c) 2017, Project OSRM contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this +list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef GLOBAL_PARTITION_CONFIG_HPP +#define GLOBAL_PARTITION_CONFIG_HPP + +#include "partitioner/partitioner_config.hpp" + +namespace osrm +{ +using ::osrm::partitioner::PartitionerConfig; +} + +#endif diff --git a/src/osrm/customizer.cpp b/src/osrm/customizer.cpp new file mode 100644 index 000000000..35563ecf4 --- /dev/null +++ b/src/osrm/customizer.cpp @@ -0,0 +1,12 @@ +#include "osrm/customizer.hpp" +#include "customizer/customizer.hpp" +#include "osrm/customizer_config.hpp" + +namespace osrm +{ + +// Pimpl-like facade + +void customize(const CustomizationConfig &config) { customizer::Customizer().Run(config); } + +} // ns osrm diff --git a/src/osrm/partitioner.cpp b/src/osrm/partitioner.cpp new file mode 100644 index 000000000..981902ccd --- /dev/null +++ b/src/osrm/partitioner.cpp @@ -0,0 +1,12 @@ +#include "osrm/partitioner.hpp" +#include "partitioner/partitioner.hpp" +#include "osrm/partitioner_config.hpp" + +namespace osrm +{ + +// Pimpl-like facade + +void partition(const PartitionerConfig &config) { partitioner::Partitioner().Run(config); } + +} // ns osrm diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index bb0f2f223..a152bdc6c 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -25,7 +25,11 @@ file(GLOB UpdaterTestsSources file(GLOB LibraryTestsSources library_tests.cpp library/*.cpp) -list(REMOVE_ITEM LibraryTestsSources ${CMAKE_CURRENT_SOURCE_DIR}/library/extract.cpp ${CMAKE_CURRENT_SOURCE_DIR}/library/contract.cpp) +list(REMOVE_ITEM LibraryTestsSources + ${CMAKE_CURRENT_SOURCE_DIR}/library/contract.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/library/customize.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/library/extract.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/library/partition.cpp) file(GLOB LibraryExtractTestsSources library_tests.cpp @@ -35,6 +39,14 @@ file(GLOB LibraryContractTestsSources library_tests.cpp library/contract.cpp) +file(GLOB LibraryCustomizeTestsSources + library_tests.cpp + library/customize.cpp) + +file(GLOB LibraryPartitionTestsSources + library_tests.cpp + library/partition.cpp) + file(GLOB ServerTestsSources server_tests.cpp server/*.cpp) @@ -85,6 +97,14 @@ add_executable(library-contract-tests EXCLUDE_FROM_ALL ${LibraryContractTestsSources}) +add_executable(library-customize-tests + EXCLUDE_FROM_ALL + ${LibraryCustomizeTestsSources}) + +add_executable(library-partition-tests + EXCLUDE_FROM_ALL + ${LibraryPartitionTestsSources}) + add_executable(server-tests EXCLUDE_FROM_ALL ${ServerTestsSources} @@ -112,6 +132,8 @@ target_compile_definitions(extractor-tests PRIVATE COMPILE_DEFINITIONS OSRM_FIXT target_compile_definitions(library-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}") target_compile_definitions(library-extract-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}") target_compile_definitions(library-contract-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}") +target_compile_definitions(library-customize-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}") +target_compile_definitions(library-partition-tests PRIVATE COMPILE_DEFINITIONS OSRM_TEST_DATA_DIR="${TEST_DATA_DIR}") target_compile_definitions(updater-tests PRIVATE COMPILE_DEFINITIONS TEST_DATA_DIR="${UPDATER_TEST_DATA_DIR}") target_compile_definitions(contractor-tests PRIVATE COMPILE_DEFINITIONS TEST_DATA_DIR="${TEST_DATA_DIR}") @@ -119,6 +141,8 @@ target_include_directories(engine-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(library-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(library-extract-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(library-contract-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(library-customize-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(library-partition-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(util-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(partitioner-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(customizer-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) @@ -133,9 +157,11 @@ target_link_libraries(updater-tests ${UPDATER_LIBRARIES} ${Boost_UNIT_TEST_FRAME target_link_libraries(library-tests osrm ${ENGINE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) target_link_libraries(library-extract-tests osrm_extract ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) target_link_libraries(library-contract-tests osrm_contract ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(library-customize-tests osrm_customize ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) +target_link_libraries(library-partition-tests osrm_partition ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) target_link_libraries(server-tests osrm ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) target_link_libraries(util-tests ${UTIL_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) target_link_libraries(contractor-tests ${CONTRACTOR_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) add_custom_target(tests - DEPENDS engine-tests extractor-tests contractor-tests partitioner-tests updater-tests customizer-tests library-tests library-extract-tests server-tests util-tests) + DEPENDS engine-tests extractor-tests contractor-tests partitioner-tests updater-tests customizer-tests library-tests library-extract-tests library-contract-tests library-customize-tests library-partition-tests server-tests util-tests) diff --git a/unit_tests/library/customize.cpp b/unit_tests/library/customize.cpp new file mode 100644 index 000000000..7facec56f --- /dev/null +++ b/unit_tests/library/customize.cpp @@ -0,0 +1,21 @@ +#include +#include + +#include "osrm/customizer.hpp" +#include "osrm/customizer_config.hpp" + +#include // default_num_threads + +BOOST_AUTO_TEST_SUITE(library_customize) + +BOOST_AUTO_TEST_CASE(test_customize_with_invalid_config) +{ + using namespace osrm; + + osrm::CustomizationConfig config; + config.requested_num_threads = tbb::task_scheduler_init::default_num_threads(); + BOOST_CHECK_THROW(osrm::customize(config), + std::exception); // including osrm::util::exception, etc. +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/library/partition.cpp b/unit_tests/library/partition.cpp new file mode 100644 index 000000000..b4911c76c --- /dev/null +++ b/unit_tests/library/partition.cpp @@ -0,0 +1,21 @@ +#include +#include + +#include "osrm/partitioner.hpp" +#include "osrm/partitioner_config.hpp" + +#include // default_num_threads + +BOOST_AUTO_TEST_SUITE(library_partition) + +BOOST_AUTO_TEST_CASE(test_partition_with_invalid_config) +{ + using namespace osrm; + + osrm::PartitionerConfig config; + config.requested_num_threads = tbb::task_scheduler_init::default_num_threads(); + BOOST_CHECK_THROW(osrm::partition(config), + std::exception); // including osrm::util::exception, etc. +} + +BOOST_AUTO_TEST_SUITE_END()