SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMOVTypeParameter.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Structure representing possible vehicle parameter
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <algorithm>
35 #include <utils/common/ToString.h>
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // member method definitions
49 // ===========================================================================
51  : id(DEFAULT_VTYPE_ID), length(DEFAULT_VEH_LENGTH),
52  minGap(DEFAULT_VEH_MINGAP), maxSpeed(DEFAULT_VEH_MAXSPEED),
53  defaultProbability(DEFAULT_VEH_PROB),
54  speedFactor(DEFAULT_VEH_SPEEDFACTOR), speedDev(DEFAULT_VEH_SPEEDDEV),
55  emissionClass(SVE_UNKNOWN), color(RGBColor::DEFAULT_COLOR),
56  vehicleClass(SVC_UNKNOWN),
57  impatience(0),
58  width(DEFAULT_VEH_WIDTH),
59  height(DEFAULT_VEH_HEIGHT), shape(DEFAULT_VEH_SHAPE),
61  setParameter(0), saved(false), onlyReferenced(false) {
62 }
63 
64 
65 void
67  if (onlyReferenced) {
68  return;
69  }
71  dev.writeAttr(SUMO_ATTR_ID, id);
74  }
77  }
80  }
83  }
86  }
89  }
92  }
95  }
98  dev.writeAttr(SUMO_ATTR_IMPATIENCE, "off");
99  } else {
101  }
102  }
105  }
108  }
111  }
114  }
117  }
120  }
121  if (wasSet(VTYPEPARS_LCM_SET)) {
123  }
124 
125  if (cfParameter.size() != 0) {
126  dev.openTag(cfModel);
127  std::vector<SumoXMLAttr> attrs;
128  for (CFParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
129  attrs.push_back(i->first);
130  }
131  std::sort(attrs.begin(), attrs.end());
132  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
133  dev.writeAttr(*i, cfParameter.find(*i)->second);
134  }
135  dev.closeTag();
136  dev.closeTag();
137  } else {
138  dev.closeTag();
139  }
140 }
141 
142 
143 SUMOReal
144 SUMOVTypeParameter::get(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
145  if (cfParameter.count(attr)) {
146  return cfParameter.find(attr)->second;
147  } else {
148  return defaultValue;
149  }
150 }
151 
152 
153 /****************************************************************************/
154 
const int VTYPEPARS_MAXSPEED_SET
const LaneChangeModel DEFAULT_VEH_LANE_CHANGE_MODEL
const int VTYPEPARS_MINGAP_SET
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
SumoXMLTag cfModel
The enum-representation of the car-following model to use.
SUMOReal get(const SumoXMLAttr attr, const SUMOReal defaultValue) const
Returns the named value from the map, or the default if it is ot contained there. ...
std::string getVehicleEmissionTypeName(SUMOEmissionClass id)
Returns the class name of the emission class given by its id.
SUMOVehicleShape shape
This class&#39; shape.
SUMOReal speedDev
The standard deviation for speed variations.
SUMOReal length
The physical vehicle length.
const SUMOVehicleShape DEFAULT_VEH_SHAPE
SUMOVehicleClass vehicleClass
The vehicle&#39;s class.
const SUMOReal DEFAULT_VEH_PROB
const SumoXMLTag DEFAULT_VEH_FOLLOW_MODEL
const SUMOReal DEFAULT_VEH_LENGTH
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
SUMOReal width
This class&#39; width.
const int VTYPEPARS_OSGFILE_SET
const int VTYPEPARS_PROBABILITY_SET
const std::string DEFAULT_VTYPE_ID
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
SUMOReal speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street...
#define max(a, b)
Definition: polyfonts.c:61
std::string osgFile
3D model file for this class
std::string imgFile
Image file for this class.
const SUMOReal DEFAULT_VEH_MAXSPEED
SUMOVTypeParameter()
Constructor.
const int VTYPEPARS_SPEEDDEVIATION_SET
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:51
const SUMOReal DEFAULT_VEH_SPEEDDEV
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers) ...
const int VTYPEPARS_SPEEDFACTOR_SET
void write(OutputDevice &dev) const
Writes the vtype.
SUMOReal maxSpeed
The vehicle type&#39;s maximum speed [m/s].
const SUMOReal DEFAULT_VEH_MINGAP
SUMOReal impatience
The vehicle&#39;s impatience (willingness to obstruct others)
bool wasSet(int what) const
Returns whether the given parameter was set.
SUMOReal defaultProbability
The probability when being added to a distribution without an explicit probability.
const int VTYPEPARS_IMGFILE_SET
RGBColor color
The color.
const SUMOReal DEFAULT_VEH_WIDTH
const int VTYPEPARS_LCM_SET
const SUMOReal DEFAULT_VEH_HEIGHT
const int VTYPEPARS_HEIGHT_SET
const SUMOReal DEFAULT_VEH_SPEEDFACTOR
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:215
const int VTYPEPARS_WIDTH_SET
LaneChangeModel lcModel
The lane-change model to use.
SUMOReal height
This class&#39; height.
const int VTYPEPARS_LENGTH_SET
const int VTYPEPARS_VEHICLECLASS_SET
A color information.
const int VTYPEPARS_EMISSIONCLASS_SET
const int VTYPEPARS_COLOR_SET
const int VTYPEPARS_SHAPE_SET
SUMOEmissionClass emissionClass
The emission class of this vehicle.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
const int VTYPEPARS_IMPATIENCE_SET
SUMOReal minGap
This class&#39; free space in front of the vehicle itself.