|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // The base class for statistical distribution descriptions 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 // included modules 00021 // =========================================================================== 00022 #ifdef _MSC_VER 00023 #include <windows_config.h> 00024 #else 00025 #include <config.h> 00026 #endif 00027 00028 #include "NBDistribution.h" 00029 00030 #ifdef CHECK_MEMORY_LEAKS 00031 #include <foreign/nvwa/debug_new.h> 00032 #endif // CHECK_MEMORY_LEAKS 00033 00034 00035 // =========================================================================== 00036 // static member variables 00037 // =========================================================================== 00038 NBDistribution::TypedDistDict NBDistribution::myDict; 00039 00040 00041 // =========================================================================== 00042 // method definitions 00043 // =========================================================================== 00044 bool 00045 NBDistribution::dictionary(const std::string& type, const std::string& id, 00046 Distribution* d) { 00047 TypedDistDict::iterator i=myDict.find(type); 00048 00049 if (i==myDict.end()) { 00050 myDict[type][id] = d; 00051 return true; 00052 } 00053 DistDict& dict = (*i).second; 00054 DistDict::iterator j=dict.find(id); 00055 if (j==dict.end()) { 00056 myDict[type][id] = d; 00057 return true; 00058 } 00059 return false; 00060 } 00061 00062 00063 Distribution* 00064 NBDistribution::dictionary(const std::string& type, 00065 const std::string& id) { 00066 TypedDistDict::iterator i=myDict.find(type); 00067 if (i==myDict.end()) { 00068 return 0; 00069 } 00070 DistDict& dict = (*i).second; 00071 DistDict::iterator j=dict.find(id); 00072 if (j==dict.end()) { 00073 return 0; 00074 } 00075 return (*j).second; 00076 } 00077 00078 00079 void 00080 NBDistribution::clear() { 00081 for (TypedDistDict::iterator i=myDict.begin(); i!=myDict.end(); i++) { 00082 DistDict& dict = (*i).second; 00083 for (DistDict::iterator j=dict.begin(); j!=dict.end(); j++) { 00084 delete(*j).second; 00085 } 00086 } 00087 } 00088 00089 00090 00091 /****************************************************************************/ 00092