SUMO - Simulation of Urban MObility
|
Importer for edge connections stored in XML. More...
#include <NIXMLTrafficLightsHandler.h>
Public Member Functions | |
void | characters (const XMLCh *const chars, const XERCES3_SIZE_t length) |
The inherited method called when characters occured. | |
void | endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname) |
The inherited method called when a tag is being closed. | |
const std::string & | getFileName () const |
returns the current file name | |
NIXMLTrafficLightsHandler (NBTrafficLightLogicCont &tlCont, NBEdgeCont &ec) | |
Constructor. | |
void | registerParent (const int tag, GenericSAXHandler *handler) |
Assigning a parent handler which is enabled when the specified tag is closed. | |
void | setFileName (const std::string &name) |
Sets the current file name. | |
void | startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs) |
The inherited method called when a new tag opens. | |
~NIXMLTrafficLightsHandler () | |
Destructor. | |
SAX ErrorHandler callbacks | |
void | warning (const SAXParseException &exception) |
Handler for XML-warnings. | |
void | error (const SAXParseException &exception) |
Handler for XML-errors. | |
void | fatalError (const SAXParseException &exception) |
Handler for XML-errors. | |
Protected Member Functions | |
std::string | buildErrorMessage (const SAXParseException &exception) |
Builds an error message. | |
virtual void | myCharacters (int element, const std::string &chars) |
Callback method for characters to implement by derived classes. | |
inherited from GenericSAXHandler | |
void | myStartElement (int element, const SUMOSAXAttributes &attrs) |
Called on the opening of a tag;. | |
void | myEndElement (int element) |
Called when a closing tag occurs. | |
Private Member Functions | |
void | addTlConnection (const SUMOSAXAttributes &attrs) |
reads and adds tl-controlled connection | |
NBLoadedSUMOTLDef * | initTrafficLightLogic (const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL) |
NIXMLTrafficLightsHandler (const NIXMLTrafficLightsHandler &s) | |
invalidated copy constructor | |
NIXMLTrafficLightsHandler & | operator= (const NIXMLTrafficLightsHandler &s) |
invalidated assignment operator | |
void | removeTlConnection (const SUMOSAXAttributes &attrs) |
reads and removes tl-controlled connection | |
NBEdge * | retrieveEdge (const SUMOSAXAttributes &attrs, SumoXMLAttr attr, bool &ok) |
parses and edge id an returns an existing edge | |
int | retrieveLaneIndex (const SUMOSAXAttributes &attrs, SumoXMLAttr attr, NBEdge *edge, bool &ok) |
parses a lane index and verifies its correctness | |
Private Attributes | |
NBLoadedSUMOTLDef * | myCurrentTL |
The currently parsed traffic light. | |
NBEdgeCont & | myEdgeCont |
The edge container for retrieving edges. | |
bool | myResetPhases |
whether phases of a previously loaded traffic light must be reset | |
NBTrafficLightLogicCont & | myTLLCont |
The traffic light container to fill. |
Importer for edge connections stored in XML.
This importer parses connections, and prohibitions, and is able to reset connections between edges.
Definition at line 57 of file NIXMLTrafficLightsHandler.h.
NIXMLTrafficLightsHandler::NIXMLTrafficLightsHandler | ( | NBTrafficLightLogicCont & | tlCont, |
NBEdgeCont & | ec | ||
) |
Constructor.
[in] | ec | The traffic light container into which to load logics |
Definition at line 63 of file NIXMLTrafficLightsHandler.cpp.
Destructor.
Definition at line 73 of file NIXMLTrafficLightsHandler.cpp.
NIXMLTrafficLightsHandler::NIXMLTrafficLightsHandler | ( | const NIXMLTrafficLightsHandler & | s | ) | [private] |
invalidated copy constructor
void NIXMLTrafficLightsHandler::addTlConnection | ( | const SUMOSAXAttributes & | attrs | ) | [private] |
reads and adds tl-controlled connection
Definition at line 172 of file NIXMLTrafficLightsHandler.cpp.
References NBLoadedSUMOTLDef::addConnection(), NBEdge::Connection::fromLane, NBEdge::getConnections(), Named::getID(), SUMOSAXAttributes::getOptIntReporting(), SUMOSAXAttributes::getOptStringReporting(), NBTrafficLightLogicCont::getPrograms(), myTLLCont, retrieveEdge(), retrieveLaneIndex(), SUMO_ATTR_FROM, SUMO_ATTR_FROM_LANE, SUMO_ATTR_TLID, SUMO_ATTR_TLLINKINDEX, SUMO_ATTR_TO, SUMO_ATTR_TO_LANE, NBEdge::Connection::tlID, NBEdge::Connection::tlLinkNo, NBEdge::Connection::toEdge, NBEdge::Connection::toLane, toString(), and WRITE_ERROR.
Referenced by myStartElement().
std::string GenericSAXHandler::buildErrorMessage | ( | const SAXParseException & | exception | ) | [protected, inherited] |
Builds an error message.
The error message includes the file name and the line/column information as supported by the given SAXParseException
[in] | exception | The name of the currently processed file |
Definition at line 193 of file GenericSAXHandler.cpp.
References GenericSAXHandler::getFileName().
Referenced by GenericSAXHandler::error(), GenericSAXHandler::fatalError(), and GenericSAXHandler::warning().
void GenericSAXHandler::characters | ( | const XMLCh *const | chars, |
const XERCES3_SIZE_t | length | ||
) | [inherited] |
The inherited method called when characters occured.
The retrieved characters are converted into a string and appended into a private buffer. They are reported as soon as the element ends.
recheck/describe what happens with characters when a new element is opened
describe characters processing in the class' head
Definition at line 176 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myCharactersVector.
void GenericSAXHandler::endElement | ( | const XMLCh *const | uri, |
const XMLCh *const | localname, | ||
const XMLCh *const | qname | ||
) | [inherited] |
The inherited method called when a tag is being closed.
This method calls the user-implemented methods myCharacters with the previously collected and converted characters.
Then, myEndElement is called, supplying it the qname converted to its enum- and string-representations.
recheck/describe encoding of the string-representation
do not generate and report the string-representation
Definition at line 126 of file GenericSAXHandler.cpp.
References GenericSAXHandler::convertTag(), GenericSAXHandler::myCharacters(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myEndElement(), GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, XMLSubSys::setHandler(), SUMO_TAG_INCLUDE, and SUMO_TAG_NOTHING.
void GenericSAXHandler::error | ( | const SAXParseException & | exception | ) | [inherited] |
Handler for XML-errors.
The message is built using buildErrorMessage and thrown within a ProcessError.
[in] | exception | The occured exception to process |
ProcessError | On any call |
Definition at line 212 of file GenericSAXHandler.cpp.
References GenericSAXHandler::buildErrorMessage().
Referenced by NLHandler::getLanesFromIndices().
void GenericSAXHandler::fatalError | ( | const SAXParseException & | exception | ) | [inherited] |
Handler for XML-errors.
The message is built using buildErrorMessage and thrown within a ProcessError.
ProcessError | On any call |
[in] | exception | The occured exception to process |
Definition at line 218 of file GenericSAXHandler.cpp.
References GenericSAXHandler::buildErrorMessage().
const std::string & GenericSAXHandler::getFileName | ( | ) | const [inherited] |
returns the current file name
Definition at line 86 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myFileName.
Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), NLHandler::addInstantE1Detector(), NLHandler::addRouteProbeDetector(), NLHandler::addVTypeProbeDetector(), NLHandler::beginE3Detector(), GenericSAXHandler::buildErrorMessage(), MSRouteLoader::init(), PCNetProjectionLoader::loadIfSet(), NILoader::loadXMLType(), MSTriggeredXMLReader::myInit(), GUISettingsHandler::myStartElement(), RODFDetectorHandler::myStartElement(), NLHandler::myStartElement(), NIImporter_OpenDrive::myStartElement(), RORDGenerator_ODAmounts::RORDGenerator_ODAmounts(), ROTypedXMLRoutesLoader::ROTypedXMLRoutesLoader(), XMLSubSys::runParser(), and GenericSAXHandler::startElement().
NBLoadedSUMOTLDef * NIXMLTrafficLightsHandler::initTrafficLightLogic | ( | const SUMOSAXAttributes & | attrs, |
NBLoadedSUMOTLDef * | currentTL | ||
) | [private] |
begins the reading of a traffic lights logic This differs from NIImporter_SUMO::initTrafficLightLogic insofar as partial definitions (diffs) are allowed in an xml file
Definition at line 123 of file NIXMLTrafficLightsHandler.cpp.
References NBTrafficLightDefinition::DefaultProgramID, NBTrafficLightDefinition::getControlledNodes(), NBTrafficLightLogicCont::getDefinition(), Named::getID(), NBLoadedSUMOTLDef::getLogic(), SUMOSAXAttributes::getOptStringReporting(), SUMOSAXAttributes::getStringReporting(), SUMOSAXAttributes::getSUMORealReporting(), SUMOSAXAttributes::hasAttribute(), NBTrafficLightLogicCont::insert(), myResetPhases, myTLLCont, NBTrafficLightLogicCont::removeProgram(), NBTrafficLightLogic::setOffset(), SUMO_ATTR_ID, SUMO_ATTR_OFFSET, SUMO_ATTR_PROGRAMID, SUMO_ATTR_TYPE, TIME2STEPS, TLTYPE_STATIC, toString(), WRITE_ERROR, and WRITE_WARNING.
Referenced by myStartElement().
void GenericSAXHandler::myCharacters | ( | int | element, |
const std::string & | chars | ||
) | [protected, virtual, inherited] |
Callback method for characters to implement by derived classes.
Called by "endElement" (see there).
[in] | element | The opened element, given as a int |
[in] | chars | The complete embedded character string ProcessError These method may throw a ProcessError if something fails |
Reimplemented in NIImporter_OpenDrive, NIImporter_SUMO, PCNetProjectionLoader, NIImporter_ITSUMO::Handler, PCLoaderXML, RORDLoader_SUMOBase, and ROJTRTurnDefLoader.
Definition at line 228 of file GenericSAXHandler.cpp.
Referenced by GenericSAXHandler::endElement().
void NIXMLTrafficLightsHandler::myEndElement | ( | int | element | ) | [protected, virtual] |
Called when a closing tag occurs.
[in] | element | ID of the currently opened element |
ProcessError | If something fails |
Reimplemented from GenericSAXHandler.
Definition at line 103 of file NIXMLTrafficLightsHandler.cpp.
References Named::getID(), NBTrafficLightDefinition::getProgramID(), NBTrafficLightLogicCont::insert(), myCurrentTL, myTLLCont, SUMO_TAG_TLLOGIC, WRITE_ERROR, and WRITE_MESSAGE.
void NIXMLTrafficLightsHandler::myStartElement | ( | int | element, |
const SUMOSAXAttributes & | attrs | ||
) | [protected, virtual] |
Called on the opening of a tag;.
[in] | element | ID of the currently opened element |
[in] | attrs | Attributes within the currently opened element |
ProcessError | If something fails |
Reimplemented from GenericSAXHandler.
Definition at line 77 of file NIXMLTrafficLightsHandler.cpp.
References NIImporter_SUMO::addPhase(), addTlConnection(), NBLoadedSUMOTLDef::getLogic(), initTrafficLightLogic(), myCurrentTL, myResetPhases, removeTlConnection(), NBTrafficLightLogic::resetPhases(), SUMO_TAG_CONNECTION, SUMO_TAG_DELETE, SUMO_TAG_PHASE, and SUMO_TAG_TLLOGIC.
NIXMLTrafficLightsHandler& NIXMLTrafficLightsHandler::operator= | ( | const NIXMLTrafficLightsHandler & | s | ) | [private] |
invalidated assignment operator
void GenericSAXHandler::registerParent | ( | const int | tag, |
GenericSAXHandler * | handler | ||
) | [inherited] |
Assigning a parent handler which is enabled when the specified tag is closed.
Definition at line 168 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, and XMLSubSys::setHandler().
Referenced by NLTriggerBuilder::parseAndBuildLaneSpeedTrigger(), and NLTriggerBuilder::parseAndBuildRerouter().
void NIXMLTrafficLightsHandler::removeTlConnection | ( | const SUMOSAXAttributes & | attrs | ) | [private] |
reads and removes tl-controlled connection
Definition at line 229 of file NIXMLTrafficLightsHandler.cpp.
References SUMOSAXAttributes::getIntReporting(), NBTrafficLightLogicCont::getPrograms(), SUMOSAXAttributes::getStringReporting(), myTLLCont, NBLoadedSUMOTLDef::removeConnection(), retrieveEdge(), retrieveLaneIndex(), SUMO_ATTR_FROM, SUMO_ATTR_FROM_LANE, SUMO_ATTR_TLID, SUMO_ATTR_TLLINKINDEX, SUMO_ATTR_TO, and SUMO_ATTR_TO_LANE.
Referenced by myStartElement().
NBEdge * NIXMLTrafficLightsHandler::retrieveEdge | ( | const SUMOSAXAttributes & | attrs, |
SumoXMLAttr | attr, | ||
bool & | ok | ||
) | [private] |
parses and edge id an returns an existing edge
Definition at line 265 of file NIXMLTrafficLightsHandler.cpp.
References SUMOSAXAttributes::getStringReporting(), myEdgeCont, NBEdgeCont::retrieve(), and WRITE_ERROR.
Referenced by addTlConnection(), and removeTlConnection().
int NIXMLTrafficLightsHandler::retrieveLaneIndex | ( | const SUMOSAXAttributes & | attrs, |
SumoXMLAttr | attr, | ||
NBEdge * | edge, | ||
bool & | ok | ||
) | [private] |
parses a lane index and verifies its correctness
Definition at line 278 of file NIXMLTrafficLightsHandler.cpp.
References Named::getID(), SUMOSAXAttributes::getIntReporting(), NBEdge::getNumLanes(), toString(), and WRITE_ERROR.
Referenced by addTlConnection(), and removeTlConnection().
void GenericSAXHandler::setFileName | ( | const std::string & | name | ) | [inherited] |
Sets the current file name.
[in] | name | The name of the currently processed file |
Definition at line 80 of file GenericSAXHandler.cpp.
References GenericSAXHandler::myFileName.
Referenced by NIImporter_SUMO::_loadNetwork(), GUISettingsHandler::GUISettingsHandler(), AGActivityGen::importInfoCity(), NIImporter_OpenStreetMap::load(), PCNetProjectionLoader::loadIfSet(), loadNet(), ROLoader::loadNet(), NIImporter_ITSUMO::loadNetwork(), NIImporter_MATSim::loadNetwork(), NIImporter_OpenDrive::loadNetwork(), NILoader::loadXMLType(), and XMLSubSys::runParser().
void GenericSAXHandler::startElement | ( | const XMLCh *const | uri, |
const XMLCh *const | localname, | ||
const XMLCh *const | qname, | ||
const Attributes & | attrs | ||
) | [inherited] |
The inherited method called when a new tag opens.
The method parses the supplied XMLCh*-qname using the internal name/enum-map to obtain the enum representation of the attribute name.
Then, "myStartElement" is called supplying the enumeration value, the string-representation of the name and the attributes.
recheck/describe encoding of the string-representation
do not generate and report the string-representation
Definition at line 105 of file GenericSAXHandler.cpp.
References GenericSAXHandler::convertTag(), FileHelpers::getConfigurationRelative(), GenericSAXHandler::getFileName(), SUMOSAXAttributesImpl_Xerces::getString(), FileHelpers::isAbsolute(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myPredefinedTags, GenericSAXHandler::myPredefinedTagsMML, GenericSAXHandler::myStartElement(), XMLSubSys::runParser(), SUMO_ATTR_HREF, and SUMO_TAG_INCLUDE.
void GenericSAXHandler::warning | ( | const SAXParseException & | exception | ) | [inherited] |
Handler for XML-warnings.
The message is built using buildErrorMessage and reported to the warning-instance of the MsgHandler.
[in] | exception | The occured exception to process |
Definition at line 206 of file GenericSAXHandler.cpp.
References GenericSAXHandler::buildErrorMessage(), and WRITE_WARNING.
The currently parsed traffic light.
Definition at line 102 of file NIXMLTrafficLightsHandler.h.
Referenced by myEndElement(), and myStartElement().
NBEdgeCont& NIXMLTrafficLightsHandler::myEdgeCont [private] |
The edge container for retrieving edges.
Definition at line 99 of file NIXMLTrafficLightsHandler.h.
Referenced by retrieveEdge().
bool NIXMLTrafficLightsHandler::myResetPhases [private] |
whether phases of a previously loaded traffic light must be reset
Definition at line 105 of file NIXMLTrafficLightsHandler.h.
Referenced by initTrafficLightLogic(), and myStartElement().
The traffic light container to fill.
Definition at line 96 of file NIXMLTrafficLightsHandler.h.
Referenced by addTlConnection(), initTrafficLightLogic(), myEndElement(), and removeTlConnection().