SUMO - Simulation of Urban MObility
NIVissimClosures.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-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 /****************************************************************************/
18 // -------------------
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include <string>
33 #include "NIVissimClosures.h"
34 
35 
37 
38 NIVissimClosures::NIVissimClosures(const std::string& id,
39  int from_node, int to_node,
40  std::vector<int>& overEdges)
41  : myID(id), myFromNode(from_node), myToNode(to_node),
42  myOverEdges(overEdges) {}
43 
44 
46 
47 
48 bool
49 NIVissimClosures::dictionary(const std::string& id,
50  int from_node, int to_node,
51  std::vector<int>& overEdges) {
52  NIVissimClosures* o = new NIVissimClosures(id, from_node, to_node,
53  overEdges);
54  if (!dictionary(id, o)) {
55  delete o;
56  return false;
57  }
58  return true;
59 }
60 
61 
62 bool
63 NIVissimClosures::dictionary(const std::string& name, NIVissimClosures* o) {
64  DictType::iterator i = myDict.find(name);
65  if (i == myDict.end()) {
66  myDict[name] = o;
67  return true;
68  }
69  return false;
70 }
71 
72 
74 NIVissimClosures::dictionary(const std::string& name) {
75  DictType::iterator i = myDict.find(name);
76  if (i == myDict.end()) {
77  return 0;
78  }
79  return (*i).second;
80 }
81 
82 
83 
84 void
86  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
87  delete(*i).second;
88  }
89  myDict.clear();
90 }
91 
92 
93 
94 /****************************************************************************/
95 
static bool dictionary(const std::string &id, int from_node, int to_node, std::vector< int > &overEdges)
static void clearDict()
NIVissimClosures(const std::string &id, int from_node, int to_node, std::vector< int > &overEdges)
std::map< std::string, NIVissimClosures * > DictType
static DictType myDict