NIVissimVehTypeClass.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
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <string>
00031 #include <utils/common/RGBColor.h>
00032 #include <utils/common/VectorHelper.h>
00033 #include "NIVissimVehTypeClass.h"
00034
00035 #ifdef CHECK_MEMORY_LEAKS
00036 #include <foreign/nvwa/debug_new.h>
00037 #endif // CHECK_MEMORY_LEAKS
00038
00039
00040 NIVissimVehTypeClass::DictType NIVissimVehTypeClass::myDict;
00041
00042 NIVissimVehTypeClass::NIVissimVehTypeClass(int id,
00043 const std::string &name,
00044 const RGBColor &color,
00045 IntVector &types)
00046 : myID(id), myName(name), myColor(color), myTypes(types) {}
00047
00048 NIVissimVehTypeClass::~NIVissimVehTypeClass() {}
00049
00050
00051 bool
00052 NIVissimVehTypeClass::dictionary(int id, const std::string &name,
00053 const RGBColor &color,
00054 IntVector &types) {
00055 NIVissimVehTypeClass *o = new NIVissimVehTypeClass(id, name, color, types);
00056 if (!dictionary(id, o)) {
00057 delete o;
00058 return false;
00059 }
00060 return true;
00061 }
00062
00063
00064
00065
00066 bool
00067 NIVissimVehTypeClass::dictionary(int name, NIVissimVehTypeClass *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 NIVissimVehTypeClass *
00078 NIVissimVehTypeClass::dictionary(int 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 void
00088 NIVissimVehTypeClass::clearDict() {
00089 for (DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
00090 delete(*i).second;
00091 }
00092 myDict.clear();
00093 }
00094
00095
00096
00097
00098