SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RONetHandler Class Reference

The handler that parses a SUMO-network for its usage in a router. More...

#include <RONetHandler.h>

Inheritance diagram for RONetHandler:
SUMOSAXHandler GenericSAXHandler DefaultHandler

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
void registerParent (const int tag, GenericSAXHandler *handler)
 Assigning a parent handler which is enabled when the specified tag is closed.
 RONetHandler (RONet &net, ROAbstractEdgeBuilder &eb)
 Constructor.
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.
virtual ~RONetHandler ()
 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.
virtual void myEndElement (int element)
 Callback method for a closing tag to implement by derived classes.
inherited from GenericSAXHandler
virtual void myStartElement (int element, const SUMOSAXAttributes &attrs)
 Called on the opening of a tag;.
called from myStartElement
void parseEdge (const SUMOSAXAttributes &attrs)
 Parses and builds an edge.
virtual void parseLane (const SUMOSAXAttributes &attrs)
 Parses and builds a lane.
void parseJunction (const SUMOSAXAttributes &attrs)
 Parses a junction's position.
void parseConnectingEdge (const SUMOSAXAttributes &attrs)
void parseConnectedEdge (const SUMOSAXAttributes &attrs)
void parseConnection (const SUMOSAXAttributes &attrs)
void parseDistrict (const SUMOSAXAttributes &attrs)
void parseDistrictEdge (const SUMOSAXAttributes &attrs, bool isSource)

Protected Attributes

ROEdgemyCurrentEdge
 The currently built edge.
std::string myCurrentName
 The name of the edge/node that is currently processed.
ROAbstractEdgeBuildermyEdgeBuilder
 The object used to build of edges of the desired type.
bool myHaveWarnedAboutDeprecatedDistrict
bool myHaveWarnedAboutDeprecatedDSink
bool myHaveWarnedAboutDeprecatedDSource
RONetmyNet
 The net to store the information into.
bool myProcess
 An indicator whether the next edge shall be read (internal edges are not read by now)

Private Member Functions

RONetHandleroperator= (const RONetHandler &src)
 Invalidated assignment operator.
 RONetHandler (const RONetHandler &src)
 Invalidated copy constructor.

Detailed Description

The handler that parses a SUMO-network for its usage in a router.

SAX2-Handler for SUMO-network loading. As this class is used for both the dua- and the jtrrouter, a reference to the edge builder is given.

Definition at line 60 of file RONetHandler.h.

Constructor & Destructor Documentation

RONetHandler::RONetHandler ( RONet net,
ROAbstractEdgeBuilder eb 
)

Constructor.

Parameters
[in]netThe network instance to fill
[in]ebThe abstract edge builder to use

Definition at line 57 of file RONetHandler.cpp.

RONetHandler::~RONetHandler ( )
virtual

Destructor.

Definition at line 65 of file RONetHandler.cpp.

RONetHandler::RONetHandler ( const RONetHandler src)
private

Invalidated copy constructor.

Member Function Documentation

std::string GenericSAXHandler::buildErrorMessage ( const SAXParseException &  exception)
protectedinherited

Builds an error message.

The error message includes the file name and the line/column information as supported by the given SAXParseException

Parameters
[in]exceptionThe name of the currently processed file
Returns
A string describing the given exception

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.

Todo:

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.

Todo:

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.

Parameters
[in]exceptionThe occured exception to process
Exceptions
ProcessErrorOn 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.

Exceptions
ProcessErrorOn any call
Parameters
[in]exceptionThe occured exception to process

Definition at line 218 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage().

void GenericSAXHandler::myCharacters ( int  element,
const std::string &  chars 
)
protectedvirtualinherited

Callback method for characters to implement by derived classes.

Called by "endElement" (see there).

Parameters
[in]elementThe opened element, given as a int
[in]charsThe 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 GenericSAXHandler::myEndElement ( int  element)
protectedvirtualinherited
void RONetHandler::myStartElement ( int  element,
const SUMOSAXAttributes attrs 
)
protectedvirtual
RONetHandler& RONetHandler::operator= ( const RONetHandler src)
private

Invalidated assignment operator.

void RONetHandler::parseConnectedEdge ( const SUMOSAXAttributes attrs)
protected

(deprecated) Parses an approached edge and lets the approaching know about the connection

Called on the occurence of a "succlane" element, this method retrieves the id of the approachable edge. If this edge is known and valid, the approaching edge is informed about it (by calling "ROEdge::addFollower").

Parameters
[in]attrsThe attributes (of the "succlane"-element) to parse
Todo:
No exception?

Definition at line 254 of file RONetHandler.cpp.

References ROEdge::addFollower(), RONet::getEdge(), SUMOSAXAttributes::getStringReporting(), myCurrentEdge, myCurrentName, myNet, SUMO_ATTR_LANE, and WRITE_ERROR.

Referenced by myStartElement().

void RONetHandler::parseConnectingEdge ( const SUMOSAXAttributes attrs)
protected

(deprecated) Begins parsing edges that are approached by an edge

Called on the occurence of a "succ" element, this method retrieves the id of the edge described herein and - using it - the edge itself. Stores the so retrieved edge in "myCurrentEdge". If the given edge is not known, a ProcessError is thrown.

Parameters
[in]attrsThe attributes (of the "succ"-element) to parse
Exceptions
ProcessErrorIf the edge given in cedge is not known

Definition at line 239 of file RONetHandler.cpp.

References RONet::getEdge(), SUMOSAXAttributes::getStringReporting(), myCurrentEdge, myNet, and SUMO_ATTR_EDGE.

Referenced by myStartElement().

void RONetHandler::parseConnection ( const SUMOSAXAttributes attrs)
protected

Parses a connection Called on the occurence of a "connection" element

Parameters
[in]attrsThe attributes (of the "connection"-element) to parse

Definition at line 275 of file RONetHandler.cpp.

References ROEdge::addFollower(), RONet::getEdge(), SUMOSAXAttributes::getStringReporting(), myNet, SUMO_ATTR_DIR, SUMO_ATTR_FROM, and SUMO_ATTR_TO.

Referenced by myStartElement().

void RONetHandler::parseDistrict ( const SUMOSAXAttributes attrs)
protected

Parses a district and creates a pseudo edge for it

Called on the occurence of a "district" element, this method retrieves the id of the district and creates a district type edge with this id.

Parameters
[in]attrsThe attributes (of the "district"-element) to parse
Exceptions
ProcessErrorIf an edge given in district is not known

Definition at line 296 of file RONetHandler.cpp.

References RONet::addEdge(), ROEdge::addFollower(), ROAbstractEdgeBuilder::buildEdge(), ROEdge::ET_DISTRICT, RONet::getEdge(), SUMOSAXAttributes::getString(), SUMOSAXAttributes::getStringReporting(), SUMOSAXAttributes::hasAttribute(), myCurrentEdge, myCurrentName, myEdgeBuilder, myNet, ROEdge::setType(), SUMO_ATTR_EDGES, and SUMO_ATTR_ID.

Referenced by myStartElement().

void RONetHandler::parseDistrictEdge ( const SUMOSAXAttributes attrs,
bool  isSource 
)
protected

Parses a district edge and connects it to the district

Called on the occurence of a "dsource" or "dsink" element, this method retrieves the id of the approachable edge. If this edge is known and valid, the approaching edge is informed about it (by calling "ROEdge::addFollower").

Parameters
[in]attrsThe attributes to parse
[in]isSourcewhether a "dsource or a "dsink" was given
Todo:
No exception?

Definition at line 325 of file RONetHandler.cpp.

References ROEdge::addFollower(), RONet::getEdge(), SUMOSAXAttributes::getStringReporting(), myCurrentName, myNet, SUMO_ATTR_ID, and WRITE_ERROR.

Referenced by myStartElement().

void RONetHandler::parseEdge ( const SUMOSAXAttributes attrs)
protected

Parses and builds an edge.

Parses attributes from an "edge"-element (id, from/to-nodes, function, etc.). If the given nodes are not yet known, they are added to the network. Uses the internal edge builder to build the edge and adds the edge to the network.

Parameters
[in]attrsThe attributes (of the "edge"-element) to parse
Todo:

The edge is "built" first, then the nodes are added; should be done while constructing, probably a legacy issue

No exception?

Definition at line 126 of file RONetHandler.cpp.

References RONet::addEdge(), RONet::addNode(), ROAbstractEdgeBuilder::buildEdge(), ROEdge::ET_NORMAL, ROEdge::ET_SINK, ROEdge::ET_SOURCE, RONet::getNode(), SUMOSAXAttributes::getStringReporting(), SUMOSAXAttributes::hasAttribute(), myCurrentEdge, myCurrentName, myEdgeBuilder, myNet, myProcess, ROEdge::setType(), SUMO_ATTR_FROM, SUMO_ATTR_FUNCTION, SUMO_ATTR_ID, SUMO_ATTR_TO, and WRITE_ERROR.

Referenced by myStartElement().

void RONetHandler::parseJunction ( const SUMOSAXAttributes attrs)
protected

Parses a junction's position.

Parses the position of the junction. Sets it to the junction.

Parameters
[in]attrsThe attributes (of the "lane"-element) to parse
Todo:

In fact, the junction should be built given its position.

No exception?

Definition at line 215 of file RONetHandler.cpp.

References RONet::addNode(), RONet::getNode(), SUMOSAXAttributes::getStringReporting(), SUMOSAXAttributes::getSUMORealReporting(), myNet, RONode::setPosition(), SUMO_ATTR_ID, SUMO_ATTR_X, SUMO_ATTR_Y, and SUMOReal.

Referenced by myStartElement().

void RONetHandler::parseLane ( const SUMOSAXAttributes attrs)
protectedvirtual

Parses and builds a lane.

Parses attributes from an "lane"-element (speed, length, vehicle classes, etc.). Builds a ROLane using these attributes (if they are valid) and adds it to the edge.

Parameters
[in]attrsThe attributes (of the "lane"-element) to parse
Todo:
No exception?

Definition at line 180 of file RONetHandler.cpp.

References ROEdge::addLane(), SUMOSAXAttributes::getOptStringReporting(), SUMOSAXAttributes::getStringReporting(), SUMOSAXAttributes::getSUMORealReporting(), SUMOSAXAttributes::hasAttribute(), myCurrentEdge, myNet, parseVehicleClasses(), RONet::setRestrictionFound(), SUMO_ATTR_ALLOW, SUMO_ATTR_DISALLOW, SUMO_ATTR_ID, SUMO_ATTR_LENGTH, SUMO_ATTR_MAXSPEED__DEPRECATED, SUMO_ATTR_SPEED, SUMOReal, and SVCFreeForAll.

Referenced by myStartElement().

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 GenericSAXHandler::setFileName ( const std::string &  name)
inherited
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.

Todo:

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.

Parameters
[in]exceptionThe occured exception to process

Definition at line 206 of file GenericSAXHandler.cpp.

References GenericSAXHandler::buildErrorMessage(), and WRITE_WARNING.

Field Documentation

ROEdge* RONetHandler::myCurrentEdge
protected

The currently built edge.

Definition at line 198 of file RONetHandler.h.

Referenced by parseConnectedEdge(), parseConnectingEdge(), parseDistrict(), parseEdge(), and parseLane().

std::string RONetHandler::myCurrentName
protected

The name of the edge/node that is currently processed.

Definition at line 195 of file RONetHandler.h.

Referenced by parseConnectedEdge(), parseDistrict(), parseDistrictEdge(), and parseEdge().

ROAbstractEdgeBuilder& RONetHandler::myEdgeBuilder
protected

The object used to build of edges of the desired type.

Definition at line 204 of file RONetHandler.h.

Referenced by parseDistrict(), and parseEdge().

bool RONetHandler::myHaveWarnedAboutDeprecatedDistrict
protected

Definition at line 206 of file RONetHandler.h.

Referenced by myStartElement().

bool RONetHandler::myHaveWarnedAboutDeprecatedDSink
protected

Definition at line 206 of file RONetHandler.h.

Referenced by myStartElement().

bool RONetHandler::myHaveWarnedAboutDeprecatedDSource
protected

Definition at line 206 of file RONetHandler.h.

Referenced by myStartElement().

RONet& RONetHandler::myNet
protected

The net to store the information into.

Definition at line 192 of file RONetHandler.h.

Referenced by parseConnectedEdge(), parseConnectingEdge(), parseConnection(), parseDistrict(), parseDistrictEdge(), parseEdge(), parseJunction(), and parseLane().

bool RONetHandler::myProcess
protected

An indicator whether the next edge shall be read (internal edges are not read by now)

Definition at line 201 of file RONetHandler.h.

Referenced by myStartElement(), and parseEdge().


The documentation for this class was generated from the following files: