From a4074332ccf67ccec9f27d0bb561c0f028f7b132 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Wed, 17 Feb 2016 12:56:27 -0800 Subject: [PATCH] Adapts publicly facing new API --- include/engine/engine.hpp | 19 ++++++++++++++++++- include/engine/plugins/nearest.hpp | 2 +- include/osrm/osrm.hpp | 12 ++++++++++++ src/engine/plugins/nearest.cpp | 0 src/osrm/osrm.cpp | 18 ++++++++++++++++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/engine/plugins/nearest.cpp diff --git a/include/engine/engine.hpp b/include/engine/engine.hpp index 122e98a9d..24e9788d0 100644 --- a/include/engine/engine.hpp +++ b/include/engine/engine.hpp @@ -20,6 +20,7 @@ struct Object; } } +// Fwd decls namespace engine { struct EngineConfig; @@ -27,12 +28,20 @@ namespace api { struct RouteParameters; struct TableParameters; +struct NearestParameters; +// struct TripParameters; +// struct MatchParameters; } namespace plugins { class ViaRoutePlugin; class TablePlugin; +class NearestPlugin; +// class TripPlugin; +// class MatchPlugin; } +// End fwd decls + namespace datafacade { class BaseDataFacade; @@ -45,19 +54,27 @@ class Engine final struct EngineLock; explicit Engine(EngineConfig &config); + Engine(const Engine &) = delete; Engine &operator=(const Engine &) = delete; - // Needed because we have unique_ptr of incomplete types + + // Impl. in cpp since for unique_ptr of incomplete types ~Engine(); Status Route(const api::RouteParameters ¶meters, util::json::Object &result); Status Table(const api::TableParameters ¶meters, util::json::Object &result); + Status Nearest(const api::NearestParameters ¶meters, util::json::Object &result); + // Status Trip(const api::TripParameters ¶meters, util::json::Object &result); + // Status Match(const api::MatchParameters ¶meters, util::json::Object &result); private: std::unique_ptr lock; std::unique_ptr route_plugin; std::unique_ptr table_plugin; + std::unique_ptr nearest_plugin; + // std::unique_ptr trip_plugin; + // std::unique_ptr match_plugin; std::unique_ptr query_data_facade; }; diff --git a/include/engine/plugins/nearest.hpp b/include/engine/plugins/nearest.hpp index 0a41fa409..5f94ce735 100644 --- a/include/engine/plugins/nearest.hpp +++ b/include/engine/plugins/nearest.hpp @@ -19,7 +19,7 @@ namespace plugins * This Plugin locates the nearest point on a street in the road network for a given coordinate. */ -template class NearestPlugin final : public BasePlugin +class NearestPlugin final : public BasePlugin { public: explicit NearestPlugin(DataFacadeT *facade) : facade(facade), descriptor_string("nearest") {} diff --git a/include/osrm/osrm.hpp b/include/osrm/osrm.hpp index 1dccecfa9..69ac8126b 100644 --- a/include/osrm/osrm.hpp +++ b/include/osrm/osrm.hpp @@ -34,6 +34,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace osrm { + +// Fwd decls namespace util { namespace json @@ -50,12 +52,19 @@ namespace api { struct RouteParameters; struct TableParameters; +struct NearestParameters; +// struct TripParameters; +// struct MatchParameters; } } +// End fwd decls using engine::EngineConfig; using engine::api::RouteParameters; using engine::api::TableParameters; +using engine::api::NearestParameters; +// using engine::api::TripParameters; +// using engine::api::MatchParameters; namespace json = util::json; class OSRM @@ -69,6 +78,9 @@ class OSRM Status Route(const RouteParameters ¶meters, json::Object &result); Status Table(const TableParameters ¶meters, json::Object &result); + Status Nearest(const NearestParameters ¶meters, json::Object &result); + // Status Trip(const TripParameters ¶meters, json::Object &result); + // Status Match(const MatchParameters ¶meters, json::Object &result); private: std::unique_ptr engine_; diff --git a/src/engine/plugins/nearest.cpp b/src/engine/plugins/nearest.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/osrm/osrm.cpp b/src/osrm/osrm.cpp index 54111c505..589a6cb3b 100644 --- a/src/osrm/osrm.cpp +++ b/src/osrm/osrm.cpp @@ -1,6 +1,9 @@ #include "osrm/osrm.hpp" #include "engine/api/route_parameters.hpp" #include "engine/api/table_parameters.hpp" +#include "engine/api/nearest_parameters.hpp" +//#include "engine/api/trip_parameters.hpp" +//#include "engine/api/match_parameters.hpp" #include "engine/engine.hpp" #include "engine/status.hpp" #include "engine/engine_config.hpp" @@ -28,4 +31,19 @@ engine::Status OSRM::Table(const engine::api::TableParameters ¶ms, json::Obj return engine_->Table(params, result); } +engine::Status OSRM::Nearest(const engine::api::NearestParameters ¶ms, json::Object &result) +{ + return engine_->Nearest(params, result); +} + +//engine::Status OSRM::Trip(const engine::api::TripParameters ¶ms, json::Object &result) +//{ +// return engine_->Trip(params, result); +//} +// +//engine::Status OSRM::Match(const engine::api::MatchParameters ¶ms, json::Object &result) +//{ +// return engine_->Match(params, result); +//} + } // ns osrm