Eclipse SUMO - Simulation of Urban MObility
SUMORouteHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // Parser for routes during their loading
17 /****************************************************************************/
18 #ifndef SUMORouteHandler_h
19 #define SUMORouteHandler_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
28 #include <utils/common/SUMOTime.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MsgHandler;
37 class SUMOVTypeParameter;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
51 public:
53  enum StopPos {
58  };
59 
61  SUMORouteHandler(const std::string& file, const std::string& expectedRoot, const bool hardFail);
62 
64  virtual ~SUMORouteHandler();
65 
68  static StopPos checkStopPos(double& startPos, double& endPos, const double laneLength, const double minLength, const bool friendlyPos);
69 
71  static bool isStopPosValid(const double startPos, const double endPos, const double laneLength, const double minLength, const bool friendlyPos);
72 
74  SUMOTime getFirstDepart() const;
75 
77  SUMOTime getLastDepart() const;
78 
79 protected:
81 
82 
90  virtual void myStartElement(int element,
91  const SUMOSAXAttributes& attrs);
92 
99  virtual void myEndElement(int element);
101 
103 
104 
106  virtual void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) = 0;
107 
109  virtual void closeVehicleTypeDistribution() = 0;
110 
112  virtual void openRoute(const SUMOSAXAttributes& attrs) = 0;
113 
115  virtual void openFlow(const SUMOSAXAttributes& attrs) = 0;
116 
118  virtual void openTrip(const SUMOSAXAttributes& attrs) = 0;
120 
122 
123 
130  virtual void closeRoute(const bool mayBeDisconnected = false) = 0;
131 
133  virtual void openRouteDistribution(const SUMOSAXAttributes& attrs) = 0;
134 
136  virtual void closeRouteDistribution() = 0;
137 
139  virtual void closeVehicle() = 0;
140 
142  virtual void closeVType() = 0;
143 
145  virtual void closePerson() = 0;
146 
148  virtual void closePersonFlow() = 0;
149 
151  virtual void closeContainer() = 0;
152 
154  virtual void closeFlow() = 0;
155 
157  virtual void closeTrip() = 0;
159 
161 
162 
164  virtual void addStop(const SUMOSAXAttributes& attrs) = 0;
165 
167  virtual void addPersonTrip(const SUMOSAXAttributes& attrs) = 0;
168 
170  virtual void addWalk(const SUMOSAXAttributes& attrs) = 0;
171 
173  virtual void addPerson(const SUMOSAXAttributes& attrs) = 0;
174 
176  virtual void addContainer(const SUMOSAXAttributes& attrs) = 0;
177 
179  virtual void addRide(const SUMOSAXAttributes& attrs) = 0;
180 
182  virtual void addTransport(const SUMOSAXAttributes& attrs) = 0;
183 
185  virtual void addTranship(const SUMOSAXAttributes& attrs) = 0;
186 
188 
190  bool checkLastDepart();
191 
193  void registerLastDepart();
194 
196  void addParam(const SUMOSAXAttributes& attrs);
197 
199  bool parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput);
200 
201 protected:
203  const bool myHardFail;
204 
207 
210 
212  std::string myActiveRouteID;
213 
215  std::string myActiveRouteRefID;
216 
219 
222 
225 
227  std::vector<SUMOVehicleParameter::Stop> myActiveRouteStops;
228 
231 
234 
237 
240 
243 
246 
249 
250 private:
252  SUMORouteHandler(const SUMORouteHandler& s) = delete;
253 
255  SUMORouteHandler& operator=(const SUMORouteHandler& s) = delete;
256 };
257 
258 
259 #endif
260 
261 /****************************************************************************/
SUMORouteHandler::closeContainer
virtual void closeContainer()=0
Ends the processing of a container.
SUMORouteHandler::~SUMORouteHandler
virtual ~SUMORouteHandler()
standard destructor
Definition: SUMORouteHandler.cpp:54
SUMORouteHandler::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: SUMORouteHandler.cpp:85
SUMORouteHandler::addRide
virtual void addRide(const SUMOSAXAttributes &attrs)=0
Processing of a ride.
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
SUMOTime.h
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:41
SUMORouteHandler::closeRoute
virtual void closeRoute(const bool mayBeDisconnected=false)=0
SUMORouteHandler::parseStop
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
Definition: SUMORouteHandler.cpp:362
SUMORouteHandler::STOPPOS_INVALID_ENDPOS
@ STOPPOS_INVALID_ENDPOS
Definition: SUMORouteHandler.h:56
SUMORouteHandler::addParam
void addParam(const SUMOSAXAttributes &attrs)
assign arbitrary vehicle parameters
Definition: SUMORouteHandler.cpp:342
SUMORouteHandler::myLastDepart
SUMOTime myLastDepart
The insertion time of the vehicle read last.
Definition: SUMORouteHandler.h:209
SUMOSAXHandler.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
IDSupplier
Definition: IDSupplier.h:37
SUMORouteHandler::closeRouteDistribution
virtual void closeRouteDistribution()=0
closes (ends) the building of a distribution
SUMORouteHandler::addPerson
virtual void addPerson(const SUMOSAXAttributes &attrs)=0
Processing of a person.
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
SUMORouteHandler::closeFlow
virtual void closeFlow()=0
Ends the processing of a flow.
SUMORouteHandler::myHardFail
const bool myHardFail
flag to enable or disable hard fails
Definition: SUMORouteHandler.h:203
SUMORouteHandler::openFlow
virtual void openFlow(const SUMOSAXAttributes &attrs)=0
opens a flow for reading
SUMORouteHandler::checkStopPos
static StopPos checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
Definition: SUMORouteHandler.cpp:283
SUMORouteHandler::myActiveRouteStops
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
Definition: SUMORouteHandler.h:227
SUMOVehicleParameter.h
SUMORouteHandler::STOPPOS_VALID
@ STOPPOS_VALID
Definition: SUMORouteHandler.h:54
SUMORouteHandler::closeVehicleTypeDistribution
virtual void closeVehicleTypeDistribution()=0
closes (ends) the building of a distribution
SUMORouteHandler::myLoadedParameterised
Parameterised myLoadedParameterised
Parameterised used for saving loaded generic parameters that aren't saved in Vehicles or Vehicle Type...
Definition: SUMORouteHandler.h:233
SUMORouteHandler::myActiveRouteRefID
std::string myActiveRouteRefID
The id of the route the current route references to.
Definition: SUMORouteHandler.h:215
RGBColor
Definition: RGBColor.h:39
SUMORouteHandler::openVehicleTypeDistribution
virtual void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)=0
opens a type distribution for reading
SUMORouteHandler::checkLastDepart
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
Definition: SUMORouteHandler.cpp:60
SUMORouteHandler::STOPPOS_INVALID_STARTPOS
@ STOPPOS_INVALID_STARTPOS
Definition: SUMORouteHandler.h:55
MsgHandler
Definition: MsgHandler.h:38
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
SUMORouteHandler::myActiveRouteColor
const RGBColor * myActiveRouteColor
The currently parsed route's color.
Definition: SUMORouteHandler.h:221
SUMORouteHandler::closePerson
virtual void closePerson()=0
Ends the processing of a person.
SUMORouteHandler::addWalk
virtual void addWalk(const SUMOSAXAttributes &attrs)=0
add a fully specified walk
SUMORouteHandler::myCurrentCosts
double myCurrentCosts
The currently parsed route costs.
Definition: SUMORouteHandler.h:224
SUMORouteHandler::myEndElement
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: SUMORouteHandler.cpp:215
SUMORouteHandler::myEndDefault
SUMOTime myEndDefault
The default value for flow ends.
Definition: SUMORouteHandler.h:242
SUMORouteHandler::openRoute
virtual void openRoute(const SUMOSAXAttributes &attrs)=0
opens a route for reading
SUMORouteHandler::SUMORouteHandler
SUMORouteHandler(const std::string &file, const std::string &expectedRoot, const bool hardFail)
standard constructor
Definition: SUMORouteHandler.cpp:39
SUMORouteHandler::closeTrip
virtual void closeTrip()=0
Ends the processing of a trip.
SUMORouteHandler::openTrip
virtual void openTrip(const SUMOSAXAttributes &attrs)=0
opens a trip for reading
IDSupplier.h
SUMORouteHandler::myActiveRouteProbability
double myActiveRouteProbability
The probability of the current route.
Definition: SUMORouteHandler.h:218
SUMORouteHandler::myVehicleParameter
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
Definition: SUMORouteHandler.h:206
SUMORouteHandler::closeVType
virtual void closeVType()=0
Ends the processing of a vehicle type.
SUMORouteHandler::registerLastDepart
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
Definition: SUMORouteHandler.cpp:72
SUMORouteHandler::myFirstDepart
SUMOTime myFirstDepart
the first read departure time
Definition: SUMORouteHandler.h:245
SUMORouteHandler::addContainer
virtual void addContainer(const SUMOSAXAttributes &attrs)=0
Processing of a container.
SUMORouteHandler::addTranship
virtual void addTranship(const SUMOSAXAttributes &attrs)=0
Processing of a tranship.
SUMORouteHandler::addPersonTrip
virtual void addPersonTrip(const SUMOSAXAttributes &attrs)=0
add a routing request for a walking or intermodal person
SUMORouteHandler::myIdSupplier
IDSupplier myIdSupplier
generates numerical ids
Definition: SUMORouteHandler.h:236
SUMORouteHandler::STOPPOS_INVALID_LANELENGTH
@ STOPPOS_INVALID_LANELENGTH
Definition: SUMORouteHandler.h:57
SUMORouteHandler::operator=
SUMORouteHandler & operator=(const SUMORouteHandler &s)=delete
Invalidated assignment operator.
SUMORouteHandler::closePersonFlow
virtual void closePersonFlow()=0
Ends the processing of a person.
SUMORouteHandler
Parser for routes during their loading.
Definition: SUMORouteHandler.h:50
SUMORouteHandler::addStop
virtual void addStop(const SUMOSAXAttributes &attrs)=0
Processing of a stop.
config.h
SUMORouteHandler::openRouteDistribution
virtual void openRouteDistribution(const SUMOSAXAttributes &attrs)=0
opens a route distribution for reading
SUMORouteHandler::myCurrentVType
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
Definition: SUMORouteHandler.h:230
SUMORouteHandler::StopPos
StopPos
enum for stops
Definition: SUMORouteHandler.h:53
SUMORouteHandler::myBeginDefault
SUMOTime myBeginDefault
The default value for flow begins.
Definition: SUMORouteHandler.h:239
SUMORouteHandler::closeVehicle
virtual void closeVehicle()=0
Ends the processing of a vehicle.
SUMORouteHandler::addTransport
virtual void addTransport(const SUMOSAXAttributes &attrs)=0
Processing of a transport.
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
SUMORouteHandler::getFirstDepart
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
Definition: SUMORouteHandler.cpp:330
SUMORouteHandler::myActiveRouteID
std::string myActiveRouteID
The id of the current route.
Definition: SUMORouteHandler.h:212
SUMORouteHandler::myInsertStopEdgesAt
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
Definition: SUMORouteHandler.h:248
SUMORouteHandler::isStopPosValid
static bool isStopPosValid(const double startPos, const double endPos, const double laneLength, const double minLength, const bool friendlyPos)
check if start and end position of a stop is valid
Definition: SUMORouteHandler.cpp:320
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:572
SUMORouteHandler::getLastDepart
SUMOTime getLastDepart() const
Returns the last loaded depart time.
Definition: SUMORouteHandler.cpp:336