libosmscout  1.1.1
PublicTransport.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_PUBLIC_TRANSPORT_H
2 #define OSMSCOUT_PUBLIC_TRANSPORT_H
3 
4 /*
5  This source is part of the libosmscout library
6  Copyright (C) 2020 Tim Teulings
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22 
23 #include <memory>
24 #include <string>
25 
27 
28 #include <osmscout/TypeConfig.h>
29 
31 
32 #include <osmscout/util/Color.h>
35 
36 namespace osmscout {
37 
43  class OSMSCOUT_API PTRoute CLASS_FINAL
44  {
45  public:
49  enum class StopType : uint8_t
50  {
51  normal = 0,
52  entryOnly = 1,
53  exitOnly = 2
54  };
55 
59  enum class PlatformType : uint8_t
60  {
61  normal = 0,
62  entryOnly = 1,
63  exitOnly = 2
64  };
65 
69  class OSMSCOUT_API Stop CLASS_FINAL
70  {
71  private:
72  StopType type;
73  ObjectFileRef stop;
74 
75  public:
76  inline StopType GetType() const
77  {
78  return type;
79  }
80 
81  inline const ObjectFileRef& GetStop() const
82  {
83  return stop;
84  }
85 
86  void SetType(StopType stopType);
87  void SetStop(const ObjectFileRef& stop);
88 
89  friend PTRoute;
90  };
91 
95  class OSMSCOUT_API Platform CLASS_FINAL
96  {
97  private:
98  PlatformType type;
99  ObjectFileRef platform;
100 
101  public:
102  inline PlatformType GetType() const
103  {
104  return type;
105  }
106 
107  inline const ObjectFileRef& GetPlatform() const
108  {
109  return platform;
110  }
111 
112  void SetType(PlatformType platformType);
113  void SetPlatform(const ObjectFileRef& platform);
114 
115  friend PTRoute;
116  };
117 
118 
125  class OSMSCOUT_API Variant CLASS_FINAL
126  {
127  private:
128  std::string name;
129  std::string ref;
130  std::string operatorName;
131  std::string network;
132  std::string from;
133  std::string to;
134  Color color;
135 
136  public:
137  std::vector<Stop> stops;
138  std::vector<Platform> platforms;
139 
140  public:
141  inline std::string GetName() const
142  {
143  return name;
144  }
145 
146  inline std::string GetRef() const
147  {
148  return ref;
149  }
150 
151  inline std::string GetOperator() const
152  {
153  return operatorName;
154  }
155 
156  inline std::string GetNetwork() const
157  {
158  return network;
159  }
160 
161  inline std::string GetFrom() const
162  {
163  return from;
164  }
165 
166  inline std::string GetTo() const
167  {
168  return to;
169  }
170 
171  inline Color GetColor() const
172  {
173  return color;
174  }
175 
176  void SetName(const std::string& name);
177  void SetRef(const std::string& ref);
178  void SetOperator(const std::string& operatorName);
179  void SetNetwork(const std::string& network);
180  void SetFrom(const std::string& from);
181  void SetTo(const std::string& to);
182  void SetColor(const Color& color);
183 
184  friend PTRoute;
185  };
186 
187  private:
188  TypeInfoRef type;
189  FileOffset fileOffset;
190  FileOffset nextFileOffset;
191  std::string name;
192  std::string ref;
193  std::string operatorName;
194  std::string network;
195  Color color;
196 
197  public:
198  std::vector<Variant> variants;
199 
200  public:
201  inline PTRoute() = default;
202 
203  inline TypeInfoRef GetType() const {
204  return type;
205  }
206 
207  inline FileOffset GetFileOffset() const
208  {
209  return fileOffset;
210  }
211 
213  {
214  return nextFileOffset;
215  }
216 
217  inline std::string GetName() const
218  {
219  return name;
220  }
221 
222  inline std::string GetRef() const
223  {
224  return ref;
225  }
226 
227  inline std::string GetOperator() const
228  {
229  return operatorName;
230  }
231 
232  inline std::string GetNetwork() const
233  {
234  return network;
235  }
236 
237  inline Color GetColor() const
238  {
239  return color;
240  }
241 
242  void SetType(const TypeInfoRef& type);
243  void SetName(const std::string& name);
244  void SetRef(const std::string& ref);
245  void SetOperator(const std::string& operatorName);
246  void SetNetwork(const std::string& network);
247  void SetColor(const Color& color);
248 
249  void Read(const TypeConfig& typeConfig,
250  FileScanner& scanner);
251 
252  void Write(const TypeConfig& typeConfig,
253  FileWriter& writer) const;
254  };
255 
256  using PTRouteRef = std::shared_ptr<PTRoute>;
257 }
258 
259 #endif
FileOffset GetFileOffset() const
Definition: PublicTransport.h:207
std::string GetName() const
Definition: PublicTransport.h:217
const ObjectFileRef & GetStop() const
Definition: PublicTransport.h:81
Definition: Area.h:86
std::string GetOperator() const
Definition: PublicTransport.h:227
std::vector< Platform > platforms
Definition: PublicTransport.h:138
TypeInfoRef GetType() const
Definition: PublicTransport.h:203
std::string GetFrom() const
Definition: PublicTransport.h:161
FileOffset GetNextFileOffset() const
Definition: PublicTransport.h:212
PlatformType GetType() const
Definition: PublicTransport.h:102
std::string GetNetwork() const
Definition: PublicTransport.h:156
Color GetColor() const
Definition: PublicTransport.h:237
std::string GetRef() const
Definition: PublicTransport.h:222
Definition: Area.h:38
#define CLASS_FINAL
Definition: Compiler.h:26
#define OSMSCOUT_API
Definition: CoreImportExport.h:45
std::string GetName() const
Definition: PublicTransport.h:141
Definition: LaneAgent.h:60
Color GetColor() const
Definition: PublicTransport.h:171
friend PTRoute
Definition: PublicTransport.h:89
std::string GetTo() const
Definition: PublicTransport.h:166
StopType GetType() const
Definition: PublicTransport.h:76
const ObjectFileRef & GetPlatform() const
Definition: PublicTransport.h:107
std::vector< Stop > stops
Definition: PublicTransport.h:137
std::shared_ptr< TypeInfo > TypeInfoRef
Definition: TypeConfig.h:58
uint64_t FileOffset
Definition: OSMScoutTypes.h:47
std::string GetRef() const
Definition: PublicTransport.h:146
StopType
Definition: PublicTransport.h:49
std::shared_ptr< PTRoute > PTRouteRef
Definition: PublicTransport.h:256
std::vector< Variant > variants
Definition: PublicTransport.h:198
PlatformType
Definition: PublicTransport.h:59
std::string GetNetwork() const
Definition: PublicTransport.h:232
std::string GetOperator() const
Definition: PublicTransport.h:151