|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A container for traffic light definitions and built programs 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef NBTrafficLightLogicCont_h 00020 #define NBTrafficLightLogicCont_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <map> 00033 #include <string> 00034 #include "NBTrafficLightDefinition.h" 00035 00036 00037 // =========================================================================== 00038 // class declarations 00039 // =========================================================================== 00040 class OptionsCont; 00041 class NBEdgeCont; 00042 class OutputDevice; 00043 00044 00045 // =========================================================================== 00046 // class definitions 00047 // =========================================================================== 00062 class NBTrafficLightLogicCont { 00063 public: 00065 NBTrafficLightLogicCont() throw(); 00066 00068 ~NBTrafficLightLogicCont() throw(); 00069 00078 void applyOptions(OptionsCont& oc) throw(); 00079 00080 00090 bool insert(NBTrafficLightDefinition* logic, bool forceInsert=false) throw(); 00091 00092 00101 bool removeFully(const std::string id); 00102 00103 00114 bool removeProgram(const std::string id, const std::string programID, bool del=true); 00115 00116 00120 void extract(NBTrafficLightDefinition* definition); 00121 00122 00124 std::vector<NBTrafficLightLogic*> getComputed() const; 00125 00126 00137 std::pair<unsigned int, unsigned int> computeLogics(NBEdgeCont& ec, OptionsCont& oc); 00138 00139 00147 bool computeSingleLogic(NBEdgeCont& ec, OptionsCont& oc, NBTrafficLightDefinition* def); 00148 00149 00157 void remapRemoved(NBEdge* removed, 00158 const EdgeVector& incoming, const EdgeVector& outgoing) throw(); 00159 00160 00169 void replaceRemoved(NBEdge* removed, int removedLane, 00170 NBEdge* by, int byLane) throw(); 00171 00172 00179 NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const; 00180 00181 00187 const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const; 00188 00189 00196 NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const; 00197 00198 00208 void setTLControllingInformation(const NBEdgeCont& ec) throw(); 00209 00210 00211 private: 00213 typedef std::map<std::string, NBTrafficLightLogic*> Program2Logic; 00214 typedef std::map<std::string, Program2Logic> Id2Logics; 00215 typedef std::map<std::string, NBTrafficLightDefinition*> Program2Def; 00216 typedef std::map<std::string, Program2Def> Id2Defs; 00217 typedef std::vector<NBTrafficLightLogic*> Logics; 00218 typedef std::vector<NBTrafficLightDefinition*> Definitions; 00219 00221 Id2Logics myComputed; 00222 00224 Id2Defs myDefinitions; 00225 00227 std::set<NBTrafficLightDefinition*> myExtracted; 00228 00230 std::set<std::string> myHalfOffsetTLS; 00231 00233 std::set<std::string> myQuarterOffsetTLS; 00234 00235 static const Program2Def EmptyDefinitions; 00236 00237 private: 00239 Definitions getDefinitions() const; 00240 00243 void clear() throw(); 00244 00245 00246 }; 00247 00248 00249 #endif 00250 00251 /****************************************************************************/ 00252