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