Eclipse 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-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 <string>
26 #include <map>
27 #include "NIVissimSource.h"
28 
30 
31 NIVissimSource::NIVissimSource(const std::string& id, const std::string& name,
32  const std::string& edgeid)
33  : myID(id), myName(name), myEdgeID(edgeid) {}
34 
35 
37 
38 
39 bool
40 NIVissimSource::dictionary(const std::string& id, const std::string& name,
41  const std::string& edgeid) {
42  NIVissimSource* o = new NIVissimSource(id, name, edgeid);
43  if (!dictionary(id, o)) {
44  delete o;
45  return false;
46  }
47  return true;
48 }
49 
50 
51 bool
52 NIVissimSource::dictionary(const std::string& id, NIVissimSource* o) {
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 
63 NIVissimSource::dictionary(const std::string& id) {
64  DictType::iterator i = myDict.find(id);
65  if (i == myDict.end()) {
66  return nullptr;
67  }
68  return (*i).second;
69 }
70 
71 
72 void
74  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
75  delete (*i).second;
76  }
77  myDict.clear();
78 }
79 
80 
81 
82 /****************************************************************************/
83 
NIVissimSource.h
NIVissimSource::DictType
std::map< std::string, NIVissimSource * > DictType
Definition: NIVissimSource.h:52
NIVissimSource::dictionary
static bool dictionary(const std::string &id, const std::string &name, const std::string &edgeid)
Definition: NIVissimSource.cpp:40
NIVissimSource::clearDict
static void clearDict()
Definition: NIVissimSource.cpp:73
NIVissimSource::myDict
static DictType myDict
Definition: NIVissimSource.h:53
NIVissimSource::~NIVissimSource
~NIVissimSource()
Definition: NIVissimSource.cpp:36
NIVissimSource::NIVissimSource
NIVissimSource(const std::string &id, const std::string &name, const std::string &edgeid)
Definition: NIVissimSource.cpp:31
config.h
NIVissimSource
Definition: NIVissimSource.h:36