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