SUMO - Simulation of Urban MObility
SUMORouteHandler.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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Parser for routes during their loading
20 /****************************************************************************/
21 #ifndef SUMORouteHandler_h
22 #define SUMORouteHandler_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
35 #include <utils/common/SUMOTime.h>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MsgHandler;
44 class SUMOVTypeParameter;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
58 public:
60  SUMORouteHandler(const std::string& file);
61 
63  virtual ~SUMORouteHandler();
64 
66  SUMOTime getLastDepart() const;
67 
69  static bool checkStopPos(double& startPos, double& endPos, const double laneLength,
70  const double minLength, const bool friendlyPos);
71 
74  return myFirstDepart;
75  }
76 
77 protected:
79 
80 
88  virtual void myStartElement(int element,
89  const SUMOSAXAttributes& attrs);
90 
91 
98  virtual void myEndElement(int element);
100 
101 
103  virtual void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) = 0;
104 
106  virtual void closeVehicleTypeDistribution() = 0;
107 
109  virtual void openRoute(const SUMOSAXAttributes& attrs) = 0;
110 
116  virtual void closeRoute(const bool mayBeDisconnected = false) = 0;
117 
119  virtual void openRouteDistribution(const SUMOSAXAttributes& attrs) = 0;
120 
122  virtual void closeRouteDistribution() = 0;
123 
125  virtual void closeVehicle() = 0;
126 
128  virtual void closePerson() = 0;
129 
131  virtual void closeContainer() = 0;
132 
134  virtual void closeFlow() = 0;
135 
137  virtual void addStop(const SUMOSAXAttributes& attrs) = 0;
138 
140  virtual void addPersonTrip(const SUMOSAXAttributes& attrs) = 0;
141 
143  virtual void addWalk(const SUMOSAXAttributes& attrs) = 0;
144 
146  bool checkLastDepart();
147 
149  void registerLastDepart();
150 
152  void addParam(const SUMOSAXAttributes& attrs);
153 
155  bool parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput);
156 
157 protected:
160 
163 
165  std::string myActiveRouteID;
166 
168  std::string myActiveRouteRefID;
169 
172 
175 
178 
180  std::vector<SUMOVehicleParameter::Stop> myActiveRouteStops;
181 
184 
187 
190 
193 
196 
199 
202 
203 private:
206 
209 
210 };
211 
212 
213 #endif
214 
215 /****************************************************************************/
virtual void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)=0
virtual void addPersonTrip(const SUMOSAXAttributes &attrs)=0
add a routing request for a walking or intermodal person
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual void myEndElement(int element)
Called when a closing tag occurs.
SUMOTime myFirstDepart
the first read departure time
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
SUMOTime myEndDefault
The default value for flow ends.
Structure representing possible vehicle parameter.
virtual void addStop(const SUMOSAXAttributes &attrs)=0
Processing of a stop.
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
double myActiveRouteProbability
The probability of the current route.
SUMORouteHandler & operator=(const SUMORouteHandler &s)
Invalidated assignment operator.
virtual void openRouteDistribution(const SUMOSAXAttributes &attrs)=0
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
std::string myActiveRouteID
The id of the current route.
SAX-handler base for SUMO-files.
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
SUMOTime getLastDepart() const
Returns the last loaded depart time.
IDSupplier myIdSupplier
generates numerical ids
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
SUMOTime myBeginDefault
The default value for flow begins.
virtual void closeVehicle()=0
Ends the processing of a vehicle.
virtual void closeContainer()=0
Ends the processing of a container.
Encapsulated SAX-Attributes.
void addParam(const SUMOSAXAttributes &attrs)
assign arbitrary vehicle parameters
virtual ~SUMORouteHandler()
standard destructor
SUMORouteHandler(const std::string &file)
standard constructor
SumoXMLTag myDefaultCFModel
the default car following model
virtual void closeRoute(const bool mayBeDisconnected=false)=0
Parser for routes during their loading.
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
Structure representing possible vehicle parameter.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
virtual void closeVehicleTypeDistribution()=0
SUMOTime myLastDepart
The insertion time of the vehicle read last.
Definition of vehicle stop (position and duration)
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
virtual void closeRouteDistribution()=0
virtual void closeFlow()=0
Ends the processing of a flow.
const RGBColor * myActiveRouteColor
The currently parsed route&#39;s color.
double myCurrentCosts
The currently parsed route costs.
virtual void closePerson()=0
Ends the processing of a person.
long long int SUMOTime
Definition: TraCIDefs.h:51
virtual void addWalk(const SUMOSAXAttributes &attrs)=0
add a fully specified walk
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
std::string myActiveRouteRefID
The id of the route the current route references to.
virtual void openRoute(const SUMOSAXAttributes &attrs)=0