Collapses Double OSRM <-> Engine <-> .. PImpl Indirection, Resolves #3019.

This commit is contained in:
Daniel J. Hofmann
2016-10-14 15:55:21 +02:00
committed by Daniel J. H
parent 2a2abe9e0f
commit 18bc02f087
10 changed files with 75 additions and 117 deletions
+26 -53
View File
@@ -1,71 +1,44 @@
#ifndef ENGINE_HPP
#define ENGINE_HPP
#include "storage/shared_barriers.hpp"
#include "engine/api/match_parameters.hpp"
#include "engine/api/nearest_parameters.hpp"
#include "engine/api/route_parameters.hpp"
#include "engine/api/table_parameters.hpp"
#include "engine/api/tile_parameters.hpp"
#include "engine/api/trip_parameters.hpp"
#include "engine/data_watchdog.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/engine_config.hpp"
#include "engine/plugins/match.hpp"
#include "engine/plugins/nearest.hpp"
#include "engine/plugins/table.hpp"
#include "engine/plugins/tile.hpp"
#include "engine/plugins/trip.hpp"
#include "engine/plugins/viaroute.hpp"
#include "engine/status.hpp"
#include "util/json_container.hpp"
#include <memory>
#include <mutex>
#include <string>
#include <unordered_map>
namespace osrm
{
namespace util
{
namespace json
{
struct Object;
}
}
namespace storage
{
struct SharedBarriers;
}
// Fwd decls
namespace engine
{
struct EngineConfig;
namespace api
{
struct RouteParameters;
struct TableParameters;
struct NearestParameters;
struct TripParameters;
struct MatchParameters;
struct TileParameters;
}
namespace plugins
{
class ViaRoutePlugin;
class TablePlugin;
class NearestPlugin;
class TripPlugin;
class MatchPlugin;
class TilePlugin;
}
// End fwd decls
namespace datafacade
{
class BaseDataFacade;
}
class DataWatchdog;
class Engine final
{
public:
explicit Engine(const EngineConfig &config);
Engine(Engine &&) noexcept;
Engine &operator=(Engine &&) noexcept;
Engine(Engine &&) noexcept = delete;
Engine &operator=(Engine &&) noexcept = delete;
// Impl. in cpp since for unique_ptr of incomplete types
~Engine();
Engine(const Engine &) = delete;
Engine &operator=(const Engine &) = delete;
Status Route(const api::RouteParameters &parameters, util::json::Object &result) const;
Status Table(const api::TableParameters &parameters, util::json::Object &result) const;
@@ -78,12 +51,12 @@ class Engine final
std::unique_ptr<storage::SharedBarriers> lock;
std::unique_ptr<DataWatchdog> watchdog;
std::unique_ptr<plugins::ViaRoutePlugin> route_plugin;
std::unique_ptr<plugins::TablePlugin> table_plugin;
std::unique_ptr<plugins::NearestPlugin> nearest_plugin;
std::unique_ptr<plugins::TripPlugin> trip_plugin;
std::unique_ptr<plugins::MatchPlugin> match_plugin;
std::unique_ptr<plugins::TilePlugin> tile_plugin;
const plugins::ViaRoutePlugin route_plugin;
const plugins::TablePlugin table_plugin;
const plugins::NearestPlugin nearest_plugin;
const plugins::TripPlugin trip_plugin;
const plugins::MatchPlugin match_plugin;
const plugins::TilePlugin tile_plugin;
// note in case of shared memory this will be empty, since the watchdog
// will provide us with the up-to-date facade
+5 -5
View File
@@ -35,13 +35,13 @@ class MatchPlugin : public BasePlugin
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
const api::MatchParameters &parameters,
util::json::Object &json_result);
util::json::Object &json_result) const;
private:
SearchEngineData heaps;
routing_algorithms::MapMatching<datafacade::BaseDataFacade> map_matching;
routing_algorithms::ShortestPathRouting<datafacade::BaseDataFacade> shortest_path;
int max_locations_map_matching;
mutable SearchEngineData heaps;
mutable routing_algorithms::MapMatching<datafacade::BaseDataFacade> map_matching;
mutable routing_algorithms::ShortestPathRouting<datafacade::BaseDataFacade> shortest_path;
const int max_locations_map_matching;
};
}
}
+4 -4
View File
@@ -22,12 +22,12 @@ class TablePlugin final : public BasePlugin
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
const api::TableParameters &params,
util::json::Object &result);
util::json::Object &result) const;
private:
SearchEngineData heaps;
routing_algorithms::ManyToManyRouting<datafacade::BaseDataFacade> distance_table;
int max_locations_distance_table;
mutable SearchEngineData heaps;
mutable routing_algorithms::ManyToManyRouting<datafacade::BaseDataFacade> distance_table;
const int max_locations_distance_table;
};
}
}
+6 -6
View File
@@ -29,14 +29,14 @@ namespace plugins
class TripPlugin final : public BasePlugin
{
private:
SearchEngineData heaps;
routing_algorithms::ShortestPathRouting<datafacade::BaseDataFacade> shortest_path;
routing_algorithms::ManyToManyRouting<datafacade::BaseDataFacade> duration_table;
int max_locations_trip;
mutable SearchEngineData heaps;
mutable routing_algorithms::ShortestPathRouting<datafacade::BaseDataFacade> shortest_path;
mutable routing_algorithms::ManyToManyRouting<datafacade::BaseDataFacade> duration_table;
const int max_locations_trip;
InternalRouteResult ComputeRoute(const datafacade::BaseDataFacade &facade,
const std::vector<PhantomNode> &phantom_node_list,
const std::vector<NodeID> &trip);
const std::vector<NodeID> &trip) const;
public:
explicit TripPlugin(const int max_locations_trip_)
@@ -46,7 +46,7 @@ class TripPlugin final : public BasePlugin
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
const api::TripParameters &parameters,
util::json::Object &json_result);
util::json::Object &json_result) const;
};
}
}
+6 -6
View File
@@ -28,18 +28,18 @@ namespace plugins
class ViaRoutePlugin final : public BasePlugin
{
private:
SearchEngineData heaps;
routing_algorithms::ShortestPathRouting<datafacade::BaseDataFacade> shortest_path;
routing_algorithms::AlternativeRouting<datafacade::BaseDataFacade> alternative_path;
routing_algorithms::DirectShortestPathRouting<datafacade::BaseDataFacade> direct_shortest_path;
int max_locations_viaroute;
mutable SearchEngineData heaps;
mutable routing_algorithms::ShortestPathRouting<datafacade::BaseDataFacade> shortest_path;
mutable routing_algorithms::AlternativeRouting<datafacade::BaseDataFacade> alternative_path;
mutable routing_algorithms::DirectShortestPathRouting<datafacade::BaseDataFacade> direct_shortest_path;
const int max_locations_viaroute;
public:
explicit ViaRoutePlugin(int max_locations_viaroute);
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade,
const api::RouteParameters &route_parameters,
util::json::Object &json_result);
util::json::Object &json_result) const;
};
}
}