diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index de15b240dc..f1b2992005 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -593,7 +593,7 @@ UNIT_TEST(OsmType_Surface) UNIT_TEST(OsmType_Ferry) { - routing::CarModel const & carModel = routing::CarModel::Instance(); + routing::CarModel const & carModel = routing::CarModel::AllLimitsInstance(); char const * arr[][2] = { { "motorcar", "yes" }, diff --git a/routing/car_model.cpp b/routing/car_model.cpp index 31a6e4c78b..0d11455b66 100644 --- a/routing/car_model.cpp +++ b/routing/car_model.cpp @@ -75,10 +75,24 @@ CarModel::CarModel() } // static -CarModel const & CarModel::Instance() +CarModel const & CarModel::AllLimitsInstance() { static CarModel const instance; return instance; } +CarModelFactory::CarModelFactory() +{ + m_model = make_shared(); +} + +shared_ptr CarModelFactory::GetVehicleModel() const +{ + return m_model; +} + +shared_ptr CarModelFactory::GetVehicleModelForCountry(string const & /* country */) const +{ + return m_model; +} } // namespace routing diff --git a/routing/car_model.hpp b/routing/car_model.hpp index 8170df3a75..680e20ebb7 100644 --- a/routing/car_model.hpp +++ b/routing/car_model.hpp @@ -1,16 +1,29 @@ #pragma once - #include "vehicle_model.hpp" +#include "std/shared_ptr.hpp" + namespace routing { class CarModel : public VehicleModel { +public: CarModel(); -public: - static CarModel const & Instance(); + static CarModel const & AllLimitsInstance(); }; +class CarModelFactory : public IVehicleModelFactory +{ +public: + CarModelFactory(); + + // IVehicleModelFactory overrides: + shared_ptr GetVehicleModel() const override; + shared_ptr GetVehicleModelForCountry(string const & country) const override; + +private: + shared_ptr m_model; +}; } // namespace routing diff --git a/routing/osrm_helpers.cpp b/routing/osrm_helpers.cpp index 2aed745f84..9a5274a75a 100644 --- a/routing/osrm_helpers.cpp +++ b/routing/osrm_helpers.cpp @@ -38,7 +38,7 @@ void Point2PhantomNode::FindNearestSegment(FeatureType const & ft, m2::PointD co void Point2PhantomNode::operator()(FeatureType const & ft) { - if (!CarModel::Instance().IsRoad(ft)) + if (!CarModel::AllLimitsInstance().IsRoad(ft)) return; Candidate res; @@ -280,7 +280,7 @@ void Point2PhantomNode::CalculateWeights(FeatureGraphNode & node) const void Point2Node::operator()(FeatureType const & ft) { - if (!CarModel::Instance().IsRoad(ft)) + if (!CarModel::AllLimitsInstance().IsRoad(ft)) return; uint32_t const featureId = ft.GetID().m_index; for (auto const & n : m_routingMapping.m_segMapping.GetNodeIdByFid(featureId)) diff --git a/routing/road_graph_router.cpp b/routing/road_graph_router.cpp index 6204c141b2..0afa57a2e7 100644 --- a/routing/road_graph_router.cpp +++ b/routing/road_graph_router.cpp @@ -1,5 +1,6 @@ #include "routing/bicycle_directions.hpp" #include "routing/bicycle_model.hpp" +#include "routing/car_model.hpp" #include "routing/features_road_graph.hpp" #include "routing/nearest_edge_finder.hpp" #include "routing/pedestrian_directions.hpp" @@ -314,7 +315,7 @@ unique_ptr CreateBicycleAStarBidirectionalRouter(Index & index, TCountr unique_ptr CreateCarAStarBidirectionalRouter(Index & index, TCountryFileFn const & countryFileFn) { // @TODO It's necessary to use car classes instead of bicycle ones. - unique_ptr vehicleModelFactory = make_unique(); + unique_ptr vehicleModelFactory = make_unique(); unique_ptr algorithm = make_unique(); unique_ptr directionsEngine = make_unique(index); unique_ptr router = make_unique( diff --git a/routing/routing_helpers.hpp b/routing/routing_helpers.hpp index 98365f39c4..76440a457e 100644 --- a/routing/routing_helpers.hpp +++ b/routing/routing_helpers.hpp @@ -10,7 +10,7 @@ namespace routing template bool IsRoad(TTypes const & types) { - return CarModel::Instance().HasRoadType(types) || + return CarModel::AllLimitsInstance().HasRoadType(types) || PedestrianModel::AllLimitsInstance().HasRoadType(types) || BicycleModel::AllLimitsInstance().HasRoadType(types); }