Drake
branch_point.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
9 
10 namespace drake {
11 namespace maliput {
12 namespace api {
13 
14 class RoadGeometry;
15 
16 
17 // Persistent identifier for a BranchPoint element.
19 
20 
22 class LaneEndSet {
23  // NB: This is abstract (versus being a std::set or what not) to allow the
24  // implementation to decide on how best to handle storage/indexing/etc.
25  // E.g., it could very well be a view into a database or tiled storage or
26  // something.
27  public:
29 
30  virtual ~LaneEndSet() = default;
31 
35  int size() const { return do_size(); }
36 
40  const LaneEnd& get(int index) const { return do_get(index); }
41 
42  protected:
43  LaneEndSet() = default;
44 
45  private:
50  virtual int do_size() const = 0;
51 
52  virtual const LaneEnd& do_get(int index) const = 0;
54 };
55 
56 
66 class BranchPoint {
67  public:
69 
70  virtual ~BranchPoint() = default;
71 
73  const BranchPointId id() const { return do_id(); }
74 
76  const RoadGeometry* road_geometry() const { return do_road_geometry(); }
77 
84  const LaneEndSet* GetConfluentBranches(const LaneEnd& end) const {
85  return DoGetConfluentBranches(end);
86  }
87 
92  const LaneEndSet* GetOngoingBranches(const LaneEnd& end) const {
93  return DoGetOngoingBranches(end);
94  }
95 
105  // TODO(maddog@tri.global) The return type yearns to be
106  // const boost::optional<LaneEnd>&.
107  std::unique_ptr<LaneEnd> GetDefaultBranch(const LaneEnd& end) const {
108  return DoGetDefaultBranch(end);
109  }
110 
112  const LaneEndSet* GetASide() const { return DoGetASide(); }
113 
115  const LaneEndSet* GetBSide() const { return DoGetBSide(); }
116 
117  protected:
118  BranchPoint() = default;
119 
120  private:
125  virtual const BranchPointId do_id() const = 0;
126 
127  virtual const RoadGeometry* do_road_geometry() const = 0;
128 
129  virtual const LaneEndSet* DoGetConfluentBranches(
130  const LaneEnd& end) const = 0;
131 
132  virtual const LaneEndSet* DoGetOngoingBranches(
133  const LaneEnd& end) const = 0;
134 
135  virtual std::unique_ptr<LaneEnd> DoGetDefaultBranch(
136  const LaneEnd& end) const = 0;
137 
138  virtual const LaneEndSet* DoGetASide() const = 0;
139 
140  virtual const LaneEndSet* DoGetBSide() const = 0;
142 };
143 
144 } // namespace api
145 } // namespace maliput
146 } // namespace drake
const BranchPointId id() const
Returns the persistent identifier.
Definition: branch_point.h:73
const LaneEndSet * GetConfluentBranches(const LaneEnd &end) const
Returns the set of LaneEnds on the same side as the given end, e.g., the LaneEnds merging with the gi...
Definition: branch_point.h:84
A BranchPoint is a node in the network of a RoadGeometry at which Lanes connect to one another...
Definition: branch_point.h:66
A specific endpoint of a specific Lane.
Definition: lane_data.h:22
Definition: automotive_demo.cc:88
const LaneEndSet * GetBSide() const
Returns the set of LaneEnds grouped together on the "B-side".
Definition: branch_point.h:115
Abstract API for the geometry of a road network, including both the network topology and the geometry...
Definition: road_geometry.h:26
TypeSpecificIdentifier< class BranchPoint > BranchPointId
Definition: branch_point.h:18
const RoadGeometry * road_geometry() const
Returns the RoadGeometry to which this BranchPoint belongs.
Definition: branch_point.h:76
A set of LaneEnds.
Definition: branch_point.h:22
TypeSpecificIdentifier<T> represents an identifier specifically identifying an entity of type T...
Definition: type_specific_identifier.h:38
std::unique_ptr< LaneEnd > GetDefaultBranch(const LaneEnd &end) const
Returns the default ongoing branch (if any) for the given end.
Definition: branch_point.h:107
const LaneEndSet * GetOngoingBranches(const LaneEnd &end) const
Returns the set of LaneEnds on the other side from the given end, e.g., the LaneEnds which end flows ...
Definition: branch_point.h:92
int size() const
Returns the number of LaneEnds in this set.
Definition: branch_point.h:35
const LaneEndSet * GetASide() const
Returns the set of LaneEnds grouped together on the "A-side".
Definition: branch_point.h:112
#define DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:35
Provides careful macros to selectively enable or disable the special member functions for copy-constr...