ad_rss_map_integration
ConnectingRoutesCache.hpp
Go to the documentation of this file.
1 // ----------------- BEGIN LICENSE BLOCK ---------------------------------
2 //
3 // Copyright (C) 2021 Intel Corporation
4 //
5 // SPDX-License-Identifier: LGPL-2.1-only
6 //
7 // ----------------- END LICENSE BLOCK -----------------------------------
12 #pragma once
13 
14 #include <ad/map/route/ConnectingRouteList.hpp>
15 #include <ad/rss/world/ObjectId.hpp>
16 #include <map>
17 #include <mutex>
18 
22 namespace ad {
26 namespace rss {
30 namespace map {
31 
36 {
37 public:
38  ConnectingRoutesCache() = default;
39 
40  ~ConnectingRoutesCache() = default;
41 
45  void clear();
46 
50  void addConnectingRoutes(ad::rss::world::ObjectId const &object_a,
51  ad::rss::world::ObjectId const &object_b,
52  ad::map::route::ConnectingRouteList const &connecting_route_list,
53  ad::physics::Distance const &max_connecting_route_length);
54 
55  bool getConnectingRoutes(ad::rss::world::ObjectId const &object_a,
56  ad::rss::world::ObjectId const &object_b,
57  ad::physics::Distance const &max_connecting_route_length,
58  ad::map::route::ConnectingRouteList &connecting_route_list);
59 
60 private:
61  bool findEntry(ad::rss::world::ObjectId const &object_a,
62  ad::rss::world::ObjectId const &object_b,
63  ad::physics::Distance const &max_connecting_route_length,
64  ad::map::route::ConnectingRouteList &connecting_route_list);
65 
66  std::mutex m_lock;
67 
68  struct ConnectingRouteStorage
69  {
70  ConnectingRouteStorage(ad::map::route::ConnectingRouteList const &i_connecting_route_list,
71  ad::physics::Distance const &i_max_connecting_route_length)
72  : connecting_route_list(i_connecting_route_list)
73  , max_connecting_route_length(i_max_connecting_route_length)
74  {
75  }
76  ad::map::route::ConnectingRouteList connecting_route_list;
77  ad::physics::Distance max_connecting_route_length;
78  };
79  std::map<ad::rss::world::ObjectId, std::map<ad::rss::world::ObjectId, ConnectingRouteStorage>> m_cache;
80 };
81 
82 } // namespace map
83 } // namespace rss
84 } // namespace ad
class to cache ConnectingRouteList between vehicles to speed up world model creation
Definition: ConnectingRoutesCache.hpp:36
void addConnectingRoutes(ad::rss::world::ObjectId const &object_a, ad::rss::world::ObjectId const &object_b, ad::map::route::ConnectingRouteList const &connecting_route_list, ad::physics::Distance const &max_connecting_route_length)
add a ConnectingRouteList of two vehicles
namespace ad
Definition: RouteAccelerations.hpp:33