![]() |
SUMO - Simulation of Urban MObility
|
A container for traffic light definitions and built programs. More...
#include <NBTrafficLightLogicCont.h>
Public Member Functions | |
void | applyOptions (OptionsCont &oc) |
Initialises the storage by applying given options. More... | |
std::pair< int, int > | computeLogics (OptionsCont &oc) |
Computes the traffic light logics using the stored definitions and stores the results. More... | |
bool | computeSingleLogic (OptionsCont &oc, NBTrafficLightDefinition *def) |
Computes a specific traffic light logic (using by NETEDIT) More... | |
void | extract (NBTrafficLightDefinition *definition) |
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * deletion (used by NETEDIT) More... | |
std::vector< NBTrafficLightLogic * > | getComputed () const |
Returns a list of all computed logics. More... | |
NBTrafficLightDefinition * | getDefinition (const std::string &id, const std::string &programID) const |
Returns the named definition. More... | |
NBTrafficLightLogic * | getLogic (const std::string &id, const std::string &programID) const |
Returns the computed logic for the given name. More... | |
int | getNumExtracted () const |
return the number of extracted traffic light definitions More... | |
const std::map< std::string, NBTrafficLightDefinition * > & | getPrograms (const std::string &id) const |
Returns all programs for the given tl-id. More... | |
bool | insert (NBTrafficLightDefinition *logic, bool forceInsert=false) |
Adds a logic definition to the dictionary. More... | |
NBTrafficLightLogicCont () | |
Constructor. More... | |
void | remapRemoved (NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing) |
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions. More... | |
bool | removeFully (const std::string id) |
Removes a logic definition (and all programs) from the dictionary. More... | |
bool | removeProgram (const std::string id, const std::string programID, bool del=true) |
Removes a program of a logic definition from the dictionary. More... | |
void | replaceRemoved (NBEdge *removed, int removedLane, NBEdge *by, int byLane) |
Replaces occurences of the removed edge/lane in all definitions by the given edge. More... | |
void | setTLControllingInformation (const NBEdgeCont &ec, const NBNodeCont &nc) |
Informs the edges about being controlled by a tls. More... | |
~NBTrafficLightLogicCont () | |
Destructor. More... | |
Private Types | |
typedef std::vector< NBTrafficLightDefinition * > | Definitions |
typedef std::map< std::string, Program2Def > | Id2Defs |
typedef std::map< std::string, Program2Logic > | Id2Logics |
typedef std::vector< NBTrafficLightLogic * > | Logics |
typedef std::map< std::string, NBTrafficLightDefinition * > | Program2Def |
typedef std::map< std::string, NBTrafficLightLogic * > | Program2Logic |
Definition of internal the container types. More... | |
Private Member Functions | |
void | clear () |
Destroys all stored definitions and logics. More... | |
Definitions | getDefinitions () const |
Returns a list of all definitions (convenience for easier iteration) More... | |
Private Attributes | |
Id2Logics | myComputed |
The container for previously computed tl-logics. More... | |
Id2Defs | myDefinitions |
The container for tl-ids to their definitions. More... | |
std::set< NBTrafficLightDefinition * > | myExtracted |
The container for extracted definitions. More... | |
std::set< std::string > | myHalfOffsetTLS |
List of tls which shall have an offset of T/2. More... | |
std::set< std::string > | myQuarterOffsetTLS |
List of tls which shall have an offset of T/2. More... | |
Static Private Attributes | |
static const Program2Def | EmptyDefinitions = NBTrafficLightLogicCont::Program2Def() |
A container for traffic light definitions and built programs.
This container class holds definitions of traffic light logics during the loading of the network. After all information has been loaded, these definitions are used to build the traffic light logics.
The built traffic light logics are kept stored within this container during their building and written to the network file at the end.
Definition at line 65 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 225 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 223 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 221 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 224 of file NBTrafficLightLogicCont.h.
|
private |
Definition at line 222 of file NBTrafficLightLogicCont.h.
|
private |
Definition of internal the container types.
Definition at line 220 of file NBTrafficLightLogicCont.h.
NBTrafficLightLogicCont::NBTrafficLightLogicCont | ( | ) |
Constructor.
Definition at line 55 of file NBTrafficLightLogicCont.cpp.
NBTrafficLightLogicCont::~NBTrafficLightLogicCont | ( | ) |
void NBTrafficLightLogicCont::applyOptions | ( | OptionsCont & | oc | ) |
Initialises the storage by applying given options.
Options, mainly setting offsets, are parsed and the according internal variables are set.
[in] | oc | The options container to read options from |
Definition at line 64 of file NBTrafficLightLogicCont.cpp.
References OptionsCont::getStringVector(), OptionsCont::isSet(), and myHalfOffsetTLS.
Referenced by NBNetBuilder::applyOptions().
|
private |
Destroys all stored definitions and logics.
Definition at line 199 of file NBTrafficLightLogicCont.cpp.
References getComputed(), getDefinitions(), myComputed, myDefinitions, and myExtracted.
Referenced by ~NBTrafficLightLogicCont().
std::pair< int, int > NBTrafficLightLogicCont::computeLogics | ( | OptionsCont & | oc | ) |
Computes the traffic light logics using the stored definitions and stores the results.
Goes through all stored definitions and calls "NBTrafficLightDefinition::compute" for each. Stores the result using "insert".
[in] | oc | Options used during the computation |
Definition at line 148 of file NBTrafficLightLogicCont.cpp.
References computeSingleLogic(), getComputed(), getDefinitions(), and myComputed.
Referenced by NBNetBuilder::compute(), NBNetBuilder::computeSingleNode(), and getNumExtracted().
bool NBTrafficLightLogicCont::computeSingleLogic | ( | OptionsCont & | oc, |
NBTrafficLightDefinition * | def | ||
) |
Computes a specific traffic light logic (using by NETEDIT)
[in] | oc | Options used during the computation |
Definition at line 168 of file NBTrafficLightLogicCont.cpp.
References NBTrafficLightDefinition::compute(), NBTrafficLightLogic::getDuration(), Named::getID(), NBTrafficLightDefinition::getNodes(), NBTrafficLightDefinition::getProgramID(), myComputed, myHalfOffsetTLS, myQuarterOffsetTLS, NBTrafficLightLogic::setOffset(), and WRITE_WARNING.
Referenced by GNENet::computeJunction(), computeLogics(), and getNumExtracted().
void NBTrafficLightLogicCont::extract | ( | NBTrafficLightDefinition * | definition | ) |
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * deletion (used by NETEDIT)
Definition at line 141 of file NBTrafficLightLogicCont.cpp.
References Named::getID(), NBTrafficLightDefinition::getProgramID(), myExtracted, and removeProgram().
Referenced by NBNodeCont::discardTrafficLights(), and GNEJunction::removeTrafficLight().
NBTrafficLightLogicCont::Logics NBTrafficLightLogicCont::getComputed | ( | ) | const |
Returns a list of all computed logics.
Definition at line 303 of file NBTrafficLightLogicCont.cpp.
References myComputed.
Referenced by clear(), computeLogics(), getNumExtracted(), and NWWriter_SUMO::writeTrafficLights().
NBTrafficLightDefinition * NBTrafficLightLogicCont::getDefinition | ( | const std::string & | id, |
const std::string & | programID | ||
) | const |
Returns the named definition.
[in] | id | The id of the definition to return |
[in] | programID | The id of the program to return |
Definition at line 238 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by getNumExtracted(), and NIXMLTrafficLightsHandler::initTrafficLightLogic().
|
private |
Returns a list of all definitions (convenience for easier iteration)
Definition at line 316 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by clear(), computeLogics(), remapRemoved(), replaceRemoved(), and setTLControllingInformation().
NBTrafficLightLogic * NBTrafficLightLogicCont::getLogic | ( | const std::string & | id, |
const std::string & | programID | ||
) | const |
Returns the computed logic for the given name.
[in] | id | The id of the logic to return |
[in] | programID | The id of the program to return |
Definition at line 262 of file NBTrafficLightLogicCont.cpp.
References myComputed.
Referenced by getNumExtracted(), and GNETLSEditorFrame::onCmdDefSwitch().
|
inline |
return the number of extracted traffic light definitions
Definition at line 127 of file NBTrafficLightLogicCont.h.
References computeLogics(), computeSingleLogic(), getComputed(), getDefinition(), getLogic(), getPrograms(), myExtracted, remapRemoved(), replaceRemoved(), and setTLControllingInformation().
Referenced by NILoader::load().
const NBTrafficLightLogicCont::Program2Def & NBTrafficLightLogicCont::getPrograms | ( | const std::string & | id | ) | const |
Returns all programs for the given tl-id.
[in] | id | The tl-id for which to return all programs |
Definition at line 251 of file NBTrafficLightLogicCont.cpp.
References EmptyDefinitions, and myDefinitions.
Referenced by NIImporter_SUMO::_loadNetwork(), NIXMLTrafficLightsHandler::addTlConnection(), getNumExtracted(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NIXMLNodesHandler::processTrafficLightDefinitions(), NIXMLTrafficLightsHandler::removeTlConnection(), and GNEJunction::setAttribute().
bool NBTrafficLightLogicCont::insert | ( | NBTrafficLightDefinition * | logic, |
bool | forceInsert = false |
||
) |
Adds a logic definition to the dictionary.
"true" is returned if the logic is accepted - no logic with the same name and programID exists within this container.
[in] | logic | The logic to add |
[in] | forceInsert | If true, rename the program to make insertion succeed |
Definition at line 81 of file NBTrafficLightLogicCont.cpp.
References IDSupplier::avoid(), Named::getID(), IDSupplier::getNext(), NBTrafficLightDefinition::getProgramID(), myDefinitions, myExtracted, and NBTrafficLightDefinition::setProgramID().
Referenced by GNEJunction::addTrafficLight(), NIVisumTL::build(), NGNode::buildNBNode(), NIVissimTL::dict_SetSignals(), NBNodeCont::guessTLs(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NIImporter_OpenStreetMap::insertNodeChecking(), NBNode::invalidateTLS(), NBNodeCont::joinNodeClusters(), NBNodeCont::joinTLS(), NIImporter_OpenDrive::loadNetwork(), NIImporter_SUMO::myEndElement(), NIXMLNodesHandler::processTrafficLightDefinitions(), NIImporter_DlrNavteq::TrafficlightsHandler::report(), and NBNodeCont::setAsTLControlled().
void NBTrafficLightLogicCont::remapRemoved | ( | NBEdge * | removed, |
const EdgeVector & | incoming, | ||
const EdgeVector & | outgoing | ||
) |
Replaces occurences of the removed edge in incoming/outgoing edges of all definitions.
[in] | removed | The removed edge |
[in] | incoming | The edges to use instead if an incoming edge was removed |
[in] | outgoing | The edges to use instead if an outgoing edge was removed |
Definition at line 218 of file NBTrafficLightLogicCont.cpp.
References getDefinitions().
Referenced by getNumExtracted(), and NBNode::remapRemoved().
bool NBTrafficLightLogicCont::removeFully | ( | const std::string | id | ) |
Removes a logic definition (and all programs) from the dictionary.
"true" is returned if the logic existed in the dictionary, otherwise "false".
[in] | id | The id of the logic to remove |
Definition at line 105 of file NBTrafficLightLogicCont.cpp.
References myComputed, and myDefinitions.
Referenced by NBNodeCont::guessTLs(), NBNode::invalidateTLS(), NBNodeCont::joinTLS(), and NIXMLNodesHandler::processNodeType().
bool NBTrafficLightLogicCont::removeProgram | ( | const std::string | id, |
const std::string | programID, | ||
bool | del = true |
||
) |
Removes a program of a logic definition from the dictionary.
"true" is returned if the program existed in the dictionary, otherwise "false".
[in] | id | The id of the logic |
[in] | programID | The id of the program to remove |
[in] | del | Whether the definition shall be deleted |
Definition at line 127 of file NBTrafficLightLogicCont.cpp.
References myDefinitions.
Referenced by extract(), and NIXMLTrafficLightsHandler::initTrafficLightLogic().
void NBTrafficLightLogicCont::replaceRemoved | ( | NBEdge * | removed, |
int | removedLane, | ||
NBEdge * | by, | ||
int | byLane | ||
) |
Replaces occurences of the removed edge/lane in all definitions by the given edge.
[in] | removed | The removed edge |
[in] | removed | The removed lane |
[in] | by | The edge to use instead |
[in] | byLane | The lane to use instead |
Definition at line 228 of file NBTrafficLightLogicCont.cpp.
References getDefinitions().
Referenced by getNumExtracted(), NBEdgeCont::joinSameNodeConnectingEdges(), and NBNodeCont::removeUnwishedNodes().
void NBTrafficLightLogicCont::setTLControllingInformation | ( | const NBEdgeCont & | ec, |
const NBNodeCont & | nc | ||
) |
Informs the edges about being controlled by a tls.
Goes through all definition, calling eachs "setParticipantsInformation" method. Goes through all definition, calling eachs "setTLControllingInformation" method.
[in] | ec | The ede control to set information into |
Definition at line 276 of file NBTrafficLightLogicCont.cpp.
References NBNodeCont::begin(), NBEdgeCont::clearControllingTLInformation(), NBNodeCont::end(), getDefinitions(), Named::getID(), NBNode::getType(), NODETYPE_RAIL_CROSSING, NODETYPE_RAIL_SIGNAL, NBNode::removeTrafficLight(), NBNode::setCrossingTLIndices(), NBOwnTLDef::setParticipantsInformation(), and TLTYPE_STATIC.
Referenced by NBNetBuilder::compute(), NBNetBuilder::computeSingleNode(), and getNumExtracted().
|
staticprivate |
Definition at line 242 of file NBTrafficLightLogicCont.h.
Referenced by getPrograms().
|
private |
The container for previously computed tl-logics.
Definition at line 228 of file NBTrafficLightLogicCont.h.
Referenced by clear(), computeLogics(), computeSingleLogic(), getComputed(), getLogic(), and removeFully().
|
private |
The container for tl-ids to their definitions.
Definition at line 231 of file NBTrafficLightLogicCont.h.
Referenced by clear(), getDefinition(), getDefinitions(), getPrograms(), insert(), removeFully(), and removeProgram().
|
private |
The container for extracted definitions.
Definition at line 234 of file NBTrafficLightLogicCont.h.
Referenced by clear(), extract(), getNumExtracted(), and insert().
|
private |
List of tls which shall have an offset of T/2.
Definition at line 237 of file NBTrafficLightLogicCont.h.
Referenced by applyOptions(), and computeSingleLogic().
|
private |
List of tls which shall have an offset of T/2.
Definition at line 240 of file NBTrafficLightLogicCont.h.
Referenced by computeSingleLogic().