renamed: Include/osrm/ServerConfig.h -> Include/osrm/libosrm_config.hpp
pass lib config object by reference
This commit is contained in:
parent
48b131eb5c
commit
c6bb7c5993
@ -30,14 +30,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <osrm/server_paths.hpp>
|
#include <osrm/server_paths.hpp>
|
||||||
|
|
||||||
struct ServerConfig
|
struct libosrm_config
|
||||||
{
|
{
|
||||||
ServerConfig()
|
libosrm_config(const libosrm_config&) = delete;
|
||||||
|
libosrm_config()
|
||||||
: max_locations_distance_table(100)
|
: max_locations_distance_table(100)
|
||||||
, use_shared_memory(false)
|
, use_shared_memory(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ServerConfig(const ServerPaths &paths, const bool flag, const int max)
|
libosrm_config(const ServerPaths &paths, const bool flag, const int max)
|
||||||
: server_paths(paths)
|
: server_paths(paths)
|
||||||
, max_locations_distance_table(max)
|
, max_locations_distance_table(max)
|
||||||
, use_shared_memory(flag)
|
, use_shared_memory(flag)
|
@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef OSRM_H
|
#ifndef OSRM_H
|
||||||
#define OSRM_H
|
#define OSRM_H
|
||||||
|
|
||||||
#include <osrm/ServerConfig.h>
|
#include <osrm/libosrm_config.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ class OSRM
|
|||||||
std::unique_ptr<OSRM_impl> OSRM_pimpl_;
|
std::unique_ptr<OSRM_impl> OSRM_pimpl_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OSRM(ServerConfig serverConfig);
|
explicit OSRM(libosrm_config &lib_config);
|
||||||
~OSRM();
|
~OSRM();
|
||||||
int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result);
|
int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result);
|
||||||
};
|
};
|
||||||
|
@ -55,9 +55,9 @@ namespace boost { namespace interprocess { class named_mutex; } }
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
OSRM_impl::OSRM_impl(ServerConfig &serverConfig)
|
OSRM_impl::OSRM_impl(libosrm_config &lib_config)
|
||||||
{
|
{
|
||||||
if (serverConfig.use_shared_memory)
|
if (lib_config.use_shared_memory)
|
||||||
{
|
{
|
||||||
barrier = osrm::make_unique<SharedBarriers>();
|
barrier = osrm::make_unique<SharedBarriers>();
|
||||||
query_data_facade = new SharedDataFacade<QueryEdge::EdgeData>();
|
query_data_facade = new SharedDataFacade<QueryEdge::EdgeData>();
|
||||||
@ -65,13 +65,13 @@ OSRM_impl::OSRM_impl(ServerConfig &serverConfig)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// populate base path
|
// populate base path
|
||||||
populate_base_path(serverConfig.server_paths);
|
populate_base_path(lib_config.server_paths);
|
||||||
query_data_facade = new InternalDataFacade<QueryEdge::EdgeData>(serverConfig.server_paths);
|
query_data_facade = new InternalDataFacade<QueryEdge::EdgeData>(lib_config.server_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following plugins handle all requests.
|
// The following plugins handle all requests.
|
||||||
RegisterPlugin(new DistanceTablePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade,
|
RegisterPlugin(new DistanceTablePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade,
|
||||||
serverConfig.max_locations_distance_table));
|
lib_config.max_locations_distance_table));
|
||||||
RegisterPlugin(new HelloWorldPlugin());
|
RegisterPlugin(new HelloWorldPlugin());
|
||||||
RegisterPlugin(new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new LocatePlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
RegisterPlugin(new NearestPlugin<BaseDataFacade<QueryEdge::EdgeData>>(query_data_facade));
|
||||||
@ -151,8 +151,8 @@ int OSRM_impl::RunQuery(RouteParameters &route_parameters, JSON::Object &json_re
|
|||||||
|
|
||||||
// proxy code for compilation firewall
|
// proxy code for compilation firewall
|
||||||
|
|
||||||
OSRM::OSRM(ServerConfig server_config)
|
OSRM::OSRM(libosrm_config &lib_config)
|
||||||
: OSRM_pimpl_(osrm::make_unique<OSRM_impl>(server_config))
|
: OSRM_pimpl_(osrm::make_unique<OSRM_impl>(lib_config))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ struct RouteParameters;
|
|||||||
#include "../data_structures/query_edge.hpp"
|
#include "../data_structures/query_edge.hpp"
|
||||||
|
|
||||||
#include <osrm/json_container.hpp>
|
#include <osrm/json_container.hpp>
|
||||||
#include <osrm/ServerConfig.h>
|
#include <osrm/libosrm_config.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -50,7 +50,7 @@ class OSRM_impl
|
|||||||
using PluginMap = std::unordered_map<std::string, BasePlugin *>;
|
using PluginMap = std::unordered_map<std::string, BasePlugin *>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSRM_impl(ServerConfig &serverConfig);
|
OSRM_impl(libosrm_config &lib_config);
|
||||||
OSRM_impl(const OSRM_impl &) = delete;
|
OSRM_impl(const OSRM_impl &) = delete;
|
||||||
virtual ~OSRM_impl();
|
virtual ~OSRM_impl();
|
||||||
int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result);
|
int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result);
|
||||||
|
17
routed.cpp
17
routed.cpp
@ -69,21 +69,21 @@ int main(int argc, const char *argv[])
|
|||||||
{
|
{
|
||||||
LogPolicy::GetInstance().Unmute();
|
LogPolicy::GetInstance().Unmute();
|
||||||
|
|
||||||
bool use_shared_memory = false, trial_run = false;
|
bool trial_run = false;
|
||||||
std::string ip_address;
|
std::string ip_address;
|
||||||
int ip_port, requested_thread_num, max_locations_distance_table;
|
int ip_port, requested_thread_num;
|
||||||
|
|
||||||
ServerPaths server_paths;
|
libosrm_config lib_config;
|
||||||
|
|
||||||
const unsigned init_result = GenerateServerProgramOptions(argc,
|
const unsigned init_result = GenerateServerProgramOptions(argc,
|
||||||
argv,
|
argv,
|
||||||
server_paths,
|
lib_config.server_paths,
|
||||||
ip_address,
|
ip_address,
|
||||||
ip_port,
|
ip_port,
|
||||||
requested_thread_num,
|
requested_thread_num,
|
||||||
use_shared_memory,
|
lib_config.use_shared_memory,
|
||||||
trial_run,
|
trial_run,
|
||||||
max_locations_distance_table);
|
lib_config.max_locations_distance_table);
|
||||||
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
|
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -102,7 +102,7 @@ int main(int argc, const char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION;
|
SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION;
|
||||||
|
|
||||||
if (use_shared_memory)
|
if (lib_config.use_shared_memory)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "Loading from shared memory";
|
SimpleLogger().Write(logDEBUG) << "Loading from shared memory";
|
||||||
}
|
}
|
||||||
@ -118,8 +118,7 @@ int main(int argc, const char *argv[])
|
|||||||
pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask);
|
pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ServerConfig server_config(server_paths, use_shared_memory, max_locations_distance_table);
|
OSRM osrm_lib(lib_config);
|
||||||
OSRM osrm_lib(server_config);
|
|
||||||
auto routing_server =
|
auto routing_server =
|
||||||
Server::CreateServer(ip_address, ip_port, requested_thread_num);
|
Server::CreateServer(ip_address, ip_port, requested_thread_num);
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "../Util/simple_logger.hpp"
|
#include "../Util/simple_logger.hpp"
|
||||||
|
|
||||||
#include <osrm/json_container.hpp>
|
#include <osrm/json_container.hpp>
|
||||||
|
#include <osrm/libosrm_config.hpp>
|
||||||
#include <osrm/route_parameters.hpp>
|
#include <osrm/route_parameters.hpp>
|
||||||
#include <osrm/ServerConfig.h>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -45,16 +45,16 @@ int main(int argc, const char *argv[])
|
|||||||
std::string ip_address;
|
std::string ip_address;
|
||||||
int ip_port, requested_thread_num;
|
int ip_port, requested_thread_num;
|
||||||
bool trial_run = false;
|
bool trial_run = false;
|
||||||
ServerConfig server_config;
|
libosrm_config lib_config;
|
||||||
const unsigned init_result = GenerateServerProgramOptions(argc,
|
const unsigned init_result = GenerateServerProgramOptions(argc,
|
||||||
argv,
|
argv,
|
||||||
server_config.server_paths,
|
lib_config.server_paths,
|
||||||
ip_address,
|
ip_address,
|
||||||
ip_port,
|
ip_port,
|
||||||
requested_thread_num,
|
requested_thread_num,
|
||||||
server_config.use_shared_memory,
|
lib_config.use_shared_memory,
|
||||||
trial_run,
|
trial_run,
|
||||||
server_config.max_locations_distance_table);
|
lib_config.max_locations_distance_table);
|
||||||
|
|
||||||
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
|
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ int main(int argc, const char *argv[])
|
|||||||
}
|
}
|
||||||
SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION;
|
SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION;
|
||||||
|
|
||||||
OSRM routing_machine(server_config);
|
OSRM routing_machine(lib_config);
|
||||||
|
|
||||||
RouteParameters route_parameters;
|
RouteParameters route_parameters;
|
||||||
route_parameters.zoom_level = 18; // no generalization
|
route_parameters.zoom_level = 18; // no generalization
|
||||||
|
Loading…
Reference in New Issue
Block a user