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 00032 #include "NIVissimVehicleType.h" 00033 00034 #ifdef CHECK_MEMORY_LEAKS 00035 #include <foreign/nvwa/debug_new.h> 00036 #endif // CHECK_MEMORY_LEAKS 00037 00038 NIVissimVehicleType::DictType NIVissimVehicleType::myDict; 00039 00040 NIVissimVehicleType::NIVissimVehicleType(int id, 00041 const std::string& name, const std::string& category, SUMOReal length, 00042 const RGBColor& color, SUMOReal amax, SUMOReal dmax) 00043 : myID(id), myName(name), myCategory(category), myLength(length), 00044 myColor(color), myAMax(amax), myDMax(dmax) {} 00045 00046 00047 NIVissimVehicleType::~NIVissimVehicleType() {} 00048 00049 00050 00051 bool 00052 NIVissimVehicleType::dictionary(int id, 00053 const std::string& name, const std::string& category, SUMOReal length, 00054 const RGBColor& color, SUMOReal amax, SUMOReal dmax) { 00055 NIVissimVehicleType* o = new NIVissimVehicleType(id, name, category, 00056 length, color, amax, dmax); 00057 if (!dictionary(id, o)) { 00058 delete o; 00059 return false; 00060 } 00061 return true; 00062 } 00063 00064 00065 bool 00066 NIVissimVehicleType::dictionary(int id, NIVissimVehicleType* o) { 00067 DictType::iterator i = myDict.find(id); 00068 if (i == myDict.end()) { 00069 myDict[id] = o; 00070 return true; 00071 } 00072 return false; 00073 } 00074 00075 00076 NIVissimVehicleType* 00077 NIVissimVehicleType::dictionary(int id) { 00078 DictType::iterator i = myDict.find(id); 00079 if (i == myDict.end()) { 00080 return 0; 00081 } 00082 return (*i).second; 00083 } 00084 00085 void 00086 NIVissimVehicleType::clearDict() { 00087 for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) { 00088 delete(*i).second; 00089 } 00090 myDict.clear(); 00091 } 00092 00093 00094 00095 /****************************************************************************/ 00096