SUMO - Simulation of Urban MObility
SUMOVehicleParserHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // Helper methods for parsing vehicle attributes
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2008-2017 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef SUMOVehicleParserHelper_h
24 #define SUMOVehicleParserHelper_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <random>
37 #include <string>
38 #include <utils/common/SUMOTime.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class SUMOSAXAttributes;
47 class SUMOVTypeParameter;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
60 public:
71  static SUMOVehicleParameter* parseFlowAttributes(const SUMOSAXAttributes& attrs, const SUMOTime beginDefault, const SUMOTime endDefault);
72 
73 
88  const bool optionalID = false, const bool skipDepart = false, const bool isPerson = false);
89 
90 
100  static SUMOVTypeParameter* beginVTypeParsing(const SUMOSAXAttributes& attrs, const std::string& file,
101  const SumoXMLTag defaultCFModel);
102 
103 
113  static void parseVTypeEmbedded(SUMOVTypeParameter& into,
114  const SumoXMLTag element, const SUMOSAXAttributes& attrs,
115  const bool fromVType = false);
116 
118  static void parseLCParams(SUMOVTypeParameter& into, LaneChangeModel model, const SUMOSAXAttributes& attrs);
119 
121  static void parseJMParams(SUMOVTypeParameter& into, const SUMOSAXAttributes& attrs);
122 
137  static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes& attrs, const std::string& id);
138 
139 
154  static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id);
155 
157  static double parseWalkPos(SumoXMLAttr attr, const std::string& id, double maxPos, const std::string& val, std::mt19937* rng = 0);
158 
159 private:
170  static void parseCommonAttributes(const SUMOSAXAttributes& attrs,
171  SUMOVehicleParameter* ret, std::string element);
172 
173 
174  typedef std::map<SumoXMLTag, std::set<SumoXMLAttr> > CFAttrMap;
175  typedef std::map<LaneChangeModel, std::set<SumoXMLAttr> > LCAttrMap;
176 
177  // returns allowed attrs for each known CF-model (init on first use)
178  static const CFAttrMap& getAllowedCFModelAttrs();
179 
180  // brief allowed attrs for each known CF-model
181  static CFAttrMap allowedCFModelAttrs;
182  // brief allowed attrs for each known LC-model
183  static LCAttrMap allowedLCModelAttrs;
184  // brief allowed attrs for the junction model
185  static std::set<SumoXMLAttr> allowedJMAttrs;
186 
187 
188 };
189 
190 
191 #endif
192 
193 /****************************************************************************/
194 
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.
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:52
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap