Drake
junction.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
7 
8 namespace drake {
9 namespace maliput {
10 namespace api {
11 
12 class RoadGeometry;
13 class Segment;
14 
15 
16 /// Persistent identifier for a Junction element.
18 
19 
20 /// A Junction is a closed set of Segments which have physically
21 /// coplanar road surfaces, in the sense that RoadPositions with the
22 /// same h value (height above surface) in the domains of two Segments
23 /// map to the same GeoPosition. The Segments need not be directly
24 /// connected to one another in the network topology.
25 ///
26 /// Junctions are grouped by RoadGeometry.
27 class Junction {
28  public:
30 
31  virtual ~Junction() = default;
32 
33  /// Returns the persistent identifier.
34  const JunctionId id() const { return do_id(); }
35 
36  /// Returns the RoadGeometry to which this Junction belongs.
37  const RoadGeometry* road_geometry() const { return do_road_geometry(); }
38 
39  /// Returns the number of Segments in the Junction.
40  ///
41  /// Return value is non-negative.
42  int num_segments() const { return do_num_segments(); }
43 
44  /// Returns the Segment indexed by @p index.
45  ///
46  /// @pre @p index must be >= 0 and < num_segments().
47  const Segment* segment(int index) const { return do_segment(index); }
48 
49  protected:
50  Junction() = default;
51 
52  private:
53  /// @name NVI implementations of the public methods.
54  /// These must satisfy the constraint/invariants of the
55  /// corresponding public methods.
56  ///@{
57  virtual const JunctionId do_id() const = 0;
58 
59  virtual const RoadGeometry* do_road_geometry() const = 0;
60 
61  virtual int do_num_segments() const = 0;
62 
63  virtual const Segment* do_segment(int index) const = 0;
64  ///@}
65 };
66 
67 
68 } // namespace api
69 } // namespace maliput
70 } // namespace drake
Definition: automotive_demo.cc:88
const RoadGeometry * road_geometry() const
Returns the RoadGeometry to which this Junction belongs.
Definition: junction.h:37
Abstract API for the geometry of a road network, including both the network topology and the geometry...
Definition: road_geometry.h:26
const JunctionId id() const
Returns the persistent identifier.
Definition: junction.h:34
TypeSpecificIdentifier<T> represents an identifier specifically identifying an entity of type T...
Definition: type_specific_identifier.h:38
TypeSpecificIdentifier< class Junction > JunctionId
Persistent identifier for a Junction element.
Definition: junction.h:17
A Segment represents a bundle of adjacent Lanes which share a continuously traversable road surface...
Definition: segment.h:27
virtual ~Junction()=default
A Junction is a closed set of Segments which have physically coplanar road surfaces, in the sense that RoadPositions with the same h value (height above surface) in the domains of two Segments map to the same GeoPosition.
Definition: junction.h:27
int num_segments() const
Returns the number of Segments in the Junction.
Definition: junction.h:42
const Segment * segment(int index) const
Returns the Segment indexed by index.
Definition: junction.h:47
#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:33
Provides careful macros to selectively enable or disable the special member functions for copy-constr...