SUMO - Simulation of Urban MObility
NBTrafficLightLogicCont.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A container for traffic light definitions and built programs
20 /****************************************************************************/
21 #ifndef NBTrafficLightLogicCont_h
22 #define NBTrafficLightLogicCont_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <map>
35 #include <string>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class OptionsCont;
43 class NBEdgeCont;
44 class OutputDevice;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
65 public:
68 
71 
80  void applyOptions(OptionsCont& oc);
81 
82 
92  bool insert(NBTrafficLightDefinition* logic, bool forceInsert = false);
93 
94 
103  bool removeFully(const std::string id);
104 
105 
116  bool removeProgram(const std::string id, const std::string programID, bool del = true);
117 
118 
122  void extract(NBTrafficLightDefinition* definition);
123 
124 
126  int getNumExtracted() const {
127  return (int)myExtracted.size();
128  }
129 
130 
132  std::vector<NBTrafficLightLogic*> getComputed() const;
133 
134 
144  std::pair<int, int> computeLogics(OptionsCont& oc);
145 
146 
154 
155 
163  void remapRemoved(NBEdge* removed,
164  const EdgeVector& incoming, const EdgeVector& outgoing);
165 
166 
175  void replaceRemoved(NBEdge* removed, int removedLane,
176  NBEdge* by, int byLane);
177 
178 
185  NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const;
186 
187 
193  const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const;
194 
195 
202  NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const;
203 
204 
214  void setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc);
215 
216 
217 private:
219  typedef std::map<std::string, NBTrafficLightLogic*> Program2Logic;
220  typedef std::map<std::string, Program2Logic> Id2Logics;
221  typedef std::map<std::string, NBTrafficLightDefinition*> Program2Def;
222  typedef std::map<std::string, Program2Def> Id2Defs;
223  typedef std::vector<NBTrafficLightLogic*> Logics;
224  typedef std::vector<NBTrafficLightDefinition*> Definitions;
225 
227  Id2Logics myComputed;
228 
230  Id2Defs myDefinitions;
231 
233  std::set<NBTrafficLightDefinition*> myExtracted;
234 
236  std::set<std::string> myHalfOffsetTLS;
237 
239  std::set<std::string> myQuarterOffsetTLS;
240 
241  static const Program2Def EmptyDefinitions;
242 
243 private:
245  Definitions getDefinitions() const;
246 
249  void clear();
250 
251 
252 };
253 
254 
255 #endif
256 
257 /****************************************************************************/
258 
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
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
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.
std::set< std::string > myQuarterOffsetTLS
List of tls which shall have an offset of T/2.
std::map< std::string, NBTrafficLightDefinition * > Program2Def
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
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.
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
std::vector< NBTrafficLightLogic * > Logics
Id2Defs myDefinitions
The container for tl-ids to their definitions.
std::vector< NBTrafficLightLogic * > getComputed() const
Returns a list of all computed logics.
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by NETEDIT)
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:40
int getNumExtracted() const
return the number of extracted traffic light definitions
A storage for options typed value containers)
Definition: OptionsCont.h:98
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:70
void clear()
Destroys all stored definitions and logics.
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:66
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
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
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.
Definitions getDefinitions() const
Returns a list of all definitions (convenience for easier iteration)