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 /****************************************************************************/
14 // -------------------
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 
24 #include "NIVissimVehicleType.h"
25 
27 
29  const std::string& category, const RGBColor& color)
30  : myName(name), myCategory(category),
31  myColor(color) {}
32 
33 
35 
36 
37 
38 bool
39 NIVissimVehicleType::dictionary(int id, const std::string& name, const std::string& category,
40  const RGBColor& color) {
41  NIVissimVehicleType* o = new NIVissimVehicleType(name, category, color);
42  if (!dictionary(id, o)) {
43  delete o;
44  return false;
45  }
46  return true;
47 }
48 
49 
50 bool
52  DictType::iterator i = myDict.find(id);
53  if (i == myDict.end()) {
54  myDict[id] = o;
55  return true;
56  }
57  return false;
58 }
59 
60 
63  DictType::iterator i = myDict.find(id);
64  if (i == myDict.end()) {
65  return nullptr;
66  }
67  return (*i).second;
68 }
69 
70 void
72  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
73  delete (*i).second;
74  }
75  myDict.clear();
76 }
77 
78 
79 
80 /****************************************************************************/
81 
NIVissimVehicleType::NIVissimVehicleType
NIVissimVehicleType(const std::string &name, const std::string &category, const RGBColor &color)
Definition: NIVissimVehicleType.cpp:28
NIVissimVehicleType::~NIVissimVehicleType
~NIVissimVehicleType()
Definition: NIVissimVehicleType.cpp:34
RGBColor
Definition: RGBColor.h:39
NIVissimVehicleType.h
NIVissimVehicleType::myDict
static DictType myDict
Definition: NIVissimVehicleType.h:53
NIVissimVehicleType::clearDict
static void clearDict()
Definition: NIVissimVehicleType.cpp:71
config.h
NIVissimVehicleType
Definition: NIVissimVehicleType.h:36
NIVissimVehicleType::DictType
std::map< int, NIVissimVehicleType * > DictType
Definition: NIVissimVehicleType.h:52
NIVissimVehicleType::dictionary
static bool dictionary(int id, const std::string &name, const std::string &category, const RGBColor &color)
Definition: NIVissimVehicleType.cpp:39