33 #include <xercesc/sax/HandlerBase.hpp>
34 #include <xercesc/sax/AttributeList.hpp>
35 #include <xercesc/sax/SAXParseException.hpp>
36 #include <xercesc/sax/SAXException.hpp>
54 #ifdef CHECK_MEMORY_LEAKS
56 #endif // CHECK_MEMORY_LEAKS
126 WRITE_ERROR(
"Definition of tlLogic '" + currentTL->
getID() +
"' was not finished.");
139 WRITE_ERROR(
"Unknown traffic light type '" + typeS +
"' for tlLogic '" +
id +
"'.");
148 if (loadedDef == 0) {
157 WRITE_ERROR(
"Cannot load traffic light program for unknown id '" +
id +
"', programID '" + programID +
"'.");
165 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
171 for (std::vector<NBNode*>::iterator it = nodes.begin(); it != nodes.end(); it++) {
172 (*it)->removeTrafficLight(newDef);
202 const std::vector<NBEdge::Connection>& connections = from->
getConnections();
203 std::vector<NBEdge::Connection>::const_iterator con_it;
204 con_it = find_if(connections.begin(), connections.end(),
206 if (con_it == connections.end()) {
208 " fromLane=" +
toString(fromLane) +
" toLane=" +
toString(toLane) +
" not found");
227 if (programs.size() > 0) {
228 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
229 for (it = programs.begin(); it != programs.end(); it++) {
235 + tlID +
"' (program '" + it->first +
"')");
239 WRITE_ERROR(
"The traffic light '" + tlID +
"' is not known.");
250 if (programs.size() > 0) {
266 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
267 for (it = programs.begin(); it != programs.end(); it++) {
273 + tlID +
"' (program '" + it->first +
"')");
283 std::string edgeID = attrs.
get<std::string>(attr, 0, ok);
286 WRITE_ERROR(
"Unknown edge '" + edgeID +
"' given in connection.");
296 int laneIndex = attrs.
get<
int>(attr, 0, ok);
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
bool removeProgram(const std::string id, const std::string programID, bool del=true)
Removes a program of a logic definition from the dictionary.
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
NBEdge * toEdge
The edge the connections yields in.
A loaded (complete) traffic light logic.
NBEdgeCont & myEdgeCont
The edge container for retrieving edges.
A container for traffic light definitions and built programs.
NBEdge * retrieveEdge(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, bool &ok)
parses and edge id an returns an existing edge
const std::string & getProgramID() const
Returns the ProgramID.
The representation of a single edge during network building.
The base class for traffic light logic definitions.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::vector< NBNode * > & getControlledNodes() const
NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
SAX-handler base for SUMO-files.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static OptionsCont & getOptions()
Retrieves the options.
NBTrafficLightDefinition * getDefinition(const std::string &id, const std::string &programID) const
Returns the named definition.
NBTrafficLightLogicCont & myTLLCont
The traffic light container to fill.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const std::string & getID() const
Returns the id.
int retrieveLaneIndex(const SUMOSAXAttributes &attrs, SumoXMLAttr attr, NBEdge *edge, bool &ok)
parses a lane index and verifies its correctness
Encapsulated SAX-Attributes.
std::string tlID
The id of the traffic light that controls this connection.
void addTlConnection(const SUMOSAXAttributes &attrs)
reads and adds tl-controlled connection
static StringBijection< TrafficLightType > TrafficLightTypes
int fromLane
The lane the connections starts at.
unsigned int getNumLanes() const
Returns the number of lanes.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
Storage for edges, including some functionality operating on multiple edges.
void removeTlConnection(const SUMOSAXAttributes &attrs)
reads and removes tl-controlled connection
NBTrafficLightLogic * getLogic()
Returns the internal logic.
static const std::string DefaultProgramID
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
bool myResetPhases
whether phases of a previously loaded traffic light must be reset
T get(const std::string &str)
~NIXMLTrafficLightsHandler()
Destructor.
void myEndElement(int element)
Called when a closing tag occurs.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
unsigned int tlLinkNo
The index of this connection within the controlling traffic light.
NIXMLTrafficLightsHandler(NBTrafficLightLogicCont &tlCont, NBEdgeCont &ec)
Constructor.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
A traffic light logics which must be computed (only nodes/edges are given)
#define WRITE_MESSAGE(msg)
const std::vector< Connection > & getConnections() const
Returns the connections.
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex)
Adds a connection and immediately informs the edges.