diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d001a40..c68188a95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -375,7 +375,7 @@ if(BUILD_TOOLS) install(TARGETS osrm-springclean DESTINATION bin) endif() -file(GLOB InstallGlob include/osrm/*.hpp library/osrm.hpp) +file(GLOB InstallGlob include/osrm/*.hpp) file(GLOB VariantGlob third_party/variant/*.hpp) # Add RPATH info to executables so that when they are run after being installed diff --git a/datastore.cpp b/datastore.cpp index 754901ca4..504dd3d44 100644 --- a/datastore.cpp +++ b/datastore.cpp @@ -45,7 +45,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "typedefs.h" #include -#include using RTreeLeaf = BaseDataFacade::RTreeLeaf; using RTreeNode = StaticRTree::vector, true>::TreeNode; @@ -121,7 +120,7 @@ int main(const int argc, const char *argv[]) try SimpleLogger().Write(logDEBUG) << "Checking input parameters"; - ServerPaths server_paths; + std::unordered_map server_paths; if (!GenerateDataStoreOptions(argc, argv, server_paths)) { return EXIT_SUCCESS; @@ -160,7 +159,7 @@ int main(const int argc, const char *argv[]) try throw osrm::exception("no core file found"); } - ServerPaths::const_iterator paths_iterator = server_paths.find("hsgrdata"); + auto paths_iterator = server_paths.find("hsgrdata"); BOOST_ASSERT(server_paths.end() != paths_iterator); BOOST_ASSERT(!paths_iterator->second.empty()); const boost::filesystem::path &hsgr_path = paths_iterator->second; diff --git a/library/osrm.hpp b/include/osrm/osrm.hpp similarity index 90% rename from library/osrm.hpp rename to include/osrm/osrm.hpp index 23053806e..091ae7c40 100644 --- a/library/osrm.hpp +++ b/include/osrm/osrm.hpp @@ -28,11 +28,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef OSRM_HPP #define OSRM_HPP -#include - #include -class OSRM_impl; +class LibOSRMConfig; struct RouteParameters; namespace osrm @@ -46,11 +44,12 @@ struct Object; class OSRM { private: + class OSRM_impl; std::unique_ptr OSRM_pimpl_; public: - explicit OSRM(LibOSRMConfig lib_config); - ~OSRM(); + OSRM(LibOSRMConfig &lib_config); + ~OSRM(); // needed because we need to define it with the implementation of OSRM_impl int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result); }; diff --git a/library/osrm_impl.cpp b/library/osrm_impl.cpp index a107650c6..cfc38e9ed 100644 --- a/library/osrm_impl.cpp +++ b/library/osrm_impl.cpp @@ -34,7 +34,6 @@ class named_mutex; } #include "osrm_impl.hpp" -#include "osrm.hpp" #include "../plugins/distance_table.hpp" #include "../plugins/hello_world.hpp" @@ -56,13 +55,15 @@ class named_mutex; #include #include +#include +#include #include #include #include #include -OSRM_impl::OSRM_impl(LibOSRMConfig lib_config) +OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig& lib_config) { if (lib_config.use_shared_memory) { @@ -88,14 +89,14 @@ OSRM_impl::OSRM_impl(LibOSRMConfig lib_config) RegisterPlugin(new RoundTripPlugin>(query_data_facade)); } -void OSRM_impl::RegisterPlugin(BasePlugin *raw_plugin_ptr) +void OSRM::OSRM_impl::RegisterPlugin(BasePlugin *raw_plugin_ptr) { std::unique_ptr plugin_ptr(raw_plugin_ptr); SimpleLogger().Write() << "loaded plugin: " << plugin_ptr->GetDescriptor(); plugin_map[plugin_ptr->GetDescriptor()] = std::move(plugin_ptr); } -int OSRM_impl::RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result) +int OSRM::OSRM_impl::RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result) { const auto &plugin_iterator = plugin_map.find(route_parameters.service); @@ -111,7 +112,7 @@ int OSRM_impl::RunQuery(const RouteParameters &route_parameters, osrm::json::Obj } // decrease number of concurrent queries -void OSRM_impl::decrease_concurrent_query_count() +void OSRM::OSRM_impl::decrease_concurrent_query_count() { if (!barrier) { @@ -133,7 +134,7 @@ void OSRM_impl::decrease_concurrent_query_count() } // increase number of concurrent queries -void OSRM_impl::increase_concurrent_query_count() +void OSRM::OSRM_impl::increase_concurrent_query_count() { if (!barrier) { @@ -159,9 +160,10 @@ void OSRM_impl::increase_concurrent_query_count() } // proxy code for compilation firewall -OSRM::OSRM(LibOSRMConfig lib_config) : OSRM_pimpl_(osrm::make_unique(std::move(lib_config))) {} +OSRM::OSRM(LibOSRMConfig &lib_config) : OSRM_pimpl_(osrm::make_unique(lib_config)) {} -OSRM::~OSRM() { OSRM_pimpl_.reset(); } +// needed because unique_ptr needs the size of OSRM_impl for delete +OSRM::~OSRM() {} int OSRM::RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result) { diff --git a/library/osrm_impl.hpp b/library/osrm_impl.hpp index 558f76f81..c223449e4 100644 --- a/library/osrm_impl.hpp +++ b/library/osrm_impl.hpp @@ -35,6 +35,7 @@ struct RouteParameters; #include #include +#include #include #include @@ -43,13 +44,13 @@ struct RouteParameters; struct SharedBarriers; template class BaseDataFacade; -class OSRM_impl final +class OSRM::OSRM_impl final { private: using PluginMap = std::unordered_map>; public: - OSRM_impl(LibOSRMConfig lib_config); + OSRM_impl(LibOSRMConfig &lib_config); OSRM_impl(const OSRM_impl &) = delete; int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result); diff --git a/routed.cpp b/routed.cpp index 725d44c9b..0a5b757cd 100644 --- a/routed.cpp +++ b/routed.cpp @@ -25,12 +25,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "library/osrm.hpp" #include "server/server.hpp" #include "util/version.hpp" #include "util/routed_options.hpp" #include "util/simple_logger.hpp" +#include +#include + #ifdef __linux__ #include #endif diff --git a/server/request_handler.cpp b/server/request_handler.cpp index a3af7f0b3..52833d0b6 100644 --- a/server/request_handler.cpp +++ b/server/request_handler.cpp @@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "http/reply.hpp" #include "http/request.hpp" -#include "../library/osrm.hpp" #include "../util/json_renderer.hpp" #include "../util/simple_logger.hpp" #include "../util/string_util.hpp" @@ -40,6 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include