DistributionCont.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00037
00038 DistributionCont::TypedDistDict DistributionCont::myDict;
00039
00040
00041
00042
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