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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A container for traffic light definitions and built programs
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <map>
26 #include <string>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 class OptionsCont;
34 class NBEdgeCont;
35 class OutputDevice;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
56 public:
59 
62 
71  void applyOptions(OptionsCont& oc);
72 
73 
83  bool insert(NBTrafficLightDefinition* logic, bool forceInsert = false);
84 
85 
94  bool removeFully(const std::string id);
95 
96 
107  bool removeProgram(const std::string id, const std::string programID, bool del = true);
108 
109 
113  void extract(NBTrafficLightDefinition* definition);
114 
115 
117  int getNumExtracted() const {
118  return (int)myExtracted.size();
119  }
120 
121 
123  std::vector<NBTrafficLightLogic*> getComputed() const;
124 
125 
135  std::pair<int, int> computeLogics(OptionsCont& oc);
136 
137 
145 
146 
154  void remapRemoved(NBEdge* removed,
155  const EdgeVector& incoming, const EdgeVector& outgoing);
156 
157 
166  void replaceRemoved(NBEdge* removed, int removedLane,
167  NBEdge* by, int byLane, bool incoming);
168 
169 
176  NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const;
177 
178 
184  const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const;
185 
186 
193  NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const;
194 
195 
205  void setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc);
206 
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 
224 
227 
229  std::set<NBTrafficLightDefinition*> myExtracted;
230 
232  std::set<std::string> myHalfOffsetTLS;
233 
235  std::set<std::string> myQuarterOffsetTLS;
236 
238 
239 private:
240 
243  void clear();
244 
245 
246 };
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:35
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:59
The representation of a single edge during network building.
Definition: NBEdge.h:91
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:58
The base class for traffic light logic definitions.
A container for traffic light definitions and built programs.
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane, bool incoming)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
void applyOptions(OptionsCont &oc)
Initialises the storage by applying given options.
void setOpenDriveSignalParameters()
set OpenDRIVE signal reference parameters after all link indices are known
std::vector< NBTrafficLightLogic * > getComputed() const
Returns a list of all computed logics.
std::map< std::string, NBTrafficLightDefinition * > Program2Def
std::set< std::string > myHalfOffsetTLS
List of tls which shall have an offset of T/2.
static const Program2Def EmptyDefinitions
std::vector< NBTrafficLightLogic * > Logics
std::vector< NBTrafficLightDefinition * > Definitions
Returns a list of all definitions (convenience for easier iteration)
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
bool computeSingleLogic(OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by NETEDIT)
int getNumExtracted() const
return the number of extracted traffic light definitions
std::map< std::string, Program2Logic > Id2Logics
void clear()
Destroys all stored definitions and logics.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
std::map< std::string, Program2Def > Id2Defs
void remapRemoved(NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing)
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
std::set< std::string > myQuarterOffsetTLS
List of tls which shall have an offset of T/2.
Id2Logics myComputed
The container for previously computed tl-logics.
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
Id2Defs myDefinitions
The container for tl-ids to their definitions.
std::pair< int, int > computeLogics(OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
bool removeFully(const std::string id)
Removes a logic definition (and all programs) from the dictionary.
std::map< std::string, NBTrafficLightLogic * > Program2Logic
Definition of internal the container types.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
void setTLControllingInformation(const NBEdgeCont &ec, const NBNodeCont &nc)
Informs the edges about being controlled by a tls.
std::set< NBTrafficLightDefinition * > myExtracted
The container for extracted definitions.
A SUMO-compliant built logic for a traffic light.
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61