SUMO - Simulation of Urban MObility
SUMOVehicleParserHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2008-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 /****************************************************************************/
20 // Helper methods for parsing vehicle attributes
21 /****************************************************************************/
22 #ifndef SUMOVehicleParserHelper_h
23 #define SUMOVehicleParserHelper_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 
35 #include <random>
36 #include <string>
37 #include <utils/common/SUMOTime.h>
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class SUMOSAXAttributes;
46 class SUMOVTypeParameter;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
59 public:
70  static SUMOVehicleParameter* parseFlowAttributes(const SUMOSAXAttributes& attrs, const SUMOTime beginDefault, const SUMOTime endDefault);
71 
72 
87  const bool optionalID = false, const bool skipDepart = false, const bool isPerson = false);
88 
89 
99  static SUMOVTypeParameter* beginVTypeParsing(const SUMOSAXAttributes& attrs, const std::string& file,
100  const SumoXMLTag defaultCFModel);
101 
102 
112  static void parseVTypeEmbedded(SUMOVTypeParameter& into,
113  const SumoXMLTag element, const SUMOSAXAttributes& attrs,
114  const bool fromVType = false);
115 
117  static void parseLCParams(SUMOVTypeParameter& into, LaneChangeModel model, const SUMOSAXAttributes& attrs);
118 
120  static void parseJMParams(SUMOVTypeParameter& into, const SUMOSAXAttributes& attrs);
121 
136  static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes& attrs, const std::string& id);
137 
138 
153  static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id);
154 
156  static double parseWalkPos(SumoXMLAttr attr, const std::string& id, double maxPos, const std::string& val, std::mt19937* rng = 0);
157 
158 
165  static SUMOTime processActionStepLength(double given);
166 
167 
168 private:
179  static void parseCommonAttributes(const SUMOSAXAttributes& attrs,
180  SUMOVehicleParameter* ret, std::string element);
181 
182 
183  typedef std::map<SumoXMLTag, std::set<SumoXMLAttr> > CFAttrMap;
184  typedef std::map<LaneChangeModel, std::set<SumoXMLAttr> > LCAttrMap;
185 
186  // returns allowed attrs for each known CF-model (init on first use)
187  static const CFAttrMap& getAllowedCFModelAttrs();
188 
189  // brief allowed attrs for each known CF-model
190  static CFAttrMap allowedCFModelAttrs;
191  // brief allowed attrs for each known LC-model
192  static LCAttrMap allowedLCModelAttrs;
193  // brief allowed attrs for the junction model
194  static std::set<SumoXMLAttr> allowedJMAttrs;
195 
196 
197 };
198 
199 
200 #endif
201 
202 /****************************************************************************/
203 
SumoXMLTag
Numbers representing SUMO-XML - element names.
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const std::string &file, const SumoXMLTag defaultCFModel)
Starts to parse a vehicle type.
static std::set< SumoXMLAttr > allowedJMAttrs
static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
Structure representing possible vehicle parameter.
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, const bool optionalID=false, const bool skipDepart=false, const bool isPerson=false)
Parses a vehicle&#39;s attributes.
static void parseVTypeEmbedded(SUMOVTypeParameter &into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool fromVType=false)
Parses an element embedded in vtype definition.
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static double parseWalkPos(SumoXMLAttr attr, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static void parseLCParams(SUMOVTypeParameter &into, LaneChangeModel model, const SUMOSAXAttributes &attrs)
Parses lane change model attributes.
static const CFAttrMap & getAllowedCFModelAttrs()
LaneChangeModel
Encapsulated SAX-Attributes.
static SUMOVehicleParameter * parseFlowAttributes(const SUMOSAXAttributes &attrs, const SUMOTime beginDefault, const SUMOTime endDefault)
Parses a flow&#39;s attributes.
static void parseCommonAttributes(const SUMOSAXAttributes &attrs, SUMOVehicleParameter *ret, std::string element)
Parses attributes common to vehicles and flows.
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
Helper methods for parsing vehicle attributes.
Structure representing possible vehicle parameter.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
static void parseJMParams(SUMOVTypeParameter &into, const SUMOSAXAttributes &attrs)
Parses junction model attributes.
long long int SUMOTime
Definition: TraCIDefs.h:51
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap