Lane.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef IGNITION_RNDF_LANE_HH_
19 #define IGNITION_RNDF_LANE_HH_
20 
21 #include <iosfwd>
22 #include <memory>
23 #include <vector>
24 
25 #include "ignition/rndf/Helpers.hh"
26 
27 namespace ignition
28 {
29  namespace rndf
30  {
31  // Forward declarations.
32  class Checkpoint;
33  class Exit;
34  class LaneHeaderPrivate;
35  class LanePrivate;
36  class Waypoint;
37 
39  enum class Marking
40  {
50  UNDEFINED,
51  };
52 
55  class LaneHeader
56  {
58  public: LaneHeader();
59 
61  public: ~LaneHeader() = default;
62 
66 
76  public: bool Load(std::ifstream &_rndfFile,
77  const int _segmentId,
78  const int _laneId,
79  int &_lineNumber);
80 
84 
87  public: double Width() const;
88 
91  public: bool SetWidth(const double _newWidth);
92 
96 
99  public: Marking LeftBoundary() const;
100 
103  public: void SetLeftBoundary(const Marking &_boundary);
104 
107  public: Marking RightBoundary() const;
108 
111  public: void SetRightBoundary(const Marking &_boundary);
112 
116 
119  public: unsigned int NumCheckpoints() const;
120 
123  public: std::vector<rndf::Checkpoint> &Checkpoints();
124 
127  public: const std::vector<rndf::Checkpoint> &Checkpoints() const;
128 
133  public: bool Checkpoint(const int _cpId, rndf::Checkpoint &_cp) const;
134 
139  public: bool UpdateCheckpoint(const rndf::Checkpoint &_cp);
140 
146  public: bool AddCheckpoint(const rndf::Checkpoint &_newCheckpoint);
147 
153  public: bool RemoveCheckpoint(const int _cpId);
154 
158 
161  public: unsigned int NumStops() const;
162 
166  public: std::vector<int> &Stops();
167 
170  public: const std::vector<int> &Stops() const;
171 
177  public: bool AddStop(const int _waypointId);
178 
184  public: bool RemoveStop(const int _waypointId);
185 
189 
192  public: unsigned int NumExits() const;
193 
196  public: std::vector<Exit> &Exits();
197 
200  public: const std::vector<Exit> &Exits() const;
201 
206  public: bool AddExit(const Exit &_newExit);
207 
212  public: bool RemoveExit(const Exit &_exit);
213 
215  private: std::unique_ptr<LaneHeaderPrivate> dataPtr;
216  };
217 
221  {
224  public: Lane();
225 
229  public: explicit Lane(const int _id);
230 
234  public: explicit Lane(const Lane &_other);
235 
237  public: virtual ~Lane();
238 
242 
251  public: bool Load(std::ifstream &_rndfFile,
252  const int _segmentId,
253  int &_lineNumber);
254 
258 
261  public: int Id() const;
262 
268  public: bool SetId(const int _id);
269 
273 
276  public: unsigned int NumWaypoints() const;
277 
280  public: std::vector<rndf::Waypoint> &Waypoints();
281 
284  public: const std::vector<rndf::Waypoint> &Waypoints() const;
285 
290  public: bool Waypoint(const int _wpId,
291  rndf::Waypoint &_wp) const;
292 
296  public: bool UpdateWaypoint(const rndf::Waypoint &_wp);
297 
303  public: bool AddWaypoint(const rndf::Waypoint &_newWaypoint);
304 
310  public: bool RemoveWaypoint(const int _wpId);
311 
315 
318  public: double Width() const;
319 
322  public: bool SetWidth(const double _newWidth);
323 
327 
330  public: Marking LeftBoundary() const;
331 
334  public: void SetLeftBoundary(const Marking &_boundary);
335 
338  public: Marking RightBoundary() const;
339 
342  public: void SetRightBoundary(const Marking &_boundary);
343 
347 
350  public: unsigned int NumCheckpoints() const;
351 
354  public: std::vector<rndf::Checkpoint> &Checkpoints();
355 
358  public: const std::vector<rndf::Checkpoint> &Checkpoints() const;
359 
364  public: bool Checkpoint(const int _cpId, rndf::Checkpoint &_cp) const;
365 
370  public: bool UpdateCheckpoint(const rndf::Checkpoint &_cp);
371 
377  public: bool AddCheckpoint(const rndf::Checkpoint &_newCheckpoint);
378 
384  public: bool RemoveCheckpoint(const int _cpId);
385 
389 
392  public: unsigned int NumStops() const;
393 
397  public: std::vector<int> &Stops();
398 
401  public: const std::vector<int> &Stops() const;
402 
408  public: bool AddStop(const int _waypointId);
409 
415  public: bool RemoveStop(const int _waypointId);
416 
420 
423  public: unsigned int NumExits() const;
424 
427  public: std::vector<Exit> &Exits();
428 
431  public: const std::vector<Exit> &Exits() const;
432 
437  public: bool AddExit(const Exit &_newExit);
438 
443  public: bool RemoveExit(const Exit &_exit);
444 
448 
450  public: bool Valid() const;
451 
455 
459  public: bool operator==(const Lane &_other) const;
460 
464  public: bool operator!=(const Lane &_other) const;
465 
469  public: Lane &operator=(const Lane &_other);
470 
473  private: std::unique_ptr<LanePrivate> dataPtr;
474  };
475  }
476 }
477 #endif
#define IGNITION_RNDF_VISIBLE
Use to represent "symbol visible" if supported.
Definition: Helpers.hh:55
Marking
Definition: Lane.hh:39
A class that represents a road lane composed by a set of waypoints.
Definition: Lane.hh:220
Definition: Lane.hh:55
An exit clas that shows how to go from an exit waypoint to an entry waypoint.
Definition: Exit.hh:32
A checkpoint is a waypoint that has to be visited.
Definition: Checkpoint.hh:34
Definition: Checkpoint.hh:25
A reference point.
Definition: Waypoint.hh:42