CARLA
LaneSectionMap.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #include "carla/NonCopyable.h"
10 #include "carla/road/LaneSection.h"
11 
12 #include <map>
13 #include <unordered_map>
14 
15 namespace carla {
16 namespace road {
17 
19  : private std::multimap<double, LaneSection>,
20  private MovableNonCopyable {
21  using Super = std::multimap<double, LaneSection>;
22  public:
23 
24  LaneSection &Emplace(SectionId id, double s) {
25  LaneSection &result = Super::emplace(s, LaneSection{id, s})->second;
26  _by_id.emplace(result.GetId(), &result);
27  return result;
28  }
29 
31  return *_by_id.at(id);
32  }
33 
34  const LaneSection &GetById(SectionId id) const {
35  return *_by_id.at(id);
36  }
37 
38  using Super::find;
39  using Super::upper_bound;
40  using Super::lower_bound;
41 
42  using Super::begin;
43  using Super::rbegin;
44  using Super::end;
45  using Super::rend;
46 
47  private:
48 
49  std::unordered_map<SectionId, LaneSection *> _by_id;
50  };
51 
52 } // road
53 } // carla
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
uint32_t SectionId
Definition: RoadTypes.h:21
const LaneSection & GetById(SectionId id) const
Inherit (privately) to suppress copy construction and assignment.
std::multimap< double, LaneSection > Super
SectionId GetId() const
Definition: LaneSection.cpp:27
std::unordered_map< SectionId, LaneSection * > _by_id
LaneSection & Emplace(SectionId id, double s)
LaneSection & GetById(SectionId id)