DistributionCont.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A container for distributions
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 "DistributionCont.h"
00029 
00030 #ifdef CHECK_MEMORY_LEAKS
00031 #include <foreign/nvwa/debug_new.h>
00032 #endif // CHECK_MEMORY_LEAKS
00033 
00034 
00035 // ===========================================================================
00036 // static variable definitions
00037 // ===========================================================================
00038 DistributionCont::TypedDistDict DistributionCont::myDict;
00039 
00040 
00041 // ===========================================================================
00042 // method definitions
00043 // ===========================================================================
00044 bool
00045 DistributionCont::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 DistributionCont::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 
00080 /****************************************************************************/
00081 

Generated on Wed May 5 00:06:28 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6