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-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 /****************************************************************************/
18 // Helper methods for parsing vehicle attributes
19 /****************************************************************************/
20 #ifndef SUMOVehicleParserHelper_h
21 #define SUMOVehicleParserHelper_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <random>
30 #include <string>
31 #include <utils/common/SUMOTime.h>
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class SUMOSAXAttributes;
40 class SUMOVTypeParameter;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
53 public:
64  static SUMOVehicleParameter* parseFlowAttributes(const SUMOSAXAttributes& attrs, const SUMOTime beginDefault, const SUMOTime endDefault);
65 
66 
81  const bool optionalID = false, const bool skipDepart = false, const bool isPerson = false);
82 
83 
92  static SUMOVTypeParameter* beginVTypeParsing(const SUMOSAXAttributes& attrs, const std::string& file);
93 
94 
104  static void parseVTypeEmbedded(SUMOVTypeParameter& into,
105  const SumoXMLTag element, const SUMOSAXAttributes& attrs,
106  const bool fromVType = false);
107 
109  static void parseLCParams(SUMOVTypeParameter& into, LaneChangeModel model, const SUMOSAXAttributes& attrs);
110 
112  static void parseJMParams(SUMOVTypeParameter& into, const SUMOSAXAttributes& attrs);
113 
128  static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes& attrs, const std::string& id);
129 
130 
145  static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id);
146 
148  static double parseWalkPos(SumoXMLAttr attr, const std::string& id, double maxPos, const std::string& val, std::mt19937* rng = 0);
149 
150 
157  static SUMOTime processActionStepLength(double given);
158 
159 
160 private:
171  static void parseCommonAttributes(const SUMOSAXAttributes& attrs,
172  SUMOVehicleParameter* ret, std::string element);
173 
174 
175  typedef std::map<SumoXMLTag, std::set<SumoXMLAttr> > CFAttrMap;
176  typedef std::map<LaneChangeModel, std::set<SumoXMLAttr> > LCAttrMap;
177 
178  // returns allowed attrs for each known CF-model (init on first use)
179  static const CFAttrMap& getAllowedCFModelAttrs();
180 
181  // brief allowed attrs for each known CF-model
182  static CFAttrMap allowedCFModelAttrs;
183  // brief allowed attrs for each known LC-model
184  static LCAttrMap allowedLCModelAttrs;
185  // brief allowed attrs for the junction model
186  static std::set<SumoXMLAttr> allowedJMAttrs;
187 
188 
189 };
190 
191 
192 #endif
193 
194 /****************************************************************************/
195 
SumoXMLTag
Numbers representing SUMO-XML - element names.
long long int SUMOTime
Definition: SUMOTime.h:36
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.
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const std::string &file)
Starts to parse a vehicle type.
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap