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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Parser for routes during their loading
18 /****************************************************************************/
19 #ifndef SUMORouteHandler_h
20 #define SUMORouteHandler_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
29 #include <utils/common/SUMOTime.h>
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class MsgHandler;
38 class SUMOVTypeParameter;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
52 public:
54  SUMORouteHandler(const std::string& file, const std::string& expectedRoot);
55 
57  virtual ~SUMORouteHandler();
58 
60  SUMOTime getLastDepart() const;
61 
63  static bool checkStopPos(double& startPos, double& endPos, const double laneLength,
64  const double minLength, const bool friendlyPos);
65 
68  return myFirstDepart;
69  }
70 
71 protected:
73 
74 
82  virtual void myStartElement(int element,
83  const SUMOSAXAttributes& attrs);
84 
85 
92  virtual void myEndElement(int element);
94 
95 
97  virtual void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) = 0;
98 
100  virtual void closeVehicleTypeDistribution() = 0;
101 
103  virtual void openRoute(const SUMOSAXAttributes& attrs) = 0;
104 
110  virtual void closeRoute(const bool mayBeDisconnected = false) = 0;
111 
113  virtual void openRouteDistribution(const SUMOSAXAttributes& attrs) = 0;
114 
116  virtual void closeRouteDistribution() = 0;
117 
119  virtual void closeVehicle() = 0;
120 
122  virtual void closePerson() = 0;
123 
125  virtual void closeContainer() = 0;
126 
128  virtual void closeFlow() = 0;
129 
131  virtual void addStop(const SUMOSAXAttributes& attrs) = 0;
132 
134  virtual void addPersonTrip(const SUMOSAXAttributes& attrs) = 0;
135 
137  virtual void addWalk(const SUMOSAXAttributes& attrs) = 0;
138 
140  bool checkLastDepart();
141 
143  void registerLastDepart();
144 
146  void addParam(const SUMOSAXAttributes& attrs);
147 
149  bool parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput);
150 
151 protected:
154 
157 
159  std::string myActiveRouteID;
160 
162  std::string myActiveRouteRefID;
163 
166 
169 
172 
174  std::vector<SUMOVehicleParameter::Stop> myActiveRouteStops;
175 
178 
181 
184 
187 
190 
193 
194 private:
197 
200 
201 };
202 
203 
204 #endif
205 
206 /****************************************************************************/
virtual void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)=0
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.
long long int SUMOTime
Definition: SUMOTime.h:36
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
virtual void closeRoute(const bool mayBeDisconnected=false)=0
Parser for routes during their loading.
SUMORouteHandler(const std::string &file, const std::string &expectedRoot)
standard constructor
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.
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