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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // -------------------
20 /****************************************************************************/
21 #include <config.h>
22 
23 #include <string>
24 #include <utils/common/RGBColor.h>
26 #include "NIVissimVehTypeClass.h"
27 
28 
30 
32  const std::string& name,
33  const RGBColor& color,
34  std::vector<int>& types)
35  : myID(id), myName(name), myColor(color), myTypes(types) {}
36 
38 
39 
40 bool
41 NIVissimVehTypeClass::dictionary(int id, const std::string& name,
42  const RGBColor& color,
43  std::vector<int>& types) {
44  NIVissimVehTypeClass* o = new NIVissimVehTypeClass(id, name, color, types);
45  if (!dictionary(id, o)) {
46  delete o;
47  return false;
48  }
49  return true;
50 }
51 
52 
53 
54 
55 bool
57  DictType::iterator i = myDict.find(name);
58  if (i == myDict.end()) {
59  myDict[name] = o;
60  return true;
61  }
62  return false;
63 }
64 
65 
68  DictType::iterator i = myDict.find(name);
69  if (i == myDict.end()) {
70  return nullptr;
71  }
72  return (*i).second;
73 }
74 
75 
76 void
78  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
79  delete (*i).second;
80  }
81  myDict.clear();
82 }
83 
84 
85 /****************************************************************************/
std::map< int, NIVissimVehTypeClass * > DictType
static bool dictionary(int id, const std::string &name, const RGBColor &color, std::vector< int > &types)
NIVissimVehTypeClass(int id, const std::string &name, const RGBColor &color, std::vector< int > &types)