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-2020 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:
54  MSRouteHandler(const std::string& file, bool addVehiclesDirectly);
55 
57  virtual ~MSRouteHandler();
58 
60  static std::mt19937* getParsingRNG() {
61  return &myParsingRNG;
62  }
63 
64 protected:
66 
67 
75  virtual void myStartElement(int element,
76  const SUMOSAXAttributes& attrs);
78 
85  void parseFromViaTo(SumoXMLTag tag, const SUMOSAXAttributes& attrs);
86 
89 
92 
94  void openRoute(const SUMOSAXAttributes& attrs);
95 
97  void openFlow(const SUMOSAXAttributes& attrs);
98 
100  void openRouteFlow(const SUMOSAXAttributes& attrs);
101 
103  void openTrip(const SUMOSAXAttributes& attrs);
104 
111  void closeRoute(const bool mayBeDisconnected = false);
112 
114  void openRouteDistribution(const SUMOSAXAttributes& attrs);
115 
117  void closeRouteDistribution();
118 
120  virtual void closeVehicle();
121 
123  void closeVType();
124 
126  void closePerson();
127 
129  void closePersonFlow();
130 
132  void closeContainer();
133 
135  void closeFlow();
136 
138  void closeTrip();
139 
141  void addStop(const SUMOSAXAttributes& attrs);
142 
144  void addPersonTrip(const SUMOSAXAttributes& attrs);
145 
147  void addWalk(const SUMOSAXAttributes& attrs);
148 
150  void addPerson(const SUMOSAXAttributes& attrs);
151 
153  void addContainer(const SUMOSAXAttributes& attrs);
154 
156  void addRide(const SUMOSAXAttributes& attrs);
157 
159  void addTransport(const SUMOSAXAttributes& attrs);
160 
162  void addTranship(const SUMOSAXAttributes& attrs);
163 
165  void parseWalkPositions(const SUMOSAXAttributes& attrs, const std::string& personID,
166  const MSEdge* fromEdge, const MSEdge*& toEdge,
167  double& departPos, double& arrivalPos, MSStoppingPlace*& bs,
168  const MSStage* const lastStage, bool& ok);
169 
170 protected:
173 
177 
180 
183 
186 
189 
192 
195 
198 
201 
203  static std::mt19937 myParsingRNG;
204 
205 private:
207  void deleteActivePlans();
208 
210  void addFlowPerson(SUMOTime depart, MSVehicleType* type, const std::string& baseID, int i);
211 
213  static std::string getDefaultGroup(const std::string& personID);
214 
216  MSRoute* addVehicleStopsToImplicitRoute(const MSRoute* route, bool isPermanent);
217 
219  MSRouteHandler(const MSRouteHandler& s) = delete;
220 
223 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
long long int SUMOTime
Definition: SUMOTime.h:31
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.
static std::mt19937 myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
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 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.
static std::mt19937 * getParsingRNG()
get parsing RNG
SUMOTime myActiveRoutePeriod
void closeVType()
Ends the processing of a vehicle type.
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
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
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.
void closeContainer()
Ends the processing of a container.
MSTransportable::MSTransportablePlan * myActiveContainerPlan
The plan of the current 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 deleteActivePlans()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
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
MSTransportable::MSTransportablePlan * myActivePlan
The plan of the current person.
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
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 addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
static std::string getDefaultGroup(const std::string &personID)
determine the default group for rides and trips
void addFlowPerson(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 addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
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.