RNDF.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_RNDF_HH_
19 #define IGNITION_RNDF_RNDF_HH_
20 
21 #include <iosfwd>
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include "ignition/rndf/Helpers.hh"
27 
28 namespace ignition
29 {
30  namespace rndf
31  {
32  // Forward declarations.
33  class RNDFHeaderPrivate;
34  class RNDFNode;
35  class RNDFPrivate;
36  class Segment;
37  class UniqueId;
38  class Zone;
39 
40  // \internal
42  class RNDFHeader
43  {
45  public: RNDFHeader();
46 
48  public: ~RNDFHeader() = default;
49 
53 
61  public: bool Load(std::ifstream &_rndfFile,
62  int &_lineNumber);
63 
67 
70  public: std::string Version() const;
71 
74  public: void SetVersion(const std::string &_version) const;
75 
79 
82  public: std::string Date() const;
83 
86  public: void SetDate(const std::string &_newDate) const;
87 
89  private: std::unique_ptr<RNDFHeaderPrivate> dataPtr;
90  };
91 
96  {
98  public: RNDF();
99 
102  public: explicit RNDF(const std::string &_filepath);
103 
105  public: virtual ~RNDF();
106 
110 
116  public: bool Load(const std::string &_filePath);
117 
121 
124  public: std::string Name() const;
125 
128  public: void SetName(const std::string &_name);
129 
133 
136  public: unsigned int NumSegments() const;
137 
140  public: std::vector<rndf::Segment> &Segments();
141 
144  public: const std::vector<rndf::Segment> &Segments() const;
145 
150  public: bool Segment(const int _segmentId,
151  rndf::Segment &_segment) const;
152 
156  public: bool UpdateSegment(const rndf::Segment &_segment);
157 
163  public: bool AddSegment(const rndf::Segment &_newSegment);
164 
170  public: bool RemoveSegment(const int _segmentId);
171 
175 
178  public: unsigned int NumZones() const;
179 
182  public: std::vector<rndf::Zone> &Zones();
183 
186  public: const std::vector<rndf::Zone> &Zones() const;
187 
192  public: bool Zone(const int _zoneId,
193  rndf::Zone &_zone) const;
194 
198  public: bool UpdateZone(const rndf::Zone &_zone);
199 
205  public: bool AddZone(const rndf::Zone &_newZone);
206 
212  public: bool RemoveZone(const int _zoneId);
213 
217 
220  public: std::string Version() const;
221 
224  public: void SetVersion(const std::string &_version) const;
225 
229 
232  public: std::string Date() const;
233 
236  public: void SetDate(const std::string &_newDate) const;
237 
241 
244  public: bool Valid() const;
245 
249 
254  public: RNDFNode *Info(const rndf::UniqueId &_id) const;
255 
258  private: void UpdateCache();
259 
262  private: std::unique_ptr<RNDFPrivate> dataPtr;
263  };
264  }
265 }
266 #endif
#define IGNITION_RNDF_VISIBLE
Use to represent "symbol visible" if supported.
Definition: Helpers.hh:55
An internal private RNDF header class.
Definition: RNDF.hh:42
Abstraction for representing road segments.
Definition: Segment.hh:82
A unique id of the form x.y.z, where x and z are positive numbers and y is a non-negative number (per...
Definition: UniqueId.hh:32
An RNDF node class.
Definition: RNDFNode.hh:40
An abstraction for representing areas within free vehicle movement is permitted.
Definition: Zone.hh:85
std::string Date() const
Date.
std::string Version() const
Version.
void SetDate(const std::string &_newDate) const
Set the creation date.
~RNDFHeader()=default
Destructor.
RNDFHeader()
Default constructor.
void SetVersion(const std::string &_version) const
Set the format version.
bool Load(std::ifstream &_rndfFile, int &_lineNumber)
Parsing.
Definition: Checkpoint.hh:25
An abstraction to represent a Route Network Definition File (RNDF).
Definition: RNDF.hh:95