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