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 
122  if (cfParameter.size() != 0) {
123  dev.openTag(cfModel);
124  std::vector<SumoXMLAttr> attrs;
125  for (CFParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
126  attrs.push_back(i->first);
127  }
128  std::sort(attrs.begin(), attrs.end());
129  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
130  dev.writeAttr(*i, cfParameter.find(*i)->second);
131  }
132  dev.closeTag();
133  dev.closeTag();
134  } else {
135  dev.closeTag();
136  }
137 }
138 
139 
140 SUMOReal
141 SUMOVTypeParameter::get(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
142  if (cfParameter.count(attr)) {
143  return cfParameter.find(attr)->second;
144  } else {
145  return defaultValue;
146  }
147 }
148 
149 
150 /****************************************************************************/
151