SUMO - Simulation of Urban MObility
NIVissimSource.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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // -------------------
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 
31 #include <string>
32 #include <map>
33 #include "NIVissimSource.h"
34 
36 
37 NIVissimSource::NIVissimSource(const std::string& id, const std::string& name,
38  const std::string& edgeid)
39  : myID(id), myName(name), myEdgeID(edgeid) {}
40 
41 
43 
44 
45 bool
46 NIVissimSource::dictionary(const std::string& id, const std::string& name,
47  const std::string& edgeid) {
48  NIVissimSource* o = new NIVissimSource(id, name, edgeid);
49  if (!dictionary(id, o)) {
50  delete o;
51  return false;
52  }
53  return true;
54 }
55 
56 
57 bool
58 NIVissimSource::dictionary(const std::string& id, NIVissimSource* o) {
59  DictType::iterator i = myDict.find(id);
60  if (i == myDict.end()) {
61  myDict[id] = o;
62  return true;
63  }
64  return false;
65 }
66 
67 
69 NIVissimSource::dictionary(const std::string& id) {
70  DictType::iterator i = myDict.find(id);
71  if (i == myDict.end()) {
72  return 0;
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 
static void clearDict()
static DictType myDict
NIVissimSource(const std::string &id, const std::string &name, const std::string &edgeid)
std::map< std::string, NIVissimSource * > DictType
static bool dictionary(const std::string &id, const std::string &name, const std::string &edgeid)