Eclipse 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-2019 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 /****************************************************************************/
16 // A container for traffic light definitions and built programs
17 /****************************************************************************/
18 #ifndef NBTrafficLightLogicCont_h
19 #define NBTrafficLightLogicCont_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <map>
28 #include <string>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class OptionsCont;
36 class NBEdgeCont;
37 class OutputDevice;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
58 public:
61 
64 
73  void applyOptions(OptionsCont& oc);
74 
75 
85  bool insert(NBTrafficLightDefinition* logic, bool forceInsert = false);
86 
87 
96  bool removeFully(const std::string id);
97 
98 
109  bool removeProgram(const std::string id, const std::string programID, bool del = true);
110 
111 
115  void extract(NBTrafficLightDefinition* definition);
116 
117 
119  int getNumExtracted() const {
120  return (int)myExtracted.size();
121  }
122 
123 
125  std::vector<NBTrafficLightLogic*> getComputed() const;
126 
127 
137  std::pair<int, int> computeLogics(OptionsCont& oc);
138 
139 
147 
148 
156  void remapRemoved(NBEdge* removed,
157  const EdgeVector& incoming, const EdgeVector& outgoing);
158 
159 
168  void replaceRemoved(NBEdge* removed, int removedLane,
169  NBEdge* by, int byLane);
170 
171 
178  NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const;
179 
180 
186  const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const;
187 
188 
195  NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const;
196 
197 
207  void setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc);
208 
210  typedef std::vector<NBTrafficLightDefinition*> Definitions;
211  Definitions getDefinitions() const;
212 
213 private:
215  typedef std::map<std::string, NBTrafficLightLogic*> Program2Logic;
216  typedef std::map<std::string, Program2Logic> Id2Logics;
217  typedef std::map<std::string, NBTrafficLightDefinition*> Program2Def;
218  typedef std::map<std::string, Program2Def> Id2Defs;
219  typedef std::vector<NBTrafficLightLogic*> Logics;
220 
223 
226 
228  std::set<NBTrafficLightDefinition*> myExtracted;
229 
231  std::set<std::string> myHalfOffsetTLS;
232 
234  std::set<std::string> myQuarterOffsetTLS;
235 
237 
238 private:
239 
242  void clear();
243 
244 
245 };
246 
247 
248 #endif
249 
250 /****************************************************************************/
251 
NBTrafficLightLogicCont::Program2Logic
std::map< std::string, NBTrafficLightLogic * > Program2Logic
Definition of internal the container types.
Definition: NBTrafficLightLogicCont.h:215
NBTrafficLightLogicCont::myComputed
Id2Logics myComputed
The container for previously computed tl-logics.
Definition: NBTrafficLightLogicCont.h:222
NBTrafficLightLogicCont::EmptyDefinitions
static const Program2Def EmptyDefinitions
Definition: NBTrafficLightLogicCont.h:236
NBTrafficLightLogicCont::getPrograms
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
Definition: NBTrafficLightLogicCont.cpp:243
NBTrafficLightLogicCont::removeProgram
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
Definition: NBTrafficLightLogicCont.cpp:119
NBEdgeCont
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:60
NBTrafficLightLogicCont
A container for traffic light definitions and built programs.
Definition: NBTrafficLightLogicCont.h:57
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
EdgeVector
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
NBTrafficLightDefinition.h
NBTrafficLightLogicCont::Definitions
std::vector< NBTrafficLightDefinition * > Definitions
Returns a list of all definitions (convenience for easier iteration)
Definition: NBTrafficLightLogicCont.h:210
NBTrafficLightLogicCont::myExtracted
std::set< NBTrafficLightDefinition * > myExtracted
The container for extracted definitions.
Definition: NBTrafficLightLogicCont.h:228
NBNodeCont
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:59
NBTrafficLightLogicCont::myQuarterOffsetTLS
std::set< std::string > myQuarterOffsetTLS
List of tls which shall have an offset of T/2.
Definition: NBTrafficLightLogicCont.h:234
NBEdge
The representation of a single edge during network building.
Definition: NBEdge.h:91
NBTrafficLightLogicCont::getDefinition
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
Definition: NBTrafficLightLogicCont.cpp:230
NBTrafficLightLogicCont::applyOptions
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
Definition: NBTrafficLightLogicCont.cpp:56
NBTrafficLightLogicCont::extract
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
Definition: NBTrafficLightLogicCont.cpp:133
NBTrafficLightLogicCont::Program2Def
std::map< std::string, NBTrafficLightDefinition * > Program2Def
Definition: NBTrafficLightLogicCont.h:217
NBTrafficLightLogicCont::myHalfOffsetTLS
std::set< std::string > myHalfOffsetTLS
List of tls which shall have an offset of T/2.
Definition: NBTrafficLightLogicCont.h:231
NBTrafficLightLogicCont::remapRemoved
void remapRemoved(NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
Definition: NBTrafficLightLogicCont.cpp:210
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
NBTrafficLightLogicCont::myDefinitions
Id2Defs myDefinitions
The container for tl-ids to their definitions.
Definition: NBTrafficLightLogicCont.h:225
NBTrafficLightLogicCont::NBTrafficLightLogicCont
NBTrafficLightLogicCont()
Constructor.
Definition: NBTrafficLightLogicCont.cpp:47
NBTrafficLightLogicCont::getComputed
std::vector< NBTrafficLightLogic * > getComputed() const
Returns a list of all computed logics.
Definition: NBTrafficLightLogicCont.cpp:295
NBTrafficLightLogicCont::Logics
std::vector< NBTrafficLightLogic * > Logics
Definition: NBTrafficLightLogicCont.h:219
NBTrafficLightLogicCont::getNumExtracted
int getNumExtracted() const
return the number of extracted traffic light definitions
Definition: NBTrafficLightLogicCont.h:119
NBTrafficLightLogicCont::removeFully
bool removeFully(const std::string id)
Removes a logic definition (and all programs) from the dictionary.
Definition: NBTrafficLightLogicCont.cpp:97
NBTrafficLightLogicCont::Id2Defs
std::map< std::string, Program2Def > Id2Defs
Definition: NBTrafficLightLogicCont.h:218
NBTrafficLightLogicCont::Id2Logics
std::map< std::string, Program2Logic > Id2Logics
Definition: NBTrafficLightLogicCont.h:216
config.h
NBTrafficLightLogicCont::computeSingleLogic
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by NETEDIT)
Definition: NBTrafficLightLogicCont.cpp:160
NBTrafficLightLogicCont::setTLControllingInformation
void setTLControllingInformation(const NBEdgeCont &ec, const NBNodeCont &nc)
Informs the edges about being controlled by a tls.
Definition: NBTrafficLightLogicCont.cpp:268
NBTrafficLightLogic
A SUMO-compliant built logic for a traffic light.
Definition: NBTrafficLightLogic.h:51
NBTrafficLightLogicCont::~NBTrafficLightLogicCont
~NBTrafficLightLogicCont()
Destructor.
Definition: NBTrafficLightLogicCont.cpp:50
NBTrafficLightLogicCont::getLogic
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
Definition: NBTrafficLightLogicCont.cpp:254
NBTrafficLightLogicCont::clear
void clear()
Destroys all stored definitions and logics.
Definition: NBTrafficLightLogicCont.cpp:191
NBTrafficLightLogicCont::getDefinitions
Definitions getDefinitions() const
Definition: NBTrafficLightLogicCont.cpp:308
NBTrafficLightLogicCont::computeLogics
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
Definition: NBTrafficLightLogicCont.cpp:140
NBTrafficLightLogicCont::insert
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
Definition: NBTrafficLightLogicCont.cpp:73
NBTrafficLightLogicCont::replaceRemoved
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
Definition: NBTrafficLightLogicCont.cpp:220
NBTrafficLightDefinition
The base class for traffic light logic definitions.
Definition: NBTrafficLightDefinition.h:67