Eclipse SUMO - Simulation of Urban MObility
NIVissimVehTypeClass.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-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 /****************************************************************************/
16 // -------------------
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <string>
26 #include <utils/common/RGBColor.h>
28 #include "NIVissimVehTypeClass.h"
29 
30 
32 
34  const std::string& name,
35  const RGBColor& color,
36  std::vector<int>& types)
37  : myID(id), myName(name), myColor(color), myTypes(types) {}
38 
40 
41 
42 bool
43 NIVissimVehTypeClass::dictionary(int id, const std::string& name,
44  const RGBColor& color,
45  std::vector<int>& types) {
46  NIVissimVehTypeClass* o = new NIVissimVehTypeClass(id, name, color, types);
47  if (!dictionary(id, o)) {
48  delete o;
49  return false;
50  }
51  return true;
52 }
53 
54 
55 
56 
57 bool
59  DictType::iterator i = myDict.find(name);
60  if (i == myDict.end()) {
61  myDict[name] = o;
62  return true;
63  }
64  return false;
65 }
66 
67 
70  DictType::iterator i = myDict.find(name);
71  if (i == myDict.end()) {
72  return nullptr;
73  }
74  return (*i).second;
75 }
76 
77 
78 void
80  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
81  delete (*i).second;
82  }
83  myDict.clear();
84 }
85 
86 
87 
88 /****************************************************************************/
89 
NIVissimVehTypeClass::clearDict
static void clearDict()
Definition: NIVissimVehTypeClass.cpp:79
NIVissimVehTypeClass
Definition: NIVissimVehTypeClass.h:38
NIVissimVehTypeClass::myDict
static DictType myDict
Definition: NIVissimVehTypeClass.h:56
NIVissimVehTypeClass::~NIVissimVehTypeClass
~NIVissimVehTypeClass()
Definition: NIVissimVehTypeClass.cpp:39
NIVissimVehTypeClass::NIVissimVehTypeClass
NIVissimVehTypeClass(int id, const std::string &name, const RGBColor &color, std::vector< int > &types)
Definition: NIVissimVehTypeClass.cpp:33
NIVissimVehTypeClass.h
RGBColor.h
VectorHelper.h
RGBColor
Definition: RGBColor.h:40
NIVissimVehTypeClass::dictionary
static bool dictionary(int id, const std::string &name, const RGBColor &color, std::vector< int > &types)
Definition: NIVissimVehTypeClass.cpp:43
config.h
NIVissimVehTypeClass::DictType
std::map< int, NIVissimVehTypeClass * > DictType
Definition: NIVissimVehTypeClass.h:55