SUMO - Simulation of Urban MObility
NIVissimSource.cpp
Go to the documentation of this file.
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 <string>
00033 #include <map>
00034 #include "NIVissimSource.h"
00035 
00036 #ifdef CHECK_MEMORY_LEAKS
00037 #include <foreign/nvwa/debug_new.h>
00038 #endif // CHECK_MEMORY_LEAKS
00039 
00040 NIVissimSource::DictType NIVissimSource::myDict;
00041 
00042 NIVissimSource::NIVissimSource(const std::string& id, const std::string& name,
00043                                const std::string& edgeid, SUMOReal q,
00044                                bool exact, int vehicle_combination,
00045                                SUMOReal beg, SUMOReal end)
00046     : myID(id), myName(name), myEdgeID(edgeid), myQ(q), myExact(exact),
00047       myVehicleCombination(vehicle_combination),
00048       myTimeBeg(beg), myTimeEnd(end) {}
00049 
00050 
00051 NIVissimSource::~NIVissimSource() {}
00052 
00053 
00054 bool
00055 NIVissimSource::dictionary(const std::string& id, const std::string& name,
00056                            const std::string& edgeid, SUMOReal q, bool exact,
00057                            int vehicle_combination, SUMOReal beg, SUMOReal end) {
00058     NIVissimSource* o = new NIVissimSource(id, name, edgeid, q, exact,
00059                                            vehicle_combination, beg, end);
00060     if (!dictionary(id, o)) {
00061         delete o;
00062         return false;
00063     }
00064     return true;
00065 }
00066 
00067 
00068 bool
00069 NIVissimSource::dictionary(const std::string& id, NIVissimSource* o) {
00070     DictType::iterator i = myDict.find(id);
00071     if (i == myDict.end()) {
00072         myDict[id] = o;
00073         return true;
00074     }
00075     return false;
00076 }
00077 
00078 
00079 NIVissimSource*
00080 NIVissimSource::dictionary(const std::string& id) {
00081     DictType::iterator i = myDict.find(id);
00082     if (i == myDict.end()) {
00083         return 0;
00084     }
00085     return (*i).second;
00086 }
00087 
00088 
00089 void
00090 NIVissimSource::clearDict() {
00091     for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
00092         delete(*i).second;
00093     }
00094     myDict.clear();
00095 }
00096 
00097 
00098 
00099 /****************************************************************************/
00100 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines