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 /****************************************************************************/
17 // Helper methods for parsing vehicle attributes
18 /****************************************************************************/
19 #ifndef SUMOVehicleParserHelper_h
20 #define SUMOVehicleParserHelper_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <random>
29 #include <string>
30 #include <utils/common/SUMOTime.h>
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class SUMOSAXAttributes;
39 class SUMOVTypeParameter;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
52 
53 public:
65  static SUMOVehicleParameter* parseFlowAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson = false);
66 
81  static SUMOVehicleParameter* parseVehicleAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, const bool optionalID = false, const bool skipDepart = false, const bool isPerson = false);
82 
93  static SUMOVTypeParameter* beginVTypeParsing(const SUMOSAXAttributes& attrs, const bool hardFail, const std::string& file);
94 
104  static bool parseAngleTimesMap(SUMOVTypeParameter& vtype, const std::string, const bool hardFail);
105 
116  static bool parseVTypeEmbedded(SUMOVTypeParameter& into, const SumoXMLTag element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool fromVType = false);
117 
119  static bool parseLCParams(SUMOVTypeParameter& into, LaneChangeModel model, const SUMOSAXAttributes& attrs, const bool hardFail);
120 
122  static bool parseJMParams(SUMOVTypeParameter& into, const SUMOSAXAttributes& attrs, const bool hardFail);
123 
138  static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes& attrs, const std::string& id);
139 
154  static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id);
155 
157  static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string& id, double maxPos, const std::string& val, std::mt19937* rng = 0);
158 
165  static SUMOTime processActionStepLength(double given);
166 
167 private:
171  static std::string parseID(const SUMOSAXAttributes& attrs, const SumoXMLTag element);
172 
184  static void parseCommonAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, SUMOVehicleParameter* ret, std::string element);
185 
187  static SUMOVehicleParameter* handleError(const bool hardFail, bool& abortCreation, const std::string& message);
188 
190  typedef std::map<SumoXMLTag, std::set<SumoXMLAttr> > CFAttrMap;
191 
193  typedef std::map<LaneChangeModel, std::set<SumoXMLAttr> > LCAttrMap;
194 
196  static const CFAttrMap& getAllowedCFModelAttrs();
197 
200 
203 
205  static std::set<SumoXMLAttr> allowedJMAttrs;
206 };
207 
208 
209 #endif
210 
211 /****************************************************************************/
212 
SUMOVehicleParserHelper::handleError
static SUMOVehicleParameter * handleError(const bool hardFail, bool &abortCreation, const std::string &message)
handle error loading SUMOVehicleParameter
Definition: SUMOVehicleParserHelper.cpp:1482
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
SUMOVehicleParserHelper::allowedCFModelAttrs
static CFAttrMap allowedCFModelAttrs
allowed attrs for each known CF-model
Definition: SUMOVehicleParserHelper.h:199
SUMOTime.h
SUMOVehicleParserHelper::parseVTypeEmbedded
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.
Definition: SUMOVehicleParserHelper.cpp:878
LaneChangeModel
LaneChangeModel
Definition: SUMOXMLDefinitions.h:1303
SUMOVehicleParserHelper::LCAttrMap
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap
Lane-Change-Model attributes map.
Definition: SUMOVehicleParserHelper.h:193
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SUMOVehicleParserHelper::allowedJMAttrs
static std::set< SumoXMLAttr > allowedJMAttrs
allowed attrs for the junction model
Definition: SUMOVehicleParserHelper.h:205
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:297
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
SUMOVehicleParserHelper::parseVehicleAttributes
static SUMOVehicleParameter * parseVehicleAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false, const bool isPerson=false)
Parses a vehicle's attributes.
Definition: SUMOVehicleParserHelper.cpp:231
SUMOVehicleParserHelper::processActionStepLength
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
Definition: SUMOVehicleParserHelper.cpp:1456
SUMOVehicleParserHelper::allowedLCModelAttrs
static LCAttrMap allowedLCModelAttrs
allowed attrs for each known LC-model
Definition: SUMOVehicleParserHelper.h:202
SUMOVehicleParserHelper::beginVTypeParsing
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
Definition: SUMOVehicleParserHelper.cpp:501
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
SUMOVehicleShape
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
Definition: SUMOVehicleClass.h:50
SUMOVehicleParserHelper
Helper methods for parsing vehicle attributes.
Definition: SUMOVehicleParserHelper.h:51
SUMOVehicleParserHelper::parseCommonAttributes
static void parseCommonAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, SUMOVehicleParameter *ret, std::string element)
Parses attributes common to vehicles and flows.
Definition: SUMOVehicleParserHelper.cpp:316
SUMOVehicleParserHelper::parseVehicleClass
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
Definition: SUMOVehicleParserHelper.cpp:1392
SUMOVehicleParserHelper::parseAngleTimesMap
static bool parseAngleTimesMap(SUMOVTypeParameter &vtype, const std::string, const bool hardFail)
Parse string containing AngleTimes triplets (angle, entry time, exit time)
Definition: SUMOVehicleParserHelper.cpp:835
SUMOVehicleParserHelper::CFAttrMap
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
Car-Following attributes map.
Definition: SUMOVehicleParserHelper.h:190
SUMOVehicleParserHelper::getAllowedCFModelAttrs
static const CFAttrMap & getAllowedCFModelAttrs()
returns allowed attrs for each known CF-model (init on first use)
Definition: SUMOVehicleParserHelper.cpp:1015
SUMOVehicleParserHelper::parseFlowAttributes
static SUMOVehicleParameter * parseFlowAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson=false)
Parses a flow's attributes.
Definition: SUMOVehicleParserHelper.cpp:56
SUMOVehicleParserHelper::parseLCParams
static bool parseLCParams(SUMOVTypeParameter &into, LaneChangeModel model, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses lane change model attributes.
Definition: SUMOVehicleParserHelper.cpp:1216
SUMOVehicleParserHelper::parseJMParams
static bool parseJMParams(SUMOVTypeParameter &into, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses junction model attributes.
Definition: SUMOVehicleParserHelper.cpp:1325
SUMOVehicleParserHelper::parseWalkPos
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
Definition: SUMOVehicleParserHelper.cpp:1432
config.h
SUMOVehicleParserHelper::parseID
static std::string parseID(const SUMOSAXAttributes &attrs, const SumoXMLTag element)
parse ID
Definition: SUMOVehicleParserHelper.cpp:293
SUMOVehicleParserHelper::parseGuiShape
static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
Definition: SUMOVehicleParserHelper.cpp:1414
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:372
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
SUMOXMLDefinitions.h