From ea9a592f1879d0b8a666c739c7a846548a1ece30 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Tue, 3 Apr 2018 08:24:02 +0800 Subject: [PATCH] Adding a comment about validity of ref returned by class Geometry methods. --- routing/geometry.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/routing/geometry.hpp b/routing/geometry.hpp index a88dd6d45c..62913c37b5 100644 --- a/routing/geometry.hpp +++ b/routing/geometry.hpp @@ -89,14 +89,23 @@ public: std::string const & fileName, std::shared_ptr vehicleModel); }; +/// \brief This class supports loading geometry of roads for routing. +/// \note Loaded information about road geometry is kept in evicted cache |m_featureIdToRoad|. +/// On the other hand methods GetRoad() and GetPoint() return geometry information by reference. +/// The reference is valid until the next call of GetRoad() or GetPoint() because the cache +/// item which is referred by returned reference may be evicted. It's done for performance reasons. class Geometry final { public: Geometry() = default; explicit Geometry(std::unique_ptr loader); + /// \note The reference returned by the method is valid until the next call of GetRoad() + /// of GetPoint() methods. RoadGeometry const & GetRoad(uint32_t featureId); + /// \note The reference returned by the method is valid until the next call of GetRoad() + /// of GetPoint() methods. m2::PointD const & GetPoint(RoadPoint const & rp) { return GetRoad(rp.GetFeatureId()).GetPoint(rp.GetPointId());