CARLA
GraphParser.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 "CityAreaDescription.h"
10 #include "GraphTypes.h"
11 #include "RoadSegmentDescription.h"
12 
13 #include <vector>
14 
15 namespace MapGen {
16 
17  class DoublyConnectedEdgeList;
18 
19  class GraphParser : private NonCopyable
20  {
21  public:
22 
23  explicit GraphParser(DoublyConnectedEdgeList &Dcel);
24 
25  bool HasRoadSegments() const {
26  return !RoadSegments.empty();
27  }
28 
29  bool HasCityAreas() const {
30  return !CityAreas.empty();
31  }
32 
33  size_t RoadSegmentCount() const {
34  return RoadSegments.size();
35  }
36 
37  size_t CityAreaCount() const {
38  return CityAreas.size();
39  }
40 
41  const RoadSegmentDescription &GetRoadSegmentAt(size_t i) const {
42  return *RoadSegments[i];
43  }
44 
45  const CityAreaDescription &GetCityAreaAt(size_t i) const {
46  return *CityAreas[i];
47  }
48 
49  TUniquePtr<RoadSegmentDescription> PopRoadSegment() {
50  TUniquePtr<RoadSegmentDescription> ptr{RoadSegments.back().Release()};
51  RoadSegments.pop_back();
52  return ptr;
53  }
54 
55  TUniquePtr<CityAreaDescription> PopCityArea() {
56  TUniquePtr<CityAreaDescription> ptr{CityAreas.back().Release()};
57  CityAreas.pop_back();
58  return ptr;
59  }
60 
61  private:
62 
63  using RoadSegmentList = std::vector<TUniquePtr<RoadSegmentDescription>>;
64 
65  using CityAreaList = std::vector<TUniquePtr<CityAreaDescription>>;
66 
68 
70  };
71 
72 } // namespace MapGen
CityAreaList CityAreas
Definition: GraphParser.h:69
std::vector< TUniquePtr< RoadSegmentDescription > > RoadSegmentList
Definition: GraphParser.h:63
size_t CityAreaCount() const
Definition: GraphParser.h:37
TUniquePtr< RoadSegmentDescription > PopRoadSegment()
Definition: GraphParser.h:49
Simple doubly-connected edge list structure.
bool HasRoadSegments() const
Definition: GraphParser.h:25
RoadSegmentList RoadSegments
Definition: GraphParser.h:67
std::vector< TUniquePtr< CityAreaDescription > > CityAreaList
Definition: GraphParser.h:65
bool HasCityAreas() const
Definition: GraphParser.h:29
const RoadSegmentDescription & GetRoadSegmentAt(size_t i) const
Definition: GraphParser.h:41
TUniquePtr< CityAreaDescription > PopCityArea()
Definition: GraphParser.h:55
size_t RoadSegmentCount() const
Definition: GraphParser.h:33
const CityAreaDescription & GetCityAreaAt(size_t i) const
Definition: GraphParser.h:45
GraphParser(DoublyConnectedEdgeList &Dcel)