NIVissimSource.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 <string>
00032 #include <map>
00033 #include "NIVissimSource.h"
00034
00035 #ifdef CHECK_MEMORY_LEAKS
00036 #include <foreign/nvwa/debug_new.h>
00037 #endif // CHECK_MEMORY_LEAKS
00038
00039 NIVissimSource::DictType NIVissimSource::myDict;
00040
00041 NIVissimSource::NIVissimSource(const std::string &id, const std::string &name,
00042 const std::string &edgeid, SUMOReal q,
00043 bool exact, int vehicle_combination,
00044 SUMOReal beg, SUMOReal end)
00045 : myID(id), myName(name), myEdgeID(edgeid), myQ(q), myExact(exact),
00046 myVehicleCombination(vehicle_combination),
00047 myTimeBeg(beg), myTimeEnd(end) {}
00048
00049
00050 NIVissimSource::~NIVissimSource() {}
00051
00052
00053 bool
00054 NIVissimSource::dictionary(const std::string &id, const std::string &name,
00055 const std::string &edgeid, SUMOReal q, bool exact,
00056 int vehicle_combination, SUMOReal beg, SUMOReal end) {
00057 NIVissimSource *o = new NIVissimSource(id, name, edgeid, q, exact,
00058 vehicle_combination, beg, end);
00059 if (!dictionary(id, o)) {
00060 delete o;
00061 return false;
00062 }
00063 return true;
00064 }
00065
00066
00067 bool
00068 NIVissimSource::dictionary(const std::string &id, NIVissimSource *o) {
00069 DictType::iterator i=myDict.find(id);
00070 if (i==myDict.end()) {
00071 myDict[id] = o;
00072 return true;
00073 }
00074 return false;
00075 }
00076
00077
00078 NIVissimSource *
00079 NIVissimSource::dictionary(const std::string &id) {
00080 DictType::iterator i=myDict.find(id);
00081 if (i==myDict.end()) {
00082 return 0;
00083 }
00084 return (*i).second;
00085 }
00086
00087
00088 void
00089 NIVissimSource::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