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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Helper methods for parsing vehicle attributes
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <random>
27 #include <string>
28 #include <utils/common/SUMOTime.h>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class SUMOSAXAttributes;
37 class SUMOVTypeParameter;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
50 
51 public:
64  static SUMOVehicleParameter* parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes& attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson = false);
65 
80  static SUMOVehicleParameter* parseVehicleAttributes(int element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool optionalID = false, const bool skipDepart = false);
81 
92  static SUMOVTypeParameter* beginVTypeParsing(const SUMOSAXAttributes& attrs, const bool hardFail, const std::string& file);
93 
103  static bool parseAngleTimesMap(SUMOVTypeParameter& vtype, const std::string, const bool hardFail);
104 
115  static bool parseVTypeEmbedded(SUMOVTypeParameter& into, const SumoXMLTag element, const SUMOSAXAttributes& attrs, const bool hardFail, const bool fromVType = false);
116 
118  static bool parseLCParams(SUMOVTypeParameter& into, LaneChangeModel model, const SUMOSAXAttributes& attrs, const bool hardFail);
119 
121  static bool parseJMParams(SUMOVTypeParameter& into, const SUMOSAXAttributes& attrs, const bool hardFail);
122 
137  static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes& attrs, const std::string& id);
138 
153  static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes& attrs, const std::string& id);
154 
156  static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string& id, double maxPos, const std::string& val, std::mt19937* rng = 0);
157 
164  static SUMOTime processActionStepLength(double given);
165 
166 private:
170  static std::string parseID(const SUMOSAXAttributes& attrs, const SumoXMLTag element);
171 
183  static void parseCommonAttributes(const SUMOSAXAttributes& attrs, const bool hardFail, SUMOVehicleParameter* ret, std::string element);
184 
186  static SUMOVehicleParameter* handleError(const bool hardFail, bool& abortCreation, const std::string& message);
187 
189  typedef std::map<SumoXMLTag, std::set<SumoXMLAttr> > CFAttrMap;
190 
192  typedef std::map<LaneChangeModel, std::set<SumoXMLAttr> > LCAttrMap;
193 
195  static const CFAttrMap& getAllowedCFModelAttrs();
196 
199 
202 
204  static std::set<SumoXMLAttr> allowedJMAttrs;
205 };
long long int SUMOTime
Definition: SUMOTime.h:31
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
SumoXMLTag
Numbers representing SUMO-XML - element names.
LaneChangeModel
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
Encapsulated SAX-Attributes.
Structure representing possible vehicle parameter.
Structure representing possible vehicle parameter.
Helper methods for parsing vehicle attributes.
static const CFAttrMap & getAllowedCFModelAttrs()
returns allowed attrs for each known CF-model (init on first use)
static SUMOVehicleParameter * handleError(const bool hardFail, bool &abortCreation, const std::string &message)
handle error loading SUMOVehicleParameter
static SUMOVTypeParameter * beginVTypeParsing(const SUMOSAXAttributes &attrs, const bool hardFail, const std::string &file)
Starts to parse a vehicle type.
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.
std::map< SumoXMLTag, std::set< SumoXMLAttr > > CFAttrMap
Car-Following attributes map.
static std::string parseID(const SUMOSAXAttributes &attrs, const SumoXMLTag element)
parse ID
static SUMOTime processActionStepLength(double given)
Checks and converts given value for the action step length from seconds to miliseconds assuring it be...
std::map< LaneChangeModel, std::set< SumoXMLAttr > > LCAttrMap
Lane-Change-Model attributes map.
static SUMOVehicleParameter * parseFlowAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs, const bool hardFail, const SUMOTime beginDefault, const SUMOTime endDefault, bool isPerson=false)
Parses a flow's attributes.
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
static void parseCommonAttributes(const SUMOSAXAttributes &attrs, const bool hardFail, SUMOVehicleParameter *ret, std::string element)
Parses attributes common to vehicles and flows.
static SUMOVehicleShape parseGuiShape(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static bool parseJMParams(SUMOVTypeParameter &into, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses junction model attributes.
static std::set< SumoXMLAttr > allowedJMAttrs
allowed attrs for the junction model
static SUMOVehicleClass parseVehicleClass(const SUMOSAXAttributes &attrs, const std::string &id)
Parses the vehicle class.
static bool parseAngleTimesMap(SUMOVTypeParameter &vtype, const std::string, const bool hardFail)
Parse string containing AngleTimes triplets (angle, entry time, exit time)
static bool parseLCParams(SUMOVTypeParameter &into, LaneChangeModel model, const SUMOSAXAttributes &attrs, const bool hardFail)
Parses lane change model attributes.
static LCAttrMap allowedLCModelAttrs
allowed attrs for each known LC-model
static SUMOVehicleParameter * parseVehicleAttributes(int element, const SUMOSAXAttributes &attrs, const bool hardFail, const bool optionalID=false, const bool skipDepart=false)
Parses a vehicle's attributes.
static CFAttrMap allowedCFModelAttrs
allowed attrs for each known CF-model