Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NBTrafficLightLogicCont.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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// ===========================================================================
33class OptionsCont;
34class NBEdgeCont;
35class OutputDevice;
36
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
56public:
59
62
71 void applyOptions(OptionsCont& oc);
72
82 bool insert(NBTrafficLightDefinition* logic, bool forceInsert = false);
83
92 bool removeFully(const std::string id);
93
104 bool removeProgram(const std::string id, const std::string programID, bool del = true);
105
109 void extract(NBTrafficLightDefinition* definition);
110
112 bool exist(const std::string& newID, bool requireComputed = true) const;
113
115 void rename(NBTrafficLightDefinition* tlDef, const std::string& newID);
116
118 int getNumExtracted() const;
119
121 std::vector<NBTrafficLightLogic*> getComputed() const;
122
132 std::pair<int, int> computeLogics(OptionsCont& oc);
133
141
149 void remapRemoved(NBEdge* removed,
150 const EdgeVector& incoming, const EdgeVector& outgoing);
151
160 void replaceRemoved(NBEdge* removed, int removedLane,
161 NBEdge* by, int byLane, bool incoming);
162
169 NBTrafficLightDefinition* getDefinition(const std::string& id, const std::string& programID) const;
170
176 const std::map<std::string, NBTrafficLightDefinition*>& getPrograms(const std::string& id) const;
177
184 NBTrafficLightLogic* getLogic(const std::string& id, const std::string& programID) const;
185
195 void setTLControllingInformation(const NBEdgeCont& ec, const NBNodeCont& nc);
196
199
202
204 typedef std::vector<NBTrafficLightDefinition*> Definitions;
206
212 std::string getNextProgramID(const std::string& id) const;
213
214private:
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
239
241 void clear();
242};
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition NBCont.h:42
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:92
Container for nodes during the netbuilding process.
Definition NBNodeCont.h:57
The base class for traffic light logic definitions.
A container for traffic light definitions and built programs.
bool exist(const std::string &newID, bool requireComputed=true) const
check if exists a definition with the given ID
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane, bool incoming)
Replaces occurrences 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.
void rename(NBTrafficLightDefinition *tlDef, const std::string &newID)
rename traffic light
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
empty definition
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 occurrences 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.
void applyOpenDriveControllers(OptionsCont &oc)
post processing of signal programs to group tl indices according to OpenDrive controllers (signal gro...
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.
std::string getNextProgramID(const std::string &id) const
Returns a new (unused) programID for the given traffic light.
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.