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