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.sourceforge.net/
12 // Copyright (C) 2001-2012 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), width(DEFAULT_VEH_WIDTH),
57  height(DEFAULT_VEH_HEIGHT), shape(DEFAULT_VEH_SHAPE),
59  setParameter(0), saved(false), onlyReferenced(false) {
60 }
61 
62 
63 void
65  if (onlyReferenced) {
66  return;
67  }
69  dev.writeAttr(SUMO_ATTR_ID, id);
72  }
75  }
78  }
81  }
84  }
87  }
90  }
93  }
96  }
99  }
102  }
105  }
108  }
111  }
112 
113  if (cfParameter.size() != 0) {
114  dev.closeOpener();
115  dev.openTag(cfModel);
116  std::vector<SumoXMLAttr> attrs;
117  for (CFParams::const_iterator i = cfParameter.begin(); i != cfParameter.end(); ++i) {
118  attrs.push_back(i->first);
119  }
120  std::sort(attrs.begin(), attrs.end());
121  for (std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
122  dev.writeAttr(*i, cfParameter.find(*i)->second);
123  }
124  dev.closeTag(true);
125  dev.closeTag();
126  } else {
127  dev.closeTag(true);
128  }
129 }
130 
131 
132 SUMOReal
133 SUMOVTypeParameter::get(const SumoXMLAttr attr, const SUMOReal defaultValue) const {
134  if (cfParameter.count(attr)) {
135  return cfParameter.find(attr)->second;
136  } else {
137  return defaultValue;
138  }
139 }
140 
141 
142 /****************************************************************************/
143