Eclipse SUMO - Simulation of Urban MObility
MSRouteHandler.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-2023 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 and container for routes during their loading
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <string>
30#include "MSVehicle.h"
31
32
33// ===========================================================================
34// class declarations
35// ===========================================================================
36class MSEdge;
37class MSVehicleType;
38
39
40// ===========================================================================
41// class definitions
42// ===========================================================================
52public:
53
55 enum class ObjectTypeEnum {
56 PERSON,
58 UNDEFINED
59 };
60
62 MSRouteHandler(const std::string& file, bool addVehiclesDirectly);
63
65 virtual ~MSRouteHandler();
66
69 return &myParsingRNG;
70 }
71
72
73protected:
75
76
84 virtual void myStartElement(int element,
85 const SUMOSAXAttributes& attrs);
87
94 void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs);
95
98
101
103 void openRoute(const SUMOSAXAttributes& attrs);
104
106 void openFlow(const SUMOSAXAttributes& attrs);
107
109 void openRouteFlow(const SUMOSAXAttributes& attrs);
110
112 void openTrip(const SUMOSAXAttributes& attrs);
113
120 void closeRoute(const bool mayBeDisconnected = false);
121
123 void openRouteDistribution(const SUMOSAXAttributes& attrs);
124
127
129 virtual void closeVehicle();
130
132 void closeVType();
133
135 void closePerson();
136
138 void closePersonFlow();
139
141 void closeContainer();
142
144 void closeContainerFlow();
145
147 void closeFlow();
148
150 void closeTrip();
151
153 MSStoppingPlace* retrieveStoppingPlace(const SUMOSAXAttributes& attrs, const std::string& errorSuffix, SUMOVehicleParameter::Stop* stopParam = nullptr);
154
156 void addStop(const SUMOSAXAttributes& attrs);
157
159 void addPersonTrip(const SUMOSAXAttributes& attrs);
160
162 void addWalk(const SUMOSAXAttributes& attrs);
163
165 void addPerson(const SUMOSAXAttributes& attrs);
166
168 void addContainer(const SUMOSAXAttributes& attrs);
169
171 void addRide(const SUMOSAXAttributes& attrs);
172
174 void addTranship(const SUMOSAXAttributes& attrs);
175
177 void addTransport(const SUMOSAXAttributes& attrs);
178
180 void parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
181 const MSEdge* fromEdge, const MSEdge*& toEdge,
182 double& departPos, double& arrivalPos, MSStoppingPlace*& bs,
183 const MSStage* const lastStage, bool& ok);
184
185protected:
188
192
195
198
201
203 std::string myActiveTypeName;
204
207
210
213
216
219
222
225
228
230 std::string myScaleSuffix;
231
234
237
238private:
241
244
247
249 void closeTransportable();
250
252 int addFlowTransportable(SUMOTime depart, MSVehicleType* type, const std::string& baseID, int i);
253
254 double interpretDepartPosLat(const std::string& value, int departLane, const std::string& element);
255
258
260 MSRouteHandler(const MSRouteHandler& s) = delete;
261
264
267
269 void addRideOrTransport(const SUMOSAXAttributes& attrs, const SumoXMLTag modeTag);
270
271};
long long int SUMOTime
Definition: GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition: Route.h:32
SumoXMLTag
Numbers representing SUMO-XML - element names.
A road/street connecting two junctions.
Definition: MSEdge.h:77
Parser and container for routes during their loading.
RandomDistributor< ConstMSRoutePtr > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
void addRideOrTransport(const SUMOSAXAttributes &attrs, const SumoXMLTag modeTag)
Processing of a transport.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
ConstMSRoutePtr addVehicleStopsToImplicitRoute(ConstMSRoutePtr route, bool isPermanent)
adapt implicit route (edges derived from stops) to additional vehicle-stops
void deleteActivePlanAndVehicleParameter()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
bool myAmLoadingState
whether a state file is being loaded
MSRouteHandler(const MSRouteHandler &s)=delete
Invalidated copy constructor.
void resetActivePlanAndVehicleParameter()
reset MSTransportablePlans after transportable tag closes
SUMOTime myActiveRoutePeriod
bool myHaveVia
Wether an object with 'via'-attribute is being parsed.
void closeContainerFlow()
Ends the processing of a containerFlow.
int addFlowTransportable(SUMOTime depart, MSVehicleType *type, const std::string &baseID, int i)
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
void closeTransportable()
ends the processing of a transportable (as person or container)
void closeVType()
Ends the processing of a vehicle type.
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
MSStoppingPlace * retrieveStoppingPlace(const SUMOSAXAttributes &attrs, const std::string &errorSuffix, SUMOVehicleParameter::Stop *stopParam=nullptr)
Parse destination stop.
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
MSRouteHandler & operator=(const MSRouteHandler &s)=delete
Invalidated assignment operator.
void closeRouteDistribution()
closes (ends) the building of a distribution
static SumoRNG myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
void closeFlow()
Ends the processing of a flow.
MSTransportable::MSTransportablePlan * myActiveTransportablePlan
The plan of the current transportable (person or container)
void closeContainer()
Ends the processing of a container.
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
void closePersonFlow()
Ends the processing of a personFlow.
void openRouteFlow(const SUMOSAXAttributes &attrs)
opens a route flow for reading
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
SUMOTime myActiveRouteReplacedAtTime
The time at which this route was replaced (from vehroute-output)
void closePerson()
Ends the processing of a person.
void closeTrip()
Ends the processing of a trip.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
ConstMSEdgeVector myActiveRoute
The current route.
int myActiveRouteRepeat
number of repetitions of the active route
ObjectTypeEnum myActiveType
The type of the current object.
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
virtual void closeVehicle()
Ends the processing of a vehicle (note: is virtual because is reimplemented in MSStateHandler)
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
int myActiveRouteReplacedIndex
The index at which this route was replaced (from vehroute-output)
void openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
std::string myScaleSuffix
prefix when copying vehicles with –scale
ObjectTypeEnum
enum for object type
double interpretDepartPosLat(const std::string &value, int departLane, const std::string &element)
virtual ~MSRouteHandler()
standard destructor
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer.
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
bool myReplayRerouting
whether loaded rerouting events shall be replayed
static SumoRNG * getParsingRNG()
get parsing RNG
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const MSEdge *fromEdge, const MSEdge *&toEdge, double &departPos, double &arrivalPos, MSStoppingPlace *&bs, const MSStage *const lastStage, bool &ok)
@ brief parse depart- and arrival positions of a walk
void checkTransportableType()
Check if vtype of given transportable exists.
std::string myActiveTypeName
The name of the current object type.
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
void closeTransportableFlow()
ends the flow of a transportable
void closeRoute(const bool mayBeDisconnected=false)
closes (ends) the building of a route.
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
A lane area vehicles can halt at.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
The car-following model and parameter.
Definition: MSVehicleType.h:63
Parser for routes during their loading.
Encapsulated SAX-Attributes.
Definition of vehicle stop (position and duration)