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-2025 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
69 static bool isStopPosValid(const double startPos, const double endPos, const double laneLength, const double minLength, const bool friendlyPos);
70
73
75 SUMOTime getLastDepart() const;
76
77protected:
79
80
88 virtual void myStartElement(int element,
89 const SUMOSAXAttributes& attrs);
90
97 virtual void myEndElement(int element);
99
101
102
104 virtual void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) = 0;
105
108
110 virtual void openRoute(const SUMOSAXAttributes& attrs) = 0;
111
113 virtual void openFlow(const SUMOSAXAttributes& attrs) = 0;
114
116 virtual void openRouteFlow(const SUMOSAXAttributes& attrs) = 0;
117
119 virtual void openTrip(const SUMOSAXAttributes& attrs) = 0;
121
123
124
131 virtual void closeRoute(const bool mayBeDisconnected = false) = 0;
132
134 virtual void openRouteDistribution(const SUMOSAXAttributes& attrs) = 0;
135
137 virtual void closeRouteDistribution() = 0;
138
140 virtual void closeVehicle() = 0;
141
143 virtual void closeVType() = 0;
144
146 virtual void closePerson() = 0;
147
149 virtual void closePersonFlow() = 0;
150
152 virtual void closeContainer() = 0;
153
155 virtual void closeContainerFlow() = 0;
156
158 virtual void closeFlow() = 0;
159
161 virtual void closeTrip() = 0;
163
165
166
168 virtual void addTransportable(const SUMOSAXAttributes& attrs, const bool isPerson) {
169 UNUSED_PARAMETER(attrs);
170 UNUSED_PARAMETER(isPerson);
171 }
172
174 virtual Parameterised* addStop(const SUMOSAXAttributes& attrs) = 0;
175
177 virtual void addPersonTrip(const SUMOSAXAttributes& attrs) = 0;
178
180 virtual void addWalk(const SUMOSAXAttributes& attrs) = 0;
181
183 virtual void addRide(const SUMOSAXAttributes& attrs) = 0;
184
186 virtual void addTransport(const SUMOSAXAttributes& attrs) = 0;
187
189 virtual void addTranship(const SUMOSAXAttributes& attrs) = 0;
190
192
194 virtual bool checkLastDepart();
195
197 void registerLastDepart();
198
200 void addParam(const SUMOSAXAttributes& attrs);
201
203 bool parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput);
204
205protected:
207 const bool myHardFail;
208
211
213 std::vector<Parameterised*> myParamStack;
214
217
219 std::string myActiveRouteID;
220
223
226
229
232
235
238
241
244
247
250
252 std::vector<int> myElementStack;
253
256
258 std::set<std::string> mySkippedVehicles;
259
260private:
263
266};
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
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
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.
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
std::vector< int > myElementStack
hierarchy of elements being parsed
StopParVector myActiveRouteStops
List of the stops on the parsed route.
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 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
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)