diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a926e530..b11eb6737 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -741,7 +741,7 @@ set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp inclu set(ExtractorHeader include/extractor/extractor.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp) set(PartitionerHeader include/partition/partitioner.hpp include/partition/partition_config.hpp) set(ContractorHeader include/contractor/contractor.hpp include/contractor/contractor_config.hpp) -set(StorageHeader include/storage/storage.hpp include/storage/storage_config.hpp) +set(StorageHeader include/storage/storage.hpp include/storage/io_config.hpp include/storage/storage_config.hpp) install(FILES ${EngineHeader} DESTINATION include/osrm/engine) install(FILES ${UtilHeader} DESTINATION include/osrm/util) install(FILES ${StorageHeader} DESTINATION include/osrm/storage) diff --git a/include/storage/io_config.hpp b/include/storage/io_config.hpp new file mode 100644 index 000000000..de518cb9f --- /dev/null +++ b/include/storage/io_config.hpp @@ -0,0 +1,77 @@ +#ifndef IO_CONFIG_HPP +#define IO_CONFIG_HPP + +#include + +namespace osrm +{ +namespace storage +{ +struct IOConfig +{ + IOConfig() = default; + + IOConfig(const boost::filesystem::path &base) : osrm_input_path(base) + { + UseDefaultOutputNames(); + } + + // Infer the output names from the path of the .osrm file + void UseDefaultOutputNames() + { + ram_index_path = {osrm_input_path.string() + ".ramIndex"}; + file_index_path = {osrm_input_path.string() + ".fileIndex"}; + hsgr_data_path = {osrm_input_path.string() + ".hsgr"}; + nodes_data_path = {osrm_input_path.string() + ".nodes"}; + edges_data_path = {osrm_input_path.string() + ".edges"}; + core_data_path = {osrm_input_path.string() + ".core"}; + geometries_path = {osrm_input_path.string() + ".geometry"}; + timestamp_path = {osrm_input_path.string() + ".timestamp"}; + turn_weight_penalties_path = {osrm_input_path.string() + ".turn_weight_penalties"}; + turn_duration_penalties_path = {osrm_input_path.string() + ".turn_duration_penalties"}; + turn_penalties_index_path = {osrm_input_path.string() + ".turn_penalties_index"}; + datasource_names_path = {osrm_input_path.string() + ".datasource_names"}; + names_data_path = {osrm_input_path.string() + ".names"}; + properties_path = {osrm_input_path.string() + ".properties"}; + intersection_class_path = {osrm_input_path.string() + ".icd"}; + turn_lane_data_path = {osrm_input_path.string() + ".tld"}; + turn_lane_description_path = {osrm_input_path.string() + ".tls"}; + mld_partition_path = {osrm_input_path.string() + ".partition"}; + mld_storage_path = {osrm_input_path.string() + ".cells"}; + mld_graph_path = {osrm_input_path.string() + ".mldgr"}; + level_path = {osrm_input_path.string() + ".level"}; + node_path = {osrm_input_path.string() + ".enw"}; + edge_based_graph_path = {osrm_input_path.string() + ".ebg"}; + } + + boost::filesystem::path osrm_input_path; + + boost::filesystem::path ram_index_path; + boost::filesystem::path file_index_path; + boost::filesystem::path hsgr_data_path; + boost::filesystem::path nodes_data_path; + boost::filesystem::path edges_data_path; + boost::filesystem::path core_data_path; + boost::filesystem::path geometries_path; + boost::filesystem::path timestamp_path; + boost::filesystem::path turn_weight_penalties_path; + boost::filesystem::path turn_duration_penalties_path; + boost::filesystem::path turn_penalties_index_path; + boost::filesystem::path datasource_names_path; + boost::filesystem::path datasource_indexes_path; + boost::filesystem::path names_data_path; + boost::filesystem::path properties_path; + boost::filesystem::path intersection_class_path; + boost::filesystem::path turn_lane_data_path; + boost::filesystem::path turn_lane_description_path; + boost::filesystem::path mld_partition_path; + boost::filesystem::path mld_storage_path; + boost::filesystem::path mld_graph_path; + boost::filesystem::path level_path; + boost::filesystem::path node_path; + boost::filesystem::path edge_based_graph_path; +}; +} +} + +#endif diff --git a/include/storage/storage_config.hpp b/include/storage/storage_config.hpp index 2841ec646..40e99f965 100644 --- a/include/storage/storage_config.hpp +++ b/include/storage/storage_config.hpp @@ -30,6 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include "storage/io_config.hpp" + namespace osrm { namespace storage @@ -40,7 +42,7 @@ namespace storage * * \see OSRM, EngineConfig */ -struct StorageConfig final +struct StorageConfig final : IOConfig { StorageConfig() = default; @@ -49,30 +51,8 @@ struct StorageConfig final * * \param base The base path (e.g. france.pbf.osrm) to derive auxiliary file suffixes from. */ - StorageConfig(const boost::filesystem::path &base); + StorageConfig(const boost::filesystem::path &base) : IOConfig(base) {} bool IsValid() const; - - boost::filesystem::path ram_index_path; - boost::filesystem::path file_index_path; - boost::filesystem::path hsgr_data_path; - boost::filesystem::path node_based_nodes_data_path; - boost::filesystem::path edge_based_nodes_data_path; - boost::filesystem::path edges_data_path; - boost::filesystem::path core_data_path; - boost::filesystem::path geometries_path; - boost::filesystem::path timestamp_path; - boost::filesystem::path turn_weight_penalties_path; - boost::filesystem::path turn_duration_penalties_path; - boost::filesystem::path datasource_names_path; - boost::filesystem::path datasource_indexes_path; - boost::filesystem::path names_data_path; - boost::filesystem::path properties_path; - boost::filesystem::path intersection_class_path; - boost::filesystem::path turn_lane_data_path; - boost::filesystem::path turn_lane_description_path; - boost::filesystem::path mld_partition_path; - boost::filesystem::path mld_storage_path; - boost::filesystem::path mld_graph_path; }; } } diff --git a/src/storage/storage_config.cpp b/src/storage/storage_config.cpp index a3051ca0a..d35be6291 100644 --- a/src/storage/storage_config.cpp +++ b/src/storage/storage_config.cpp @@ -24,24 +24,6 @@ bool CheckFileList(const std::vector &files) } } -StorageConfig::StorageConfig(const boost::filesystem::path &base) - : ram_index_path{base.string() + ".ramIndex"}, file_index_path{base.string() + ".fileIndex"}, - hsgr_data_path{base.string() + ".hsgr"}, - node_based_nodes_data_path{base.string() + ".nbg_nodes"}, - edge_based_nodes_data_path{base.string() + ".ebg_nodes"}, - edges_data_path{base.string() + ".edges"}, core_data_path{base.string() + ".core"}, - geometries_path{base.string() + ".geometry"}, timestamp_path{base.string() + ".timestamp"}, - turn_weight_penalties_path{base.string() + ".turn_weight_penalties"}, - turn_duration_penalties_path{base.string() + ".turn_duration_penalties"}, - datasource_names_path{base.string() + ".datasource_names"}, - names_data_path{base.string() + ".names"}, properties_path{base.string() + ".properties"}, - intersection_class_path{base.string() + ".icd"}, turn_lane_data_path{base.string() + ".tld"}, - turn_lane_description_path{base.string() + ".tls"}, - mld_partition_path{base.string() + ".partition"}, mld_storage_path{base.string() + ".cells"}, - mld_graph_path{base.string() + ".mldgr"} -{ -} - bool StorageConfig::IsValid() const { // Common files