SUMO - Simulation of Urban MObility
NBTrafficLightLogicCont.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A container for traffic light definitions and built programs
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NBTrafficLightLogicCont_h
23 #define NBTrafficLightLogicCont_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <map>
36 #include <string>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class OptionsCont;
44 class NBEdgeCont;
45 class OutputDevice;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
66 public:
69 
72 
81  void applyOptions(OptionsCont& oc);
82 
83 
93  bool insert(NBTrafficLightDefinition* logic, bool forceInsert = false);
94 
95 
104  bool removeFully(const std::string id);
105 
106 
117  bool removeProgram(const std::string id, const std::string programID, bool del = true);
118 
119 
123  void extract(NBTrafficLightDefinition* definition);
124 
125 
127  int getNumExtracted() const {
128  return (int)myExtracted.size();
129  }
130 
131 
133  std::vector<NBTrafficLightLogic*> getComputed() const;
134 
135 
145  std::pair<int, int> computeLogics(OptionsCont& oc);
146 
147 
155 
156 
164  void remapRemoved(NBEdge* removed,
165  const EdgeVector& incoming, const EdgeVector& outgoing);
166 
167 
176  void replaceRemoved(NBEdge* removed, int removedLane,
177  NBEdge* by, int byLane);
178 
179 
186  NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const;
187 
188 
194  const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const;
195 
196 
203  NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const;
204 
205 
215  void setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc);
216 
217 
218 private:
220  typedef std::map<std::string, NBTrafficLightLogic*> Program2Logic;
221  typedef std::map<std::string, Program2Logic> Id2Logics;
222  typedef std::map<std::string, NBTrafficLightDefinition*> Program2Def;
223  typedef std::map<std::string, Program2Def> Id2Defs;
224  typedef std::vector<NBTrafficLightLogic*> Logics;
225  typedef std::vector<NBTrafficLightDefinition*> Definitions;
226 
228  Id2Logics myComputed;
229 
231  Id2Defs myDefinitions;
232 
234  std::set<NBTrafficLightDefinition*> myExtracted;
235 
237  std::set<std::string> myHalfOffsetTLS;
238 
240  std::set<std::string> myQuarterOffsetTLS;
241 
242  static const Program2Def EmptyDefinitions;
243 
244 private:
246  Definitions getDefinitions() const;
247 
250  void clear();
251 
252 
253 };
254 
255 
256 #endif
257 
258 /****************************************************************************/
259 
std::map< std::string, NBTrafficLightLogic * > Program2Logic
Definition of internal the container types.
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
static const Program2Def EmptyDefinitions
A container for traffic light definitions and built programs.
A SUMO-compliant built logic for a traffic light.
The representation of a single edge during network building.
Definition: NBEdge.h:70
The base class for traffic light logic definitions.
std::vector< NBTrafficLightDefinition * > Definitions
Definitions getDefinitions() const
Returns a list of all definitions (convenience for easier iteration)
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
std::set< NBTrafficLightDefinition * > myExtracted
The container for extracted definitions.
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
std::set< std::string > myQuarterOffsetTLS
List of tls which shall have an offset of T/2.
int getNumExtracted() const
return the number of extracted traffic light definitions
std::map< std::string, NBTrafficLightDefinition * > Program2Def
void remapRemoved(NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
std::set< std::string > myHalfOffsetTLS
List of tls which shall have an offset of T/2.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
std::vector< NBTrafficLightLogic * > getComputed() const
Returns a list of all computed logics.
std::vector< NBTrafficLightLogic * > Logics
Id2Defs myDefinitions
The container for tl-ids to their definitions.
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by NETEDIT)
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
A storage for options typed value containers)
Definition: OptionsCont.h:99
std::map< std::string, Program2Def > Id2Defs
bool removeFully(const std::string id)
Removes a logic definition (and all programs) from the dictionary.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
void clear()
Destroys all stored definitions and logics.
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:63
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
std::map< std::string, Program2Logic > Id2Logics
void setTLControllingInformation(const NBEdgeCont &ec, const NBNodeCont &nc)
Informs the edges about being controlled by a tls.
Id2Logics myComputed
The container for previously computed tl-logics.
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.