| 38 | using namespace std; |
| 39 | |
| 40 | class IndexGraphLoaderImpl final : public IndexGraphLoader |
| 41 | { |
| 42 | public: |
| 43 | IndexGraphLoaderImpl(VehicleType vehicleType, bool loadAltitudes, |
| 44 | shared_ptr<VehicleModelFactoryInterface> vehicleModelFactory, |
| 45 | shared_ptr<EdgeEstimator> estimator, MwmDataSource & dataSource, RoutingOptions routingOptions, |
| 46 | TimeGetterT timeGetter) |
| 47 | : m_vehicleType(vehicleType) |
| 48 | , m_loadAltitudes(loadAltitudes) |
| 49 | , m_dataSource(dataSource) |
| 50 | , m_vehicleModelFactory(std::move(vehicleModelFactory)) |
| 51 | , m_estimator(std::move(estimator)) |
| 52 | , m_avoidRoutingOptions(routingOptions) |
| 53 | { |
| 54 | CHECK(m_vehicleModelFactory, ()); |
| 55 | CHECK(m_estimator, ()); |
| 56 | |
| 57 | if (timeGetter) |
| 58 | m_currentTimeGetter = std::move(timeGetter); |
| 59 | } |
| 60 | |
| 61 | // IndexGraphLoader overrides: |
| 62 | IndexGraph & GetIndexGraph(NumMwmId numMwmId) override; |
| 63 | Geometry & GetGeometry(NumMwmId numMwmId) override; |
| 64 | vector<RouteSegment::SpeedCamera> GetSpeedCameraInfo(Segment const & segment) override; |
| 65 | void Clear() override; |
| 66 | |
| 67 | private: |
| 68 | using GeometryPtrT = shared_ptr<Geometry>; |
| 69 | GeometryPtrT CreateGeometry(NumMwmId numMwmId); |
| 70 | using GraphPtrT = unique_ptr<IndexGraph>; |
| 71 | GraphPtrT CreateIndexGraph(NumMwmId numMwmId, GeometryPtrT & geometry); |
| 72 | |
| 73 | VehicleType m_vehicleType; |
| 74 | bool m_loadAltitudes; |
| 75 | MwmDataSource & m_dataSource; |
| 76 | shared_ptr<VehicleModelFactoryInterface> m_vehicleModelFactory; |
| 77 | shared_ptr<EdgeEstimator> m_estimator; |
| 78 | |
| 79 | struct GraphAttrs |
| 80 | { |
| 81 | GeometryPtrT m_geometry; |
| 82 | // May be nullptr, because it has "lazy" loading. |
| 83 | GraphPtrT m_graph; |
| 84 | }; |
| 85 | std::unordered_map<NumMwmId, GraphAttrs> m_graphs; |
| 86 | |
| 87 | ankerl::unordered_dense::map<NumMwmId, SpeedCamerasMapT> m_cachedCameras; |
| 88 | SpeedCamerasMapT const & ReceiveSpeedCamsFromMwm(NumMwmId numMwmId); |
| 89 | |
| 90 | RoutingOptions m_avoidRoutingOptions; |
| 91 | std::function<time_t()> m_currentTimeGetter = [time = GetCurrentTimestamp()]() { return time; }; |
| 92 | }; |
| 93 | |
| 94 | IndexGraph & IndexGraphLoaderImpl::GetIndexGraph(NumMwmId numMwmId) |
| 95 | { |
nothing calls this directly
no test coverage detected