Enable all plugins with aStatus::Error return code fallback for not implemented ones
This commit is contained in:
		
							parent
							
								
									99f18051f6
								
							
						
					
					
						commit
						44b802c053
					
				| @ -29,16 +29,16 @@ namespace api | |||||||
| struct RouteParameters; | struct RouteParameters; | ||||||
| struct TableParameters; | struct TableParameters; | ||||||
| struct NearestParameters; | struct NearestParameters; | ||||||
| // struct TripParameters;
 | struct TripParameters; | ||||||
| // struct MatchParameters;
 | struct MatchParameters; | ||||||
| } | } | ||||||
| namespace plugins | namespace plugins | ||||||
| { | { | ||||||
| class ViaRoutePlugin; | class ViaRoutePlugin; | ||||||
| class TablePlugin; | class TablePlugin; | ||||||
| class NearestPlugin; | class NearestPlugin; | ||||||
| // class TripPlugin;
 | class TripPlugin; | ||||||
| // class MatchPlugin;
 | class MatchPlugin; | ||||||
| } | } | ||||||
| // End fwd decls
 | // End fwd decls
 | ||||||
| 
 | 
 | ||||||
| @ -64,8 +64,8 @@ class Engine final | |||||||
|     Status Route(const api::RouteParameters ¶meters, util::json::Object &result); |     Status Route(const api::RouteParameters ¶meters, util::json::Object &result); | ||||||
|     Status Table(const api::TableParameters ¶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 Nearest(const api::NearestParameters ¶meters, util::json::Object &result); | ||||||
|     // Status Trip(const api::TripParameters ¶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);
 |     Status Match(const api::MatchParameters ¶meters, util::json::Object &result); | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     std::unique_ptr<EngineLock> lock; |     std::unique_ptr<EngineLock> lock; | ||||||
|  | |||||||
| @ -47,27 +47,32 @@ struct Object; | |||||||
| namespace engine | namespace engine | ||||||
| { | { | ||||||
| class Engine; | class Engine; | ||||||
|  | 
 | ||||||
| struct EngineConfig; | struct EngineConfig; | ||||||
| namespace api | namespace api | ||||||
| { | { | ||||||
| struct RouteParameters; | struct RouteParameters; | ||||||
| struct TableParameters; | struct TableParameters; | ||||||
| struct NearestParameters; | struct NearestParameters; | ||||||
| // struct TripParameters;
 | struct TripParameters; | ||||||
| // struct MatchParameters;
 | struct MatchParameters; | ||||||
| } | } | ||||||
| } | } | ||||||
|  | 
 | ||||||
| // End fwd decls
 | // End fwd decls
 | ||||||
| 
 | 
 | ||||||
| using engine::EngineConfig; | using engine::EngineConfig; | ||||||
| using engine::api::RouteParameters; | using engine::api::RouteParameters; | ||||||
| using engine::api::TableParameters; | using engine::api::TableParameters; | ||||||
| using engine::api::NearestParameters; | using engine::api::NearestParameters; | ||||||
| // using engine::api::TripParameters;
 | using engine::api::TripParameters; | ||||||
| // using engine::api::MatchParameters;
 | using engine::api::MatchParameters; | ||||||
|  | 
 | ||||||
| namespace json = util::json; | namespace json = util::json; | ||||||
| 
 | 
 | ||||||
| class OSRM | // OSRM API
 | ||||||
|  | 
 | ||||||
|  | class OSRM final | ||||||
| { | { | ||||||
|   public: |   public: | ||||||
|     explicit OSRM(EngineConfig &config); |     explicit OSRM(EngineConfig &config); | ||||||
| @ -79,8 +84,8 @@ class OSRM | |||||||
|     Status Route(const RouteParameters ¶meters, json::Object &result); |     Status Route(const RouteParameters ¶meters, json::Object &result); | ||||||
|     Status Table(const TableParameters ¶meters, json::Object &result); |     Status Table(const TableParameters ¶meters, json::Object &result); | ||||||
|     Status Nearest(const NearestParameters ¶meters, json::Object &result); |     Status Nearest(const NearestParameters ¶meters, json::Object &result); | ||||||
|     // Status Trip(const TripParameters ¶meters, json::Object &result);
 |     Status Trip(const TripParameters ¶meters, json::Object &result); | ||||||
|     // Status Match(const MatchParameters ¶meters, json::Object &result);
 |     Status Match(const MatchParameters ¶meters, json::Object &result); | ||||||
| 
 | 
 | ||||||
|   private: |   private: | ||||||
|     std::unique_ptr<engine::Engine> engine_; |     std::unique_ptr<engine::Engine> engine_; | ||||||
|  | |||||||
| @ -113,6 +113,13 @@ osrm::engine::Status RunQuery(const std::unique_ptr<osrm::engine::Engine::Engine | |||||||
|     lock->DecreaseQueryCount(); |     lock->DecreaseQueryCount(); | ||||||
|     return status; |     return status; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | template <typename Plugin, typename Facade, typename... Args> | ||||||
|  | std::unique_ptr<Plugin> create(Facade &facade, Args... args) | ||||||
|  | { | ||||||
|  |     return osrm::util::make_unique<Plugin>(facade, std::forward<Args>(args)...); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } // anon. ns
 | } // anon. ns
 | ||||||
| 
 | 
 | ||||||
| namespace osrm | namespace osrm | ||||||
| @ -133,10 +140,14 @@ Engine::Engine(EngineConfig &config) | |||||||
|         query_data_facade = util::make_unique<datafacade::InternalDataFacade>(config.server_paths); |         query_data_facade = util::make_unique<datafacade::InternalDataFacade>(config.server_paths); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     route_plugin = util::make_unique<plugins::ViaRoutePlugin>(*query_data_facade, |     // Register plugins
 | ||||||
|                                                               config.max_locations_viaroute); |     using namespace plugins; | ||||||
|     table_plugin = util::make_unique<plugins::TablePlugin>(*query_data_facade, | 
 | ||||||
|                                                            config.max_locations_distance_table); |     route_plugin = create<ViaRoutePlugin>(*query_data_facade, config.max_locations_viaroute); | ||||||
|  |     table_plugin = create<TablePlugin>(*query_data_facade, config.max_locations_distance_table); | ||||||
|  |     nearest_plugin = create<NearestPlugin>(*query_data_facade); | ||||||
|  |     // trip_plugin = ceate<TripPlugin>(*query_data_facade, config.max_locations_trip);
 | ||||||
|  |     // match_plugin = create<MatchPlugin>(*query_data_facade, config.max_locations_map_matching);
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // make sure we deallocate the unique ptr at a position where we know the size of the plugins
 | // make sure we deallocate the unique ptr at a position where we know the size of the plugins
 | ||||||
| @ -159,15 +170,17 @@ Status Engine::Nearest(const api::NearestParameters ¶ms, util::json::Object | |||||||
|     return RunQuery(lock, *query_data_facade, params, *nearest_plugin, result); |     return RunQuery(lock, *query_data_facade, params, *nearest_plugin, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //Status Engine::Trip(const api::TripParameters ¶ms, util::json::Object &result)
 | Status Engine::Trip(const api::TripParameters ¶ms, util::json::Object &result) | ||||||
| //{
 | { | ||||||
| //    return RunQuery(lock, *query_data_facade, params, *trip_plugin, result);
 |     // return RunQuery(lock, *query_data_facade, params, *trip_plugin, result);
 | ||||||
| //}
 |     return Status::Error; | ||||||
| //
 | } | ||||||
| //Status Engine::Match(const api::MatchParameters ¶ms, util::json::Object &result)
 | 
 | ||||||
| //{
 | Status Engine::Match(const api::MatchParameters ¶ms, util::json::Object &result) | ||||||
| //    return RunQuery(lock, *query_data_facade, params, *match_plugin, result);
 | { | ||||||
| //}
 |     // return RunQuery(lock, *query_data_facade, params, *match_plugin, result);
 | ||||||
|  |     return Status::Error; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| } // engine ns
 | } // engine ns
 | ||||||
| } // osrm ns
 | } // osrm ns
 | ||||||
|  | |||||||
| @ -2,8 +2,8 @@ | |||||||
| #include "engine/api/route_parameters.hpp" | #include "engine/api/route_parameters.hpp" | ||||||
| #include "engine/api/table_parameters.hpp" | #include "engine/api/table_parameters.hpp" | ||||||
| #include "engine/api/nearest_parameters.hpp" | #include "engine/api/nearest_parameters.hpp" | ||||||
| //#include "engine/api/trip_parameters.hpp"
 | #include "engine/api/trip_parameters.hpp" | ||||||
| //#include "engine/api/match_parameters.hpp"
 | #include "engine/api/match_parameters.hpp" | ||||||
| #include "engine/engine.hpp" | #include "engine/engine.hpp" | ||||||
| #include "engine/status.hpp" | #include "engine/status.hpp" | ||||||
| #include "engine/engine_config.hpp" | #include "engine/engine_config.hpp" | ||||||
| @ -36,14 +36,14 @@ engine::Status OSRM::Nearest(const engine::api::NearestParameters ¶ms, json: | |||||||
|     return engine_->Nearest(params, result); |     return engine_->Nearest(params, result); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //engine::Status OSRM::Trip(const engine::api::TripParameters ¶ms, json::Object &result)
 | engine::Status OSRM::Trip(const engine::api::TripParameters ¶ms, json::Object &result) | ||||||
| //{
 | { | ||||||
| //    return engine_->Trip(params, result);
 |     return engine_->Trip(params, result); | ||||||
| //}
 | } | ||||||
| //
 | 
 | ||||||
| //engine::Status OSRM::Match(const engine::api::MatchParameters ¶ms, json::Object &result)
 | engine::Status OSRM::Match(const engine::api::MatchParameters ¶ms, json::Object &result) | ||||||
| //{
 | { | ||||||
| //    return engine_->Match(params, result);
 |     return engine_->Match(params, result); | ||||||
| //}
 | } | ||||||
| 
 | 
 | ||||||
| } // ns osrm
 | } // ns osrm
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user