Eclipse SUMO - Simulation of Urban MObility
NIVissimVehicleType.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // -------------------
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 
25 #include "NIVissimVehicleType.h"
26 
28 
30  const std::string& category, const RGBColor& color)
31  : myName(name), myCategory(category),
32  myColor(color) {}
33 
34 
36 
37 
38 
39 bool
40 NIVissimVehicleType::dictionary(int id, const std::string& name, const std::string& category,
41  const RGBColor& color) {
42  NIVissimVehicleType* o = new NIVissimVehicleType(name, category, color);
43  if (!dictionary(id, o)) {
44  delete o;
45  return false;
46  }
47  return true;
48 }
49 
50 
51 bool
53  DictType::iterator i = myDict.find(id);
54  if (i == myDict.end()) {
55  myDict[id] = o;
56  return true;
57  }
58  return false;
59 }
60 
61 
64  DictType::iterator i = myDict.find(id);
65  if (i == myDict.end()) {
66  return nullptr;
67  }
68  return (*i).second;
69 }
70 
71 void
73  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
74  delete (*i).second;
75  }
76  myDict.clear();
77 }
78 
79 
80 
81 /****************************************************************************/
82 
NIVissimVehicleType(const std::string &name, const std::string &category, const RGBColor &color)
static bool dictionary(int id, const std::string &name, const std::string &category, const RGBColor &color)
static DictType myDict
std::map< int, NIVissimVehicleType * > DictType