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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A container for traffic light definitions and built programs
18 /****************************************************************************/
19 #ifndef NBTrafficLightLogicCont_h
20 #define NBTrafficLightLogicCont_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <map>
29 #include <string>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class OptionsCont;
37 class NBEdgeCont;
38 class OutputDevice;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
59 public:
62 
65 
74  void applyOptions(OptionsCont& oc);
75 
76 
86  bool insert(NBTrafficLightDefinition* logic, bool forceInsert = false);
87 
88 
97  bool removeFully(const std::string id);
98 
99 
110  bool removeProgram(const std::string id, const std::string programID, bool del = true);
111 
112 
116  void extract(NBTrafficLightDefinition* definition);
117 
118 
120  int getNumExtracted() const {
121  return (int)myExtracted.size();
122  }
123 
124 
126  std::vector<NBTrafficLightLogic*> getComputed() const;
127 
128 
138  std::pair<int, int> computeLogics(OptionsCont& oc);
139 
140 
148 
149 
157  void remapRemoved(NBEdge* removed,
158  const EdgeVector& incoming, const EdgeVector& outgoing);
159 
160 
169  void replaceRemoved(NBEdge* removed, int removedLane,
170  NBEdge* by, int byLane);
171 
172 
179  NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const;
180 
181 
187  const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const;
188 
189 
196  NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const;
197 
198 
208  void setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc);
209 
211  typedef std::vector<NBTrafficLightDefinition*> Definitions;
212  Definitions getDefinitions() const;
213 
214 private:
216  typedef std::map<std::string, NBTrafficLightLogic*> Program2Logic;
217  typedef std::map<std::string, Program2Logic> Id2Logics;
218  typedef std::map<std::string, NBTrafficLightDefinition*> Program2Def;
219  typedef std::map<std::string, Program2Def> Id2Defs;
220  typedef std::vector<NBTrafficLightLogic*> Logics;
221 
223  Id2Logics myComputed;
224 
226  Id2Defs myDefinitions;
227 
229  std::set<NBTrafficLightDefinition*> myExtracted;
230 
232  std::set<std::string> myHalfOffsetTLS;
233 
235  std::set<std::string> myQuarterOffsetTLS;
236 
237  static const Program2Def EmptyDefinitions;
238 
239 private:
240 
243  void clear();
244 
245 
246 };
247 
248 
249 #endif
250 
251 /****************************************************************************/
252 
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:65
The base class for traffic light logic definitions.
std::vector< NBTrafficLightDefinition * > Definitions
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.
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:61
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:34
int getNumExtracted() const
return the number of extracted traffic light definitions
A storage for options typed value containers)
Definition: OptionsCont.h:92
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:64
void clear()
Destroys all stored definitions and logics.
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
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.