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 
190 
193 
195  static std::set<SumoXMLAttr> allowedJMAttrs;
196 };
197 
198 
199 #endif
200 
201 /****************************************************************************/
202 
SUMOVehicleParserHelper::handleError
static SUMOVehicleParameter * handleError(const bool hardFail, bool &abortCreation, const std::string &message)
handle error loading SUMOVehicleParameter
Definition: SUMOVehicleParserHelper.cpp:1416
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:134
SUMOVehicleParserHelper::allowedCFModelAttrs
static CFAttrMap allowedCFModelAttrs
allowed attrs for each known CF-model
Definition: SUMOVehicleParserHelper.h:189
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:819
LaneChangeModel
LaneChangeModel
Definition: SUMOXMLDefinitions.h:1298
SUMOVehicleParserHelper::LCAttrMap
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap
Lane-Change-Model attributes map.
Definition: SUMOVehicleParserHelper.h:183
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SUMOVehicleParserHelper::allowedJMAttrs
static std::set< SumoXMLAttr > allowedJMAttrs
allowed attrs for the junction model
Definition: SUMOVehicleParserHelper.h:195
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
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:1390
SUMOVehicleParserHelper::allowedLCModelAttrs
static LCAttrMap allowedLCModelAttrs
allowed attrs for each known LC-model
Definition: SUMOVehicleParserHelper.h:192
SUMOVehicleParserHelper::beginVTypeParsing
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
Definition: SUMOVehicleParserHelper.cpp:491
SUMOVTypeParameter
Structure representing possible vehicle parameter.
Definition: SUMOVTypeParameter.h:86
SUMOVehicleShape
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
Definition: SUMOVehicleClass.h:51
SUMOVehicleParserHelper
Helper methods for parsing vehicle attributes.
Definition: SUMOVehicleParserHelper.h:52
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:1326
SUMOVehicleParserHelper::CFAttrMap
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
Car-Following attributes map.
Definition: SUMOVehicleParserHelper.h:180
SUMOVehicleParserHelper::getAllowedCFModelAttrs
static const CFAttrMap & getAllowedCFModelAttrs()
returns allowed attrs for each known CF-model (init on first use)
Definition: SUMOVehicleParserHelper.cpp:956
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:1155
SUMOVehicleParserHelper::parseJMParams
static bool parseJMParams(SUMOVTypeParameter &into, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses junction model attributes.
Definition: SUMOVehicleParserHelper.cpp:1259
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:1366
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:1348
SumoXMLAttr
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Definition: SUMOXMLDefinitions.h:373
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
SUMOXMLDefinitions.h