SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMORouteHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Parser for routes during their loading
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef SUMORouteHandler_h
23 #define SUMORouteHandler_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
36 #include <utils/common/SUMOTime.h>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class MsgHandler;
45 class SUMOVTypeParameter;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
59 public:
61  SUMORouteHandler(const std::string& file);
62 
64  virtual ~SUMORouteHandler();
65 
67  SUMOTime getLastDepart() const;
68 
70  static bool checkStopPos(SUMOReal& startPos, SUMOReal& endPos, const SUMOReal laneLength,
71  const SUMOReal minLength, const bool friendlyPos);
72 
75  return myFirstDepart;
76  }
77 
78 protected:
80 
81 
89  virtual void myStartElement(int element,
90  const SUMOSAXAttributes& attrs);
91 
92 
99  virtual void myEndElement(int element);
101 
102 
104  virtual void openVehicleTypeDistribution(const SUMOSAXAttributes& attrs) = 0;
105 
107  virtual void closeVehicleTypeDistribution() = 0;
108 
110  virtual void openRoute(const SUMOSAXAttributes& attrs) = 0;
111 
117  virtual void closeRoute(const bool mayBeDisconnected = false) = 0;
118 
120  virtual void openRouteDistribution(const SUMOSAXAttributes& attrs) = 0;
121 
123  virtual void closeRouteDistribution() = 0;
124 
126  virtual void closeVehicle() = 0;
127 
129  virtual void closePerson() = 0;
130 
132  virtual void closeFlow() = 0;
133 
135  virtual void addStop(const SUMOSAXAttributes& attrs) = 0;
136 
138  bool checkLastDepart();
139 
141  void registerLastDepart();
142 
144  void addParam(const SUMOSAXAttributes& attrs);
145 
147  bool parseStop(SUMOVehicleParameter::Stop& stop, const SUMOSAXAttributes& attrs, std::string errorSuffix, MsgHandler* const errorOutput);
148 
149 protected:
152 
155 
157  std::string myActiveRouteID;
158 
160  std::string myActiveRouteRefID;
161 
164 
167 
170 
172  std::vector<SUMOVehicleParameter::Stop> myActiveRouteStops;
173 
176 
179 
182 
185 
188 
189 private:
192 
195 
196 };
197 
198 
199 #endif
200 
201 /****************************************************************************/
virtual void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)=0
SUMOReal myCurrentCosts
The currently parsed route costs.
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, 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.
static bool checkStopPos(SUMOReal &startPos, SUMOReal &endPos, const SUMOReal laneLength, const SUMOReal minLength, const bool friendlyPos)
check start and end position of a stop
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
SUMOReal 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.
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
IDSupplier myIdSupplier
generates numerical ids
SUMOTime myBeginDefault
The default value for flow begins.
virtual void closeVehicle()=0
Ends the processing of a vehicle.
Encapsulated SAX-Attributes.
void addParam(const SUMOSAXAttributes &attrs)
assign arbitrary vehicle parameters
virtual ~SUMORouteHandler()
standard destructor
SUMORouteHandler(const std::string &file)
standard constructor
virtual void closeRoute(const bool mayBeDisconnected=false)=0
Parser for routes during their loading.
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
int SUMOTime
Definition: SUMOTime.h:43
virtual void closeFlow()=0
Ends the processing of a flow.
const RGBColor * myActiveRouteColor
The currently parsed route&#39;s color.
virtual void closePerson()=0
Ends the processing of a person.
#define SUMOReal
Definition: config.h:218
SUMOTime getLastDepart() const
Returns the last loaded depart time.
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