|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // ------------------- 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 00020 00021 // =========================================================================== 00022 // included modules 00023 // =========================================================================== 00024 #ifdef _MSC_VER 00025 #include <windows_config.h> 00026 #else 00027 #include <config.h> 00028 #endif 00029 00030 #include <string> 00031 #include <utils/common/VectorHelper.h> 00032 #include "NIVissimClosures.h" 00033 00034 #ifdef CHECK_MEMORY_LEAKS 00035 #include <foreign/nvwa/debug_new.h> 00036 #endif // CHECK_MEMORY_LEAKS 00037 00038 00039 NIVissimClosures::DictType NIVissimClosures::myDict; 00040 00041 NIVissimClosures::NIVissimClosures(const std::string& id, 00042 int from_node, int to_node, 00043 IntVector& overEdges) 00044 : myID(id), myFromNode(from_node), myToNode(to_node), 00045 myOverEdges(overEdges) {} 00046 00047 00048 NIVissimClosures::~NIVissimClosures() {} 00049 00050 00051 bool 00052 NIVissimClosures::dictionary(const std::string& id, 00053 int from_node, int to_node, 00054 IntVector& overEdges) { 00055 NIVissimClosures* o = new NIVissimClosures(id, from_node, to_node, 00056 overEdges); 00057 if (!dictionary(id, o)) { 00058 delete o; 00059 return false; 00060 } 00061 return true; 00062 } 00063 00064 00065 bool 00066 NIVissimClosures::dictionary(const std::string& name, NIVissimClosures* o) { 00067 DictType::iterator i=myDict.find(name); 00068 if (i==myDict.end()) { 00069 myDict[name] = o; 00070 return true; 00071 } 00072 return false; 00073 } 00074 00075 00076 NIVissimClosures* 00077 NIVissimClosures::dictionary(const std::string& name) { 00078 DictType::iterator i=myDict.find(name); 00079 if (i==myDict.end()) { 00080 return 0; 00081 } 00082 return (*i).second; 00083 } 00084 00085 00086 00087 void 00088 NIVissimClosures::clearDict() { 00089 for (DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) { 00090 delete(*i).second; 00091 } 00092 myDict.clear(); 00093 } 00094 00095 00096 00097 /****************************************************************************/ 00098