SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // ------------------- 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This file is part of SUMO. 00014 // SUMO is free software: you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation, either version 3 of the License, or 00017 // (at your option) any later version. 00018 // 00019 /****************************************************************************/ 00020 00021 00022 // =========================================================================== 00023 // included modules 00024 // =========================================================================== 00025 #ifdef _MSC_VER 00026 #include <windows_config.h> 00027 #else 00028 #include <config.h> 00029 #endif 00030 00031 #include <string> 00032 #include <utils/common/RGBColor.h> 00033 #include <utils/common/VectorHelper.h> 00034 #include "NIVissimVehTypeClass.h" 00035 00036 #ifdef CHECK_MEMORY_LEAKS 00037 #include <foreign/nvwa/debug_new.h> 00038 #endif // CHECK_MEMORY_LEAKS 00039 00040 00041 NIVissimVehTypeClass::DictType NIVissimVehTypeClass::myDict; 00042 00043 NIVissimVehTypeClass::NIVissimVehTypeClass(int id, 00044 const std::string& name, 00045 const RGBColor& color, 00046 std::vector<int>& types) 00047 : myID(id), myName(name), myColor(color), myTypes(types) {} 00048 00049 NIVissimVehTypeClass::~NIVissimVehTypeClass() {} 00050 00051 00052 bool 00053 NIVissimVehTypeClass::dictionary(int id, const std::string& name, 00054 const RGBColor& color, 00055 std::vector<int>& types) { 00056 NIVissimVehTypeClass* o = new NIVissimVehTypeClass(id, name, color, types); 00057 if (!dictionary(id, o)) { 00058 delete o; 00059 return false; 00060 } 00061 return true; 00062 } 00063 00064 00065 00066 00067 bool 00068 NIVissimVehTypeClass::dictionary(int name, NIVissimVehTypeClass* o) { 00069 DictType::iterator i = myDict.find(name); 00070 if (i == myDict.end()) { 00071 myDict[name] = o; 00072 return true; 00073 } 00074 return false; 00075 } 00076 00077 00078 NIVissimVehTypeClass* 00079 NIVissimVehTypeClass::dictionary(int name) { 00080 DictType::iterator i = myDict.find(name); 00081 if (i == myDict.end()) { 00082 return 0; 00083 } 00084 return (*i).second; 00085 } 00086 00087 00088 void 00089 NIVissimVehTypeClass::clearDict() { 00090 for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) { 00091 delete(*i).second; 00092 } 00093 myDict.clear(); 00094 } 00095 00096 00097 00098 /****************************************************************************/ 00099