Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2002-2024 German Aerospace Center (DLR) and others. 4 : // This program and the accompanying materials are made available under the 5 : // terms of the Eclipse Public License 2.0 which is available at 6 : // https://www.eclipse.org/legal/epl-2.0/ 7 : // This Source Code may also be made available under the following Secondary 8 : // Licenses when the conditions for such availability set forth in the Eclipse 9 : // Public License 2.0 are satisfied: GNU General Public License, version 2 10 : // or later which is available at 11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 13 : /****************************************************************************/ 14 : /// @file NIVissimVehTypeClass.cpp 15 : /// @author Daniel Krajzewicz 16 : /// @author Michael Behrisch 17 : /// @date Sept 2002 18 : /// 19 : // ------------------- 20 : /****************************************************************************/ 21 : #include <config.h> 22 : 23 : #include <string> 24 : #include <utils/common/RGBColor.h> 25 : #include <utils/common/VectorHelper.h> 26 : #include "NIVissimVehTypeClass.h" 27 : 28 : 29 : NIVissimVehTypeClass::DictType NIVissimVehTypeClass::myDict; 30 : 31 49 : NIVissimVehTypeClass::NIVissimVehTypeClass(int id, 32 : const std::string& name, 33 : const RGBColor& color, 34 49 : std::vector<int>& types) 35 49 : : myID(id), myName(name), myColor(color), myTypes(types) {} 36 : 37 49 : NIVissimVehTypeClass::~NIVissimVehTypeClass() {} 38 : 39 : 40 : bool 41 49 : NIVissimVehTypeClass::dictionary(int id, const std::string& name, 42 : const RGBColor& color, 43 : std::vector<int>& types) { 44 49 : NIVissimVehTypeClass* o = new NIVissimVehTypeClass(id, name, color, types); 45 49 : if (!dictionary(id, o)) { 46 0 : delete o; 47 0 : return false; 48 : } 49 : return true; 50 : } 51 : 52 : 53 : 54 : 55 : bool 56 49 : NIVissimVehTypeClass::dictionary(int name, NIVissimVehTypeClass* o) { 57 : DictType::iterator i = myDict.find(name); 58 49 : if (i == myDict.end()) { 59 49 : myDict[name] = o; 60 49 : return true; 61 : } 62 : return false; 63 : } 64 : 65 : 66 : NIVissimVehTypeClass* 67 0 : NIVissimVehTypeClass::dictionary(int name) { 68 : DictType::iterator i = myDict.find(name); 69 0 : if (i == myDict.end()) { 70 : return nullptr; 71 : } 72 0 : return (*i).second; 73 : } 74 : 75 : 76 : void 77 9 : NIVissimVehTypeClass::clearDict() { 78 58 : for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) { 79 49 : delete (*i).second; 80 : } 81 : myDict.clear(); 82 9 : } 83 : 84 : 85 : /****************************************************************************/