SUMO - Simulation of Urban MObility
NBTrafficLightLogicCont.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // A container for traffic light definitions and built programs
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef NBTrafficLightLogicCont_h
00023 #define NBTrafficLightLogicCont_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <map>
00036 #include <string>
00037 #include "NBTrafficLightDefinition.h"
00038 
00039 
00040 // ===========================================================================
00041 // class declarations
00042 // ===========================================================================
00043 class OptionsCont;
00044 class NBEdgeCont;
00045 class OutputDevice;
00046 
00047 
00048 // ===========================================================================
00049 // class definitions
00050 // ===========================================================================
00065 class NBTrafficLightLogicCont {
00066 public:
00068     NBTrafficLightLogicCont() ;
00069 
00071     ~NBTrafficLightLogicCont() ;
00072 
00081     void applyOptions(OptionsCont& oc) ;
00082 
00083 
00093     bool insert(NBTrafficLightDefinition* logic, bool forceInsert = false) ;
00094 
00095 
00104     bool removeFully(const std::string id);
00105 
00106 
00117     bool removeProgram(const std::string id, const std::string programID, bool del = true);
00118 
00119 
00123     void extract(NBTrafficLightDefinition* definition);
00124 
00125 
00127     std::vector<NBTrafficLightLogic*> getComputed() const;
00128 
00129 
00140     std::pair<unsigned int, unsigned int> computeLogics(NBEdgeCont& ec, OptionsCont& oc);
00141 
00142 
00150     bool computeSingleLogic(NBEdgeCont& ec, OptionsCont& oc, NBTrafficLightDefinition* def);
00151 
00152 
00160     void remapRemoved(NBEdge* removed,
00161                       const EdgeVector& incoming, const EdgeVector& outgoing) ;
00162 
00163 
00172     void replaceRemoved(NBEdge* removed, int removedLane,
00173                         NBEdge* by, int byLane) ;
00174 
00175 
00182     NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const;
00183 
00184 
00190     const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const;
00191 
00192 
00199     NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const;
00200 
00201 
00211     void setTLControllingInformation(const NBEdgeCont& ec) ;
00212 
00213 
00214 private:
00216     typedef std::map<std::string, NBTrafficLightLogic*> Program2Logic;
00217     typedef std::map<std::string, Program2Logic> Id2Logics;
00218     typedef std::map<std::string, NBTrafficLightDefinition*> Program2Def;
00219     typedef std::map<std::string, Program2Def> Id2Defs;
00220     typedef std::vector<NBTrafficLightLogic*> Logics;
00221     typedef std::vector<NBTrafficLightDefinition*> Definitions;
00222 
00224     Id2Logics myComputed;
00225 
00227     Id2Defs myDefinitions;
00228 
00230     std::set<NBTrafficLightDefinition*> myExtracted;
00231 
00233     std::set<std::string> myHalfOffsetTLS;
00234 
00236     std::set<std::string> myQuarterOffsetTLS;
00237 
00238     static const Program2Def EmptyDefinitions;
00239 
00240 private:
00242     Definitions getDefinitions() const;
00243 
00246     void clear() ;
00247 
00248 
00249 };
00250 
00251 
00252 #endif
00253 
00254 /****************************************************************************/
00255 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines