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

Public Member Functions

void characters (const XMLCh *const chars, const XERCES3_SIZE_t length)
 The inherited method called when characters occured. More...
 
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 The inherited method called when a tag is being closed. More...
 
const std::string & getFileName () const
 returns the current file name More...
 
void registerParent (const int tag, GenericSAXHandler *handler)
 Assigning a parent handler which is enabled when the specified tag is closed. More...
 
 RONetHandler (RONet &net, ROAbstractEdgeBuilder &eb)
 Constructor. More...
 
void setFileName (const std::string &name)
 Sets the current file name. More...
 
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 The inherited method called when a new tag opens. More...
 
virtual ~RONetHandler ()
 Destructor. More...
 
SAX ErrorHandler callbacks
void warning (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-warnings. More...
 
void error (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-errors. More...
 
void fatalError (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Handler for XML-errors. More...
 

Protected Member Functions

std::string buildErrorMessage (const XERCES_CPP_NAMESPACE::SAXParseException &exception)
 Builds an error message. More...
 
virtual void myCharacters (int element, const std::string &chars)
 Callback method for characters to implement by derived classes. More...
 
virtual void myEndElement (int element)
 Callback method for a closing tag to implement by derived classes. More...
 
inherited from GenericSAXHandler
virtual void myStartElement (int element, const SUMOSAXAttributes &attrs)
 Called on the opening of a tag;. More...
 
called from myStartElement
void parseEdge (const SUMOSAXAttributes &attrs)
 Parses and builds an edge. More...
 
virtual void parseLane (const SUMOSAXAttributes &attrs)
 Parses and builds a lane. More...
 
void parseJunction (const SUMOSAXAttributes &attrs)
 Parses a junction's position. More...
 
void parseConnection (const SUMOSAXAttributes &attrs)
 
void parseDistrict (const SUMOSAXAttributes &attrs)
 
void parseDistrictEdge (const SUMOSAXAttributes &attrs, bool isSource)
 

Protected Attributes

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

Private Member Functions

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

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 64 of file RONetHandler.cpp.

RONetHandler::RONetHandler ( const RONetHandler src)
private

Invalidated copy constructor.

Member Function Documentation

std::string GenericSAXHandler::buildErrorMessage ( const XERCES_CPP_NAMESPACE::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 TplConvert::_2str(), and 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 TplConvert::_2str(), 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 XERCES_CPP_NAMESPACE::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().

void GenericSAXHandler::fatalError ( const XERCES_CPP_NAMESPACE::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_ITSUMO::Handler.

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

Called on the opening of a tag;.

Parameters
[in]elementID of the currently opened element
[in]attrsAttributes within the currently opened element
Exceptions
ProcessErrorIf something fails
See Also
GenericSAXHandler::myStartElement

Reimplemented from GenericSAXHandler.

Definition at line 68 of file RONetHandler.cpp.

References myProcess, parseConnection(), parseDistrict(), parseDistrictEdge(), parseEdge(), parseJunction(), parseLane(), SUMO_TAG_CONNECTION, SUMO_TAG_EDGE, SUMO_TAG_JUNCTION, SUMO_TAG_LANE, SUMO_TAG_TAZ, SUMO_TAG_TAZSINK, and SUMO_TAG_TAZSOURCE.

RONetHandler& RONetHandler::operator= ( const RONetHandler src)
private

Invalidated assignment operator.

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 216 of file RONetHandler.cpp.

References ROEdge::addFollower(), SUMOSAXAttributes::get(), RONet::getEdge(), 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 237 of file RONetHandler.cpp.

References RONet::addEdge(), ROEdge::addFollower(), ROAbstractEdgeBuilder::buildEdge(), ROEdge::ET_DISTRICT, SUMOSAXAttributes::get(), RONet::getEdge(), SUMOSAXAttributes::getStringVector(), 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 266 of file RONetHandler.cpp.

References ROEdge::addFollower(), SUMOSAXAttributes::get(), RONet::getEdge(), 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 104 of file RONetHandler.cpp.

References RONet::addEdge(), RONet::addNode(), ROAbstractEdgeBuilder::buildEdge(), ROEdge::ET_NORMAL, ROEdge::ET_SINK, ROEdge::ET_SOURCE, SUMOSAXAttributes::get(), RONet::getNode(), SUMOSAXAttributes::hasAttribute(), myCurrentEdge, myCurrentName, myEdgeBuilder, myNet, myProcess, ROEdge::setType(), SUMO_ATTR_FROM, SUMO_ATTR_FUNCTION, SUMO_ATTR_ID, SUMO_ATTR_PRIORITY, 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 192 of file RONetHandler.cpp.

References RONet::addNode(), SUMOSAXAttributes::get(), RONet::getNode(), 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 159 of file RONetHandler.cpp.

References ROEdge::addLane(), SUMOSAXAttributes::get(), SUMOSAXAttributes::getOpt(), myCurrentEdge, myNet, parseVehicleClasses(), RONet::setRestrictionFound(), SUMO_ATTR_ALLOW, SUMO_ATTR_DISALLOW, SUMO_ATTR_ID, SUMO_ATTR_LENGTH, SUMO_ATTR_SPEED, SUMOReal, and SVCFreeForAll.

Referenced by myStartElement().

void GenericSAXHandler::registerParent ( const int  tag,
GenericSAXHandler handler 
)
inherited
void GenericSAXHandler::setFileName ( const std::string &  name)
inherited

Sets the current file name.

Parameters
[in]nameThe name of the currently processed file
Todo:
Hmmm - this is as unsafe as having a direct access to the variable; recheck

Definition at line 80 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myFileName.

Referenced by NIImporter_SUMO::_loadNetwork(), GUISettingsHandler::GUISettingsHandler(), PCNetProjectionLoader::load(), NIImporter_OpenStreetMap::load(), loadNet(), ROLoader::loadNet(), NIImporter_ITSUMO::loadNetwork(), NIImporter_MATSim::loadNetwork(), NIImporter_OpenDrive::loadNetwork(), and XMLSubSys::runParser().

void GenericSAXHandler::startElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname,
const XERCES_CPP_NAMESPACE::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 TplConvert::_2str(), 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 XERCES_CPP_NAMESPACE::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 172 of file RONetHandler.h.

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

std::string RONetHandler::myCurrentName
protected

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

Definition at line 169 of file RONetHandler.h.

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

ROAbstractEdgeBuilder& RONetHandler::myEdgeBuilder
protected

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

Definition at line 178 of file RONetHandler.h.

Referenced by parseDistrict(), and parseEdge().

RONet& RONetHandler::myNet
protected

The net to store the information into.

Definition at line 166 of file RONetHandler.h.

Referenced by 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 175 of file RONetHandler.h.

Referenced by myStartElement(), and parseEdge().


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