SUMO - Simulation of Urban MObility
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-2017 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 
38 
39 NIVissimClosures::NIVissimClosures(const std::string& id,
40  int from_node, int to_node,
41  std::vector<int>& overEdges)
42  : myID(id), myFromNode(from_node), myToNode(to_node),
43  myOverEdges(overEdges) {}
44 
45 
47 
48 
49 bool
50 NIVissimClosures::dictionary(const std::string& id,
51  int from_node, int to_node,
52  std::vector<int>& overEdges) {
53  NIVissimClosures* o = new NIVissimClosures(id, from_node, to_node,
54  overEdges);
55  if (!dictionary(id, o)) {
56  delete o;
57  return false;
58  }
59  return true;
60 }
61 
62 
63 bool
64 NIVissimClosures::dictionary(const std::string& name, NIVissimClosures* o) {
65  DictType::iterator i = myDict.find(name);
66  if (i == myDict.end()) {
67  myDict[name] = o;
68  return true;
69  }
70  return false;
71 }
72 
73 
75 NIVissimClosures::dictionary(const std::string& name) {
76  DictType::iterator i = myDict.find(name);
77  if (i == myDict.end()) {
78  return 0;
79  }
80  return (*i).second;
81 }
82 
83 
84 
85 void
87  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
88  delete(*i).second;
89  }
90  myDict.clear();
91 }
92 
93 
94 
95 /****************************************************************************/
96 
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