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 /****************************************************************************/
16 // -------------------
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <string>
27 #include "NIVissimClosures.h"
28 
29 
31 
32 NIVissimClosures::NIVissimClosures(const std::string& id,
33  int from_node, int to_node,
34  std::vector<int>& overEdges)
35  : myID(id), myFromNode(from_node), myToNode(to_node),
36  myOverEdges(overEdges) {}
37 
38 
40 
41 
42 bool
43 NIVissimClosures::dictionary(const std::string& id,
44  int from_node, int to_node,
45  std::vector<int>& overEdges) {
46  NIVissimClosures* o = new NIVissimClosures(id, from_node, to_node,
47  overEdges);
48  if (!dictionary(id, o)) {
49  delete o;
50  return false;
51  }
52  return true;
53 }
54 
55 
56 bool
57 NIVissimClosures::dictionary(const std::string& name, NIVissimClosures* o) {
58  DictType::iterator i = myDict.find(name);
59  if (i == myDict.end()) {
60  myDict[name] = o;
61  return true;
62  }
63  return false;
64 }
65 
66 
68 NIVissimClosures::dictionary(const std::string& name) {
69  DictType::iterator i = myDict.find(name);
70  if (i == myDict.end()) {
71  return nullptr;
72  }
73  return (*i).second;
74 }
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 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