Fix osrm.hpp placement

This commit is contained in:
Patrick Niklaus 2015-12-15 19:25:26 +01:00
parent 1264983688
commit 9a332d2f86
7 changed files with 24 additions and 21 deletions

View File

@ -375,7 +375,7 @@ if(BUILD_TOOLS)
install(TARGETS osrm-springclean DESTINATION bin) install(TARGETS osrm-springclean DESTINATION bin)
endif() endif()
file(GLOB InstallGlob include/osrm/*.hpp library/osrm.hpp) file(GLOB InstallGlob include/osrm/*.hpp)
file(GLOB VariantGlob third_party/variant/*.hpp) file(GLOB VariantGlob third_party/variant/*.hpp)
# Add RPATH info to executables so that when they are run after being installed # Add RPATH info to executables so that when they are run after being installed

View File

@ -45,7 +45,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "typedefs.h" #include "typedefs.h"
#include <osrm/coordinate.hpp> #include <osrm/coordinate.hpp>
#include <osrm/server_paths.hpp>
using RTreeLeaf = BaseDataFacade<QueryEdge::EdgeData>::RTreeLeaf; using RTreeLeaf = BaseDataFacade<QueryEdge::EdgeData>::RTreeLeaf;
using RTreeNode = StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>::TreeNode; using RTreeNode = StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>::TreeNode;
@ -121,7 +120,7 @@ int main(const int argc, const char *argv[]) try
SimpleLogger().Write(logDEBUG) << "Checking input parameters"; SimpleLogger().Write(logDEBUG) << "Checking input parameters";
ServerPaths server_paths; std::unordered_map<std::string, boost::filesystem::path> server_paths;
if (!GenerateDataStoreOptions(argc, argv, server_paths)) if (!GenerateDataStoreOptions(argc, argv, server_paths))
{ {
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -160,7 +159,7 @@ int main(const int argc, const char *argv[]) try
throw osrm::exception("no core file found"); 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(server_paths.end() != paths_iterator);
BOOST_ASSERT(!paths_iterator->second.empty()); BOOST_ASSERT(!paths_iterator->second.empty());
const boost::filesystem::path &hsgr_path = paths_iterator->second; const boost::filesystem::path &hsgr_path = paths_iterator->second;

View File

@ -28,11 +28,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef OSRM_HPP #ifndef OSRM_HPP
#define OSRM_HPP #define OSRM_HPP
#include <osrm/libosrm_config.hpp>
#include <memory> #include <memory>
class OSRM_impl; class LibOSRMConfig;
struct RouteParameters; struct RouteParameters;
namespace osrm namespace osrm
@ -46,11 +44,12 @@ struct Object;
class OSRM class OSRM
{ {
private: private:
class OSRM_impl;
std::unique_ptr<OSRM_impl> OSRM_pimpl_; std::unique_ptr<OSRM_impl> OSRM_pimpl_;
public: public:
explicit OSRM(LibOSRMConfig lib_config); OSRM(LibOSRMConfig &lib_config);
~OSRM(); ~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); int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result);
}; };

View File

@ -34,7 +34,6 @@ class named_mutex;
} }
#include "osrm_impl.hpp" #include "osrm_impl.hpp"
#include "osrm.hpp"
#include "../plugins/distance_table.hpp" #include "../plugins/distance_table.hpp"
#include "../plugins/hello_world.hpp" #include "../plugins/hello_world.hpp"
@ -56,13 +55,15 @@ class named_mutex;
#include <boost/interprocess/sync/scoped_lock.hpp> #include <boost/interprocess/sync/scoped_lock.hpp>
#include <osrm/route_parameters.hpp> #include <osrm/route_parameters.hpp>
#include <osrm/libosrm_config.hpp>
#include <osrm/osrm.hpp>
#include <algorithm> #include <algorithm>
#include <fstream> #include <fstream>
#include <utility> #include <utility>
#include <vector> #include <vector>
OSRM_impl::OSRM_impl(LibOSRMConfig lib_config) OSRM::OSRM_impl::OSRM_impl(LibOSRMConfig& lib_config)
{ {
if (lib_config.use_shared_memory) if (lib_config.use_shared_memory)
{ {
@ -88,14 +89,14 @@ OSRM_impl::OSRM_impl(LibOSRMConfig lib_config)
RegisterPlugin(new RoundTripPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade)); RegisterPlugin(new RoundTripPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
} }
void OSRM_impl::RegisterPlugin(BasePlugin *raw_plugin_ptr) void OSRM::OSRM_impl::RegisterPlugin(BasePlugin *raw_plugin_ptr)
{ {
std::unique_ptr<BasePlugin> plugin_ptr(raw_plugin_ptr); std::unique_ptr<BasePlugin> plugin_ptr(raw_plugin_ptr);
SimpleLogger().Write() << "loaded plugin: " << plugin_ptr->GetDescriptor(); SimpleLogger().Write() << "loaded plugin: " << plugin_ptr->GetDescriptor();
plugin_map[plugin_ptr->GetDescriptor()] = std::move(plugin_ptr); 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); 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 // decrease number of concurrent queries
void OSRM_impl::decrease_concurrent_query_count() void OSRM::OSRM_impl::decrease_concurrent_query_count()
{ {
if (!barrier) if (!barrier)
{ {
@ -133,7 +134,7 @@ void OSRM_impl::decrease_concurrent_query_count()
} }
// increase number of concurrent queries // increase number of concurrent queries
void OSRM_impl::increase_concurrent_query_count() void OSRM::OSRM_impl::increase_concurrent_query_count()
{ {
if (!barrier) if (!barrier)
{ {
@ -159,9 +160,10 @@ void OSRM_impl::increase_concurrent_query_count()
} }
// proxy code for compilation firewall // proxy code for compilation firewall
OSRM::OSRM(LibOSRMConfig lib_config) : OSRM_pimpl_(osrm::make_unique<OSRM_impl>(std::move(lib_config))) {} OSRM::OSRM(LibOSRMConfig &lib_config) : OSRM_pimpl_(osrm::make_unique<OSRM_impl>(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) int OSRM::RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result)
{ {

View File

@ -35,6 +35,7 @@ struct RouteParameters;
#include <osrm/json_container.hpp> #include <osrm/json_container.hpp>
#include <osrm/libosrm_config.hpp> #include <osrm/libosrm_config.hpp>
#include <osrm/osrm.hpp>
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
@ -43,13 +44,13 @@ struct RouteParameters;
struct SharedBarriers; struct SharedBarriers;
template <class EdgeDataT> class BaseDataFacade; template <class EdgeDataT> class BaseDataFacade;
class OSRM_impl final class OSRM::OSRM_impl final
{ {
private: private:
using PluginMap = std::unordered_map<std::string, std::unique_ptr<BasePlugin>>; using PluginMap = std::unordered_map<std::string, std::unique_ptr<BasePlugin>>;
public: public:
OSRM_impl(LibOSRMConfig lib_config); OSRM_impl(LibOSRMConfig &lib_config);
OSRM_impl(const OSRM_impl &) = delete; OSRM_impl(const OSRM_impl &) = delete;
int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result); int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result);

View File

@ -25,12 +25,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "library/osrm.hpp"
#include "server/server.hpp" #include "server/server.hpp"
#include "util/version.hpp" #include "util/version.hpp"
#include "util/routed_options.hpp" #include "util/routed_options.hpp"
#include "util/simple_logger.hpp" #include "util/simple_logger.hpp"
#include <osrm/osrm.hpp>
#include <osrm/libosrm_config.hpp>
#ifdef __linux__ #ifdef __linux__
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif

View File

@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "http/reply.hpp" #include "http/reply.hpp"
#include "http/request.hpp" #include "http/request.hpp"
#include "../library/osrm.hpp"
#include "../util/json_renderer.hpp" #include "../util/json_renderer.hpp"
#include "../util/simple_logger.hpp" #include "../util/simple_logger.hpp"
#include "../util/string_util.hpp" #include "../util/string_util.hpp"
@ -40,6 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <osrm/route_parameters.hpp> #include <osrm/route_parameters.hpp>
#include <osrm/json_container.hpp> #include <osrm/json_container.hpp>
#include <osrm/osrm.hpp>
#include <ctime> #include <ctime>