SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // A container for districts 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include <iostream> 00034 #include <utils/common/MsgHandler.h> 00035 #include <utils/common/ToString.h> 00036 #include <utils/iodevices/OutputDevice.h> 00037 #include "NBDistrict.h" 00038 #include "NBDistrictCont.h" 00039 00040 #ifdef CHECK_MEMORY_LEAKS 00041 #include <foreign/nvwa/debug_new.h> 00042 #endif // CHECK_MEMORY_LEAKS 00043 00044 00045 // =========================================================================== 00046 // method definitions 00047 // =========================================================================== 00048 NBDistrictCont::NBDistrictCont() {} 00049 00050 00051 NBDistrictCont::~NBDistrictCont() { 00052 for (DistrictCont::iterator i = myDistricts.begin(); i != myDistricts.end(); i++) { 00053 delete((*i).second); 00054 } 00055 myDistricts.clear(); 00056 } 00057 00058 00059 bool 00060 NBDistrictCont::insert(NBDistrict* const district) { 00061 DistrictCont::const_iterator i = myDistricts.find(district->getID()); 00062 if (i != myDistricts.end()) { 00063 return false; 00064 } 00065 myDistricts.insert(DistrictCont::value_type(district->getID(), district)); 00066 return true; 00067 } 00068 00069 00070 NBDistrict* 00071 NBDistrictCont::retrieve(const std::string& id) const { 00072 DistrictCont::const_iterator i = myDistricts.find(id); 00073 if (i == myDistricts.end()) { 00074 return 0; 00075 } 00076 return (*i).second; 00077 } 00078 00079 00080 size_t 00081 NBDistrictCont::size() const { 00082 return myDistricts.size(); 00083 } 00084 00085 00086 bool 00087 NBDistrictCont::addSource(const std::string& dist, NBEdge* const source, 00088 SUMOReal weight) { 00089 NBDistrict* o = retrieve(dist); 00090 if (o == 0) { 00091 return false; 00092 } 00093 return o->addSource(source, weight); 00094 } 00095 00096 00097 bool 00098 NBDistrictCont::addSink(const std::string& dist, NBEdge* const destination, 00099 SUMOReal weight) { 00100 NBDistrict* o = retrieve(dist); 00101 if (o == 0) { 00102 return false; 00103 } 00104 return o->addSink(destination, weight); 00105 } 00106 00107 00108 void 00109 NBDistrictCont::removeFromSinksAndSources(NBEdge* const e) { 00110 for (DistrictCont::iterator i = myDistricts.begin(); i != myDistricts.end(); i++) { 00111 (*i).second->removeFromSinksAndSources(e); 00112 } 00113 } 00114 00115 00116 00117 /****************************************************************************/ 00118