SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimClosures.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // -------------------
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
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 #ifdef CHECK_MEMORY_LEAKS
36 #include <foreign/nvwa/debug_new.h>
37 #endif // CHECK_MEMORY_LEAKS
38 
39 
41 
42 NIVissimClosures::NIVissimClosures(const std::string& id,
43  int from_node, int to_node,
44  std::vector<int>& overEdges)
45  : myID(id), myFromNode(from_node), myToNode(to_node),
46  myOverEdges(overEdges) {}
47 
48 
50 
51 
52 bool
53 NIVissimClosures::dictionary(const std::string& id,
54  int from_node, int to_node,
55  std::vector<int>& overEdges) {
56  NIVissimClosures* o = new NIVissimClosures(id, from_node, to_node,
57  overEdges);
58  if (!dictionary(id, o)) {
59  delete o;
60  return false;
61  }
62  return true;
63 }
64 
65 
66 bool
67 NIVissimClosures::dictionary(const std::string& name, NIVissimClosures* o) {
68  DictType::iterator i = myDict.find(name);
69  if (i == myDict.end()) {
70  myDict[name] = o;
71  return true;
72  }
73  return false;
74 }
75 
76 
78 NIVissimClosures::dictionary(const std::string& name) {
79  DictType::iterator i = myDict.find(name);
80  if (i == myDict.end()) {
81  return 0;
82  }
83  return (*i).second;
84 }
85 
86 
87 
88 void
90  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
91  delete(*i).second;
92  }
93  myDict.clear();
94 }
95 
96 
97 
98 /****************************************************************************/
99 
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