Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SUMORouteHandler.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// Parser for routes during their loading
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
29
30
31// ===========================================================================
32// class declarations
33// ===========================================================================
34class MsgHandler;
36
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
49public:
57
59 SUMORouteHandler(const std::string& file, const std::string& expectedRoot, const bool hardFail);
60
62 virtual ~SUMORouteHandler();
63
66 static StopPos checkStopPos(double& startPos, double& endPos, const double laneLength, const double minLength, const bool friendlyPos);
67
70
72 SUMOTime getLastDepart() const;
73
76 return &myParsingRNG;
77 }
78
79protected:
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
110
112 virtual void openRoute(const SUMOSAXAttributes& attrs) = 0;
113
115 virtual void openFlow(const SUMOSAXAttributes& attrs) = 0;
116
118 virtual void openRouteFlow(const SUMOSAXAttributes& attrs) = 0;
119
121 virtual void openTrip(const SUMOSAXAttributes& attrs) = 0;
123
125
126
133 virtual void closeRoute(const bool mayBeDisconnected = false) = 0;
134
136 virtual void openRouteDistribution(const SUMOSAXAttributes& attrs) = 0;
137
139 virtual void closeRouteDistribution() = 0;
140
142 virtual void closeVehicle() = 0;
143
145 virtual void closeVType() = 0;
146
148 virtual void closePerson() = 0;
149
151 virtual void closePersonFlow() = 0;
152
154 virtual void closeContainer() = 0;
155
157 virtual void closeContainerFlow() = 0;
158
160 virtual void closeFlow() = 0;
161
163 virtual void closeTrip() = 0;
165
167
168
170 virtual void addTransportable(const SUMOSAXAttributes& attrs, const bool isPerson) {
171 UNUSED_PARAMETER(attrs);
172 UNUSED_PARAMETER(isPerson);
173 }
174
176 virtual Parameterised* addStop(const SUMOSAXAttributes& attrs) = 0;
177
179 virtual void addPersonTrip(const SUMOSAXAttributes& attrs) = 0;
180
182 virtual void addWalk(const SUMOSAXAttributes& attrs) = 0;
183
185 virtual void addRide(const SUMOSAXAttributes& attrs) = 0;
186
188 virtual void addTransport(const SUMOSAXAttributes& attrs) = 0;
189
191 virtual void addTranship(const SUMOSAXAttributes& attrs) = 0;
192
194
196 virtual bool checkLastDepart();
197
199 void registerLastDepart();
200
202 void addParam(const SUMOSAXAttributes& attrs);
203
205 bool parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput);
206
207protected:
208 virtual const SUMOVTypeParameter* getVTypeParameter(const std::string& refid) = 0;
209
210protected:
212 const bool myHardFail;
213
216
218 std::vector<Parameterised*> myParamStack;
219
222
224 std::string myActiveRouteID;
225
228
231
234
237
240
243
245 std::string myCurrentVTypeRef;
246
249
252
255
258
261
263 std::vector<int> myElementStack;
264
267
269 std::set<std::string> mySkippedVehicles;
270
273
274private:
277
280};
long long int SUMOTime
Definition GUI.h:36
std::vector< SUMOVehicleParameter::Stop > StopParVector
An upper class for objects with additional parameters.
Parser for routes during their loading.
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
virtual void openTrip(const SUMOSAXAttributes &attrs)=0
opens a trip for reading
StopPos
enum for stops
std::set< std::string > mySkippedVehicles
IDs of skipped vehicles to suppress errors for the triggered transportables within.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
virtual void openFlow(const SUMOSAXAttributes &attrs)=0
opens a flow for reading
virtual void closeContainer()=0
Ends the processing of a container.
SUMOTime myFirstDepart
the first read departure time
virtual void addWalk(const SUMOSAXAttributes &attrs)=0
add a fully specified walk
SUMOTime myBeginDefault
The default value for flow begins.
double myCurrentCosts
The currently parsed route costs.
virtual void openRouteDistribution(const SUMOSAXAttributes &attrs)=0
opens a route distribution for reading
bool myAllowInternalRoutes
whether references to internal routes are allowed in this context
std::string myActiveRouteID
The id of the current route.
static SumoRNG * getParsingRNG()
get parsing RNG
virtual void openRoute(const SUMOSAXAttributes &attrs)=0
opens a route for reading
virtual void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)=0
opens a type distribution for reading
virtual ~SUMORouteHandler()
standard destructor
SUMORouteHandler(const SUMORouteHandler &s)=delete
Invalidated copy constructor.
virtual void closeVehicle()=0
Ends the processing of a vehicle.
virtual void closeFlow()=0
Ends the processing of a flow.
virtual void closePersonFlow()=0
Ends the processing of a person flow.
std::vector< Parameterised * > myParamStack
The stack of currently parsed parameterised objects.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
virtual void addRide(const SUMOSAXAttributes &attrs)=0
Processing of a ride.
virtual void addTranship(const SUMOSAXAttributes &attrs)=0
Processing of a tranship.
SUMOTime getLastDepart() const
Returns the last loaded depart time.
const bool myHardFail
flag to enable or disable hard fails
static SumoRNG myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
std::vector< int > myElementStack
hierarchy of elements being parsed
StopParVector myActiveRouteStops
List of the stops on the parsed route.
std::string myCurrentVTypeRef
if the currently parsed vType is only a reference to an existing type, store the refId
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
virtual void addTransport(const SUMOSAXAttributes &attrs)=0
Processing of a transport.
virtual void closeRoute(const bool mayBeDisconnected=false)=0
virtual void closePerson()=0
Ends the processing of a person.
SUMOTime myLastDepart
The insertion time of the vehicle read last.
SUMOTime myEndDefault
The default value for flow ends.
virtual void closeVehicleTypeDistribution()=0
closes (ends) the building of a distribution
static StopPos checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void addParam(const SUMOSAXAttributes &attrs)
assign arbitrary vehicle parameters
virtual void closeContainerFlow()=0
Ends the processing of a container flow.
virtual const SUMOVTypeParameter * getVTypeParameter(const std::string &refid)=0
virtual Parameterised * addStop(const SUMOSAXAttributes &attrs)=0
Processing of a stop.
virtual void closeTrip()=0
Ends the processing of a trip.
double myActiveRouteProbability
The probability of the current route.
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
SUMORouteHandler & operator=(const SUMORouteHandler &s)=delete
Invalidated assignment operator.
virtual void openRouteFlow(const SUMOSAXAttributes &attrs)=0
opens a route flow for reading
double myCurrentVTypeProbability
if the currently parsed vType is only a reference, store the probability here
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
virtual void addTransportable(const SUMOSAXAttributes &attrs, const bool isPerson)
Processing of a person or container.
std::string myActiveRouteRefID
The id of the route the current route references to.
const RGBColor * myActiveRouteColor
The currently parsed route's color.
virtual void addPersonTrip(const SUMOSAXAttributes &attrs)=0
add a routing request for a walking or intermodal person
virtual void myEndElement(int element)
Called when a closing tag occurs.
virtual void closeVType()=0
Ends the processing of a vehicle type.
virtual void closeRouteDistribution()=0
closes (ends) the building of a distribution
virtual bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
#define UNUSED_PARAMETER(x)