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-2022 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>
26 #include <utils/common/SUMOTime.h>
30 #include "MSVehicle.h"
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MSEdge;
37 class MSVehicleType;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
52 public:
53 
55  enum class ObjectTypeEnum {
56  PERSON,
57  CONTAINER,
58  UNDEFINED
59  };
60 
62  MSRouteHandler(const std::string& file, bool addVehiclesDirectly);
63 
65  virtual ~MSRouteHandler();
66 
68  static SumoRNG* getParsingRNG() {
69  return &myParsingRNG;
70  }
71 
72 
73 protected:
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 
126  void closeRouteDistribution();
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 
185 protected:
188 
192 
195 
197  std::string myActiveTypeName;
198 
201 
204 
207 
210 
213 
216 
219 
221  std::string myScaleSuffix;
222 
225 
226 private:
229 
232 
234  void closeTransportableFlow();
235 
237  void closeTransportable();
238 
240  void addFlowTransportable(SUMOTime depart, MSVehicleType* type, const std::string& baseID, int i);
241 
243  MSRoute* addVehicleStopsToImplicitRoute(const MSRoute* route, bool isPermanent);
244 
246  MSRouteHandler(const MSRouteHandler& s) = delete;
247 
250 
252  void checkTransportableType();
253 
255  void addRideOrTransport(const SUMOSAXAttributes& attrs, const SumoXMLTag modeTag);
256 
257 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
long long int SUMOTime
Definition: SUMOTime.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.
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;.
MSRouteHandler & operator=(const MSRouteHandler &s)=delete
Invalidated assignment operator.
void deleteActivePlanAndVehicleParameter()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
static SumoRNG * getParsingRNG()
get parsing RNG
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
void closeContainerFlow()
Ends the processing of a containerFlow.
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.
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
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)
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)
MSRoute * addVehicleStopsToImplicitRoute(const MSRoute *route, bool isPermanent)
adapt implicit route (edges derived from stops) to additional vehicle-stops
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
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
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
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 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 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:62
Parser for routes during their loading.
Encapsulated SAX-Attributes.
Definition of vehicle stop (position and duration)