44 #ifdef CHECK_MEMORY_LEAKS
46 #endif // CHECK_MEMORY_LEAKS
69 if (oc.
isSet(
"tls.half-offset")) {
75 if (oc.
isSet(
"tls.quarter-offset")) {
76 std::vector<std::string> ids = oc.
getStringVector(
"tls.quarter-offset");
90 for (Program2Def::const_iterator it_prog = programs.begin(); it_prog != programs.end(); it_prog++) {
91 idS.
avoid(it_prog->first);
149 std::pair<unsigned int, unsigned int>
153 for (Logics::iterator it = logics.begin(); it != logics.end(); it++) {
158 unsigned int numPrograms = 0;
160 for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
165 return std::pair<unsigned int, unsigned int>((
unsigned int)
myComputed.size(), numPrograms);
171 const std::string&
id = def->
getID();
176 WRITE_WARNING(
"Could not build program '" + programID +
"' for traffic light '" +
id +
"'");
200 for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
205 for (Logics::iterator it = logics.begin(); it != logics.end(); it++) {
209 for (std::set<NBTrafficLightDefinition*>::iterator it =
myExtracted.begin(); it !=
myExtracted.end(); it++) {
220 for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
221 (*it)->remapRemoved(removed, incoming, outgoing);
230 for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
231 (*it)->replaceRemoved(removed, removedLane, by, byLane);
241 Program2Def::const_iterator i2 = programs.find(programID);
242 if (i2 != programs.end()) {
262 Id2Logics::const_iterator i =
myComputed.find(
id);
265 Program2Logic::const_iterator i2 = programs.find(programID);
266 if (i2 != programs.end()) {
278 for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
279 (*it)->setParticipantsInformation();
284 for (Definitions::iterator it = definitions.begin(); it != definitions.end(); it++) {
285 (*it)->setTLControllingInformation(ec);
293 for (Id2Logics::const_iterator it_id =
myComputed.begin(); it_id !=
myComputed.end(); it_id++) {
295 for (Program2Logic::const_iterator it_prog = programs.begin(); it_prog != programs.end(); it_prog++) {
296 result.push_back(it_prog->second);
308 for (Program2Def::const_iterator it_prog = programs.begin(); it_prog != programs.end(); it_prog++) {
309 result.push_back(it_prog->second);
std::map< std::string, NBTrafficLightLogic * > Program2Logic
Definition of internal the container types.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
void setTLControllingInformation(const NBEdgeCont &ec)
Informs the edges about being controlled by a tls.
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 SUMO-compliant built logic for a traffic light.
const std::string & getProgramID() const
Returns the ProgramID.
The representation of a single edge during network building.
void avoid(const std::string &id)
make sure that the given id is never supplied
The base class for traffic light logic definitions.
void setOffset(SUMOTime offset)
Sets the offset of this tls.
std::vector< NBTrafficLightDefinition * > Definitions
void clearControllingTLInformation() const
Clears information about controlling traffic lights for all connenections of all edges.
Definitions getDefinitions() const
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...
#define WRITE_WARNING(msg)
std::set< NBTrafficLightDefinition * > myExtracted
The container for extracted definitions.
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
std::set< std::string > myQuarterOffsetTLS
List of tls which shall have an offset of T/2.
const std::string & getID() const
Returns the id.
std::map< std::string, NBTrafficLightDefinition * > Program2Def
std::string getNext()
Returns the next id.
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.
NBTrafficLightLogic * compute(const NBEdgeCont &ec, OptionsCont &oc)
Computes the traffic light logic.
std::set< std::string > myHalfOffsetTLS
List of tls which shall have an offset of T/2.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
Storage for edges, including some functionality operating on multiple edges.
std::vector< NBTrafficLightLogic * > getComputed() const
Returns a list of all computed logics.
std::pair< unsigned int, unsigned int > computeLogics(NBEdgeCont &ec, OptionsCont &oc)
Computes the traffic light logics using the stored definitions and stores the results.
void setProgramID(const std::string &programID)
Sets the programID.
SUMOTime getDuration() const
Returns the duration of the complete cycle.
std::vector< NBTrafficLightLogic * > Logics
NBTrafficLightLogicCont()
Constructor.
Id2Defs myDefinitions
The container for tl-ids to their definitions.
NBTrafficLightLogic * getLogic(const std::string &id, const std::string &programID) const
Returns the computed logic for the given name.
std::vector< NBEdge * > EdgeVector
A storage for options typed value containers)
bool computeSingleLogic(NBEdgeCont &ec, OptionsCont &oc, NBTrafficLightDefinition *def)
Computes a specific traffic light logic (using by NETEDIT)
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.
void clear()
Destroys all stored definitions and logics.
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane)
Replaces occurences of the removed edge/lane in all definitions by the given edge.
Id2Logics myComputed
The container for previously computed tl-logics.
~NBTrafficLightLogicCont()
Destructor.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.