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
-57
View File
@@ -1,57 +0,0 @@
/*
Copyright (c) 2015, 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_HPP
#define OSRM_HPP
#include <osrm/libosrm_config.hpp>
#include <memory>
class OSRM_impl;
struct RouteParameters;
namespace osrm
{
namespace json
{
struct Object;
}
}
class OSRM
{
private:
std::unique_ptr<OSRM_impl> OSRM_pimpl_;
public:
explicit OSRM(LibOSRMConfig lib_config);
~OSRM();
int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result);
};
#endif // OSRM_HPP
+10 -8
View File
@@ -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 <boost/interprocess/sync/scoped_lock.hpp>
#include <osrm/route_parameters.hpp>
#include <osrm/libosrm_config.hpp>
#include <osrm/osrm.hpp>
#include <algorithm>
#include <fstream>
#include <utility>
#include <vector>
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<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);
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<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)
{
+3 -2
View File
@@ -35,6 +35,7 @@ struct RouteParameters;
#include <osrm/json_container.hpp>
#include <osrm/libosrm_config.hpp>
#include <osrm/osrm.hpp>
#include <memory>
#include <unordered_map>
@@ -43,13 +44,13 @@ struct RouteParameters;
struct SharedBarriers;
template <class EdgeDataT> class BaseDataFacade;
class OSRM_impl final
class OSRM::OSRM_impl final
{
private:
using PluginMap = std::unordered_map<std::string, std::unique_ptr<BasePlugin>>;
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);