Eclipse 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-2019 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 
54 public:
66  static SUMOVehicleParameter* parseFlowAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson = false);
67 
82  static SUMOVehicleParameter* parseVehicleAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, const bool optionalID = false, const bool skipDepart = false, const bool isPerson = false);
83 
94  static SUMOVTypeParameter* beginVTypeParsing(const SUMOSAXAttributes& attrs, const bool hardFail, const std::string& file);
95 
106  static bool parseVTypeEmbedded(SUMOVTypeParameter& into, const SumoXMLTag element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool fromVType = false);
107 
109  static bool parseLCParams(SUMOVTypeParameter& into, LaneChangeModel model, const SUMOSAXAttributes& attrs, const bool hardFail);
110 
112  static bool parseJMParams(SUMOVTypeParameter& into, const SUMOSAXAttributes& attrs, const bool hardFail);
113 
128  static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes& attrs, const std::string& id);
129 
144  static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id);
145 
147  static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string& id, double maxPos, const std::string& val, std::mt19937* rng = 0);
148 
155  static SUMOTime processActionStepLength(double given);
156 
157 private:
161  static std::string parseID(const SUMOSAXAttributes& attrs, const SumoXMLTag element);
162 
174  static void parseCommonAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, SUMOVehicleParameter* ret, std::string element);
175 
177  static SUMOVehicleParameter* handleError(const bool hardFail, bool& abortCreation, const std::string& message);
178 
180  typedef std::map<SumoXMLTag, std::set<SumoXMLAttr> > CFAttrMap;
181 
183  typedef std::map<LaneChangeModel, std::set<SumoXMLAttr> > LCAttrMap;
184 
186  static const CFAttrMap& getAllowedCFModelAttrs();
187 
189  static CFAttrMap allowedCFModelAttrs;
190 
192  static LCAttrMap allowedLCModelAttrs;
193 
195  static std::set<SumoXMLAttr> allowedJMAttrs;
196 };
197 
198 
199 #endif
200 
201 /****************************************************************************/
202 
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
SumoXMLTag
Numbers representing SUMO-XML - element names.
long long int SUMOTime
Definition: SUMOTime.h:35
static std::set< SumoXMLAttr > allowedJMAttrs
allowed attrs for the junction model
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 SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false, const bool isPerson=false)
Parses a vehicle&#39;s attributes.
static SUMOVehicleParameter * handleError(const bool hardFail, bool &abortCreation, const std::string &message)
handle error loading SUMOVehicleParameter
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
static LCAttrMap allowedLCModelAttrs
allowed attrs for each known LC-model
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static const CFAttrMap & getAllowedCFModelAttrs()
returns allowed attrs for each known CF-model (init on first use)
LaneChangeModel
Encapsulated SAX-Attributes.
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
Car-Following attributes map.
static SUMOVehicleParameter * parseFlowAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson=false)
Parses a flow&#39;s attributes.
static bool parseJMParams(SUMOVTypeParameter &into, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses junction model attributes.
Helper methods for parsing vehicle attributes.
static std::string parseID(const SUMOSAXAttributes &attrs, const SumoXMLTag element)
parse ID
static void parseCommonAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, SUMOVehicleParameter *ret, std::string element)
Parses attributes common to vehicles and flows.
Structure representing possible vehicle parameter.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
static CFAttrMap allowedCFModelAttrs
allowed attrs for each known CF-model
static bool parseLCParams(SUMOVTypeParameter &into, LaneChangeModel model, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses lane change model attributes.
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap
Lane-Change-Model attributes map.
static bool parseVTypeEmbedded(SUMOVTypeParameter &into, const SumoXMLTag element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool fromVType=false)
Parses an element embedded in vtype definition.