SUMO - Simulation of Urban MObility
NIVissimVehicleType.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // -------------------
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 
32 #include "NIVissimVehicleType.h"
33 
34 #ifdef CHECK_MEMORY_LEAKS
35 #include <foreign/nvwa/debug_new.h>
36 #endif // CHECK_MEMORY_LEAKS
37 
39 
41  const std::string& name, const std::string& category, SUMOReal length,
42  const RGBColor& color, SUMOReal amax, SUMOReal dmax)
43  : myID(id), myName(name), myCategory(category), myLength(length),
44  myColor(color), myAMax(amax), myDMax(dmax) {}
45 
46 
48 
49 
50 
51 bool
53  const std::string& name, const std::string& category, SUMOReal length,
54  const RGBColor& color, SUMOReal amax, SUMOReal dmax) {
55  NIVissimVehicleType* o = new NIVissimVehicleType(id, name, category,
56  length, color, amax, dmax);
57  if (!dictionary(id, o)) {
58  delete o;
59  return false;
60  }
61  return true;
62 }
63 
64 
65 bool
67  DictType::iterator i = myDict.find(id);
68  if (i == myDict.end()) {
69  myDict[id] = o;
70  return true;
71  }
72  return false;
73 }
74 
75 
78  DictType::iterator i = myDict.find(id);
79  if (i == myDict.end()) {
80  return 0;
81  }
82  return (*i).second;
83 }
84 
85 void
87  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
88  delete(*i).second;
89  }
90  myDict.clear();
91 }
92 
93 
94 
95 /****************************************************************************/
96 
static bool dictionary(int id, const std::string &name, const std::string &category, SUMOReal length, const RGBColor &color, SUMOReal amax, SUMOReal dmax)
static DictType myDict
NIVissimVehicleType(int id, const std::string &name, const std::string &category, SUMOReal length, const RGBColor &color, SUMOReal amax, SUMOReal dmax)
std::map< int, NIVissimVehicleType * > DictType
#define SUMOReal
Definition: config.h:215