RORDGenerator_ODAmounts Class Reference

#include <RORDGenerator_ODAmounts.h>

Inheritance diagram for RORDGenerator_ODAmounts:

RORDLoader_TripDefs ROTypedXMLRoutesLoader ROAbstractRouteDefLoader SUMOSAXHandler GenericSAXHandler

Detailed Description

This class is a file-based generator. Within the first step, all route definitions are parsed into the memory from a file and then consecutively build on demand.

Definition at line 51 of file RORDGenerator_ODAmounts.h.


Public Member Functions

void characters (const XMLCh *const chars, const XERCES3_SIZE_t length)
 The inherited method called when characters occured.
void endDocument ()
 Called when the document has ended.
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 throw ()
 returns the current file name
void registerParent (const SumoXMLTag tag, GenericSAXHandler *handler)
 Assigning a parent handler which is enabled when the specified tag is closed.
 RORDGenerator_ODAmounts (RONet &net, SUMOTime begin, SUMOTime end, bool emptyDestinationsAllowed, bool randomize, const std::string &file="") throw (ProcessError)
 Constructor.
void setFileName (const std::string &name) throw ()
 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.
 ~RORDGenerator_ODAmounts () throw ()
 Destructor.
inherited from ROAbstractRouteDefLoader
bool ended () const throw ()
 Returns the information whether no routes are available from this loader anymore.
SAX ErrorHandler callbacks
void error (const SAXParseException &exception) throw (ProcessError)
 Handler for XML-errors.
void fatalError (const SAXParseException &exception) throw (ProcessError)
 Handler for XML-errors.
void warning (const SAXParseException &exception) throw ()
 Handler for XML-warnings.
inherited from ROAbstractRouteDefLoader
SUMOTime getLastReadTimeStep () const throw ()
 Returns the time the current (last read) route starts at.
inherited from ROAbstractRouteDefLoader
bool readRoutesAtLeastUntil (SUMOTime until, bool skipping) throw (ProcessError)
 Adds routes from the file until the given time is reached.

Protected Member Functions

std::string buildErrorMessage (const SAXParseException &exception) throw ()
 Builds an error message.
ROEdgegetEdge (const SUMOSAXAttributes &attrs, const std::string &purpose, SumoXMLAttr which, const std::string &id, bool emptyAllowed)
 Parses a named edge frm the attributes.
std::string getLane (const SUMOSAXAttributes &attrs)
 Parses and returns the name of the lane the vehicle starts at This value is optional.
SUMOTime getPeriod (const SUMOSAXAttributes &attrs, const std::string &id)
 Parses and returns the period the trip shall be repeated with.
int getRepetitionNumber (const SUMOSAXAttributes &attrs, const std::string &id)
 Parses and returns the number of cars that shall use the same parameter.
std::string getVehicleID (const SUMOSAXAttributes &attrs)
 Parses the vehicle id.
virtual void myCharacters (SumoXMLTag element, const std::string &chars) throw (ProcessError)
 Callback method for characters to implement by derived classes.
void myEndFlowAmountDef ()
 Closes the trip amount parsing.
void myEndInterval ()
 Closes the current embedding interval.
void parseFlowAmountDef (const SUMOSAXAttributes &attrs) throw (ProcessError)
 Parses the trip amount definition.
void parseInterval (const SUMOSAXAttributes &attrs)
 Parses the interval information.
inherited from ROTypedXMLRoutesLoader
void beginNextRoute () throw ()
 Returns Initialises the reading of a further route.
bool nextRouteRead () throw ()
inherited from GenericSAXHandler
void myEndElement (SumoXMLTag element) throw (ProcessError)
 Called when a closing tag occurs.
void myStartElement (SumoXMLTag element, const SUMOSAXAttributes &attrs) throw (ProcessError)
 Called on the opening of a tag;.

Protected Attributes

SUMOTime myBegin
 The time for which the first route shall be loaded.
ROEdgemyBeginEdge
 The starting edge.
SUMOVTypeParametermyCurrentVehicleType
 The currently parsed vehicle type.
SUMOTime myDepartureTime
const bool myEmptyDestinationsAllowed
 Information whether empty destinations are allowed This is a feature used for the handling of explicite routes within the jp-router where the destination is not necessary.
SUMOTime myEnd
 The time for which the first route shall be loaded.
bool myEnded
 Information whether the whole file has been parsed.
ROEdgemyEndEdge
 The end edge.
IDSupplier myIdSupplier
 generates numerical ids
RONetmyNet
 The network to add routes to.
bool myNextRouteRead
 The information whether the next route was read.
SUMOVehicleParametermyParameter
SAX2XMLReader * myParser
 The parser used.
XMLPScanToken myToken
 Information about the current position within the file.
const bool myWithTaz
 Information whether zones (districts) are used as origins / destinations.

Private Types

typedef std::vector< FlowDef * > FlowDefV
 Definition of a container for flo definitions (vector).

Private Member Functions

void buildForTimeStep (SUMOTime time) throw ()
 Builds the routes for the given time step.
void buildRoutes (SUMOTime until) throw ()
 Builds the routes between the current time step and the one given.
RORDGenerator_ODAmountsoperator= (const RORDGenerator_ODAmounts &src)
 Invalidated assignment operator.
 RORDGenerator_ODAmounts (const RORDGenerator_ODAmounts &src)
 Invalidated copy constructor.

Private Attributes

SUMOTime myCurrentTimeStep
 The current time step read.
FlowDefV myFlows
 The definitions of the read flows.
SUMOTime myIntervalBegin
 The begin of the interval current read.
SUMOTime myIntervalEnd
 The end of the interval current read.
std::set< std::string > myKnownIDs
 A storage for ids (!!! this should be done router-wide).
bool myRandom
 Information whether randomized departures are used.
SUMOTime myUpperIntervalBegin
 The begin of the embedding interval (if given).
SUMOTime myUpperIntervalEnd
 The end of the embedding interval (if given).
unsigned int myVehicle2EmitNumber
 The number of vehicles to emit.

Data Structures

class  FlowDef

Member Typedef Documentation

typedef std::vector<FlowDef*> RORDGenerator_ODAmounts::FlowDefV [private]

Definition of a container for flo definitions (vector).

Definition at line 196 of file RORDGenerator_ODAmounts.h.


Constructor & Destructor Documentation

RORDGenerator_ODAmounts::RORDGenerator_ODAmounts ( RONet net,
SUMOTime  begin,
SUMOTime  end,
bool  emptyDestinationsAllowed,
bool  randomize,
const std::string &  file = "" 
) throw (ProcessError)

Constructor.

Definition at line 138 of file RORDGenerator_ODAmounts.cpp.

References GenericSAXHandler::getFileName(), ROAbstractRouteDefLoader::myBegin, RORDLoader_TripDefs::myDepartureTime, ROTypedXMLRoutesLoader::myParser, and ROTypedXMLRoutesLoader::myToken.

00144         : RORDLoader_TripDefs(net, begin, end, emptyDestinationsAllowed, false, fileName),
00145         myRandom(randomize) {
00146     // read the complete file on initialisation
00147     myParser->parseReset(myToken);
00148     myParser->parse(getFileName().c_str());
00149     myDepartureTime = myBegin;
00150 }

RORDGenerator_ODAmounts::~RORDGenerator_ODAmounts (  )  throw ()

Destructor.

Definition at line 153 of file RORDGenerator_ODAmounts.cpp.

References myFlows.

00153                                                           {
00154     for (FlowDefV::const_iterator i=myFlows.begin(); i!=myFlows.end(); i++) {
00155         delete(*i);
00156     }
00157 }

RORDGenerator_ODAmounts::RORDGenerator_ODAmounts ( const RORDGenerator_ODAmounts src  )  [private]

Invalidated copy constructor.


Member Function Documentation

void RORDLoader_TripDefs::beginNextRoute (  )  throw () [protected, virtual, inherited]

Returns Initialises the reading of a further route.

Todo:
recheck/refactor
See also:
ROTypedXMLRoutesLoader::beginNextRoute

Implements ROTypedXMLRoutesLoader.

Definition at line 196 of file RORDLoader_TripDefs.cpp.

References RORDLoader_TripDefs::myNextRouteRead.

00196                                             {
00197     myNextRouteRead = false;
00198 }

std::string SUMOSAXHandler::buildErrorMessage ( const SAXParseException &  exception  )  throw () [protected, inherited]

Builds an error message.

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

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

Definition at line 55 of file SUMOSAXHandler.cpp.

References GenericSAXHandler::getFileName().

Referenced by SUMOSAXHandler::error(), SUMOSAXHandler::fatalError(), and SUMOSAXHandler::warning().

00055                                                                             {
00056     std::ostringstream buf;
00057     char *pMsg = XMLString::transcode(exception.getMessage());
00058     buf << pMsg << std::endl;
00059     buf << " In file '" << getFileName() << "'" << std::endl;
00060     buf << " At line/column " << exception.getLineNumber()+1
00061     << '/' << exception.getColumnNumber() << "." << std::endl;
00062     XMLString::release(&pMsg);
00063     return buf.str();
00064 }

void RORDGenerator_ODAmounts::buildForTimeStep ( SUMOTime  time  )  throw () [private]

Builds the routes for the given time step.

Definition at line 184 of file RORDGenerator_ODAmounts.cpp.

References RORDGenerator_ODAmounts::FlowDef::addRoutes(), RORDGenerator_ODAmounts::FlowDef::applicableForTime(), RORDGenerator_ODAmounts::FlowDef::getIntervalEnd(), ROAbstractRouteDefLoader::myEnd, ROTypedXMLRoutesLoader::myEnded, myFlows, and ROAbstractRouteDefLoader::myNet.

Referenced by buildRoutes().

00184                                                                {
00185     if (time<myBegin||time>=myEnd) {
00186         return;
00187     }
00188     myEnded = true;
00189     for (FlowDefV::const_iterator i=myFlows.begin(); i!=myFlows.end(); i++) {
00190         FlowDef *fd = *i;
00191         // skip flow definitions not valid for the current time
00192         if (fd->applicableForTime(time)) {
00193             fd->addRoutes(myNet, time);
00194         }
00195         // check whether any further exists
00196         if (fd->getIntervalEnd()>time) {
00197             myEnded = false;
00198         }
00199     }
00200 }

void RORDGenerator_ODAmounts::buildRoutes ( SUMOTime  until  )  throw () [private]

Builds the routes between the current time step and the one given.

Definition at line 174 of file RORDGenerator_ODAmounts.cpp.

References buildForTimeStep(), DELTA_T, and RORDLoader_TripDefs::myDepartureTime.

Referenced by readRoutesAtLeastUntil().

00174                                                            {
00175     SUMOTime t;
00176     for (t=myDepartureTime; t<until+1; t+=DELTA_T) {
00177         buildForTimeStep(t);
00178     }
00179     myDepartureTime = t;
00180 }

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
Todo:
describe characters processing in the class' head

Definition at line 168 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myCharactersVector.

00169                                                            {
00170     myCharactersVector.push_back(TplConvert<XMLCh>::_2str(chars, length));
00171 }

void ROTypedXMLRoutesLoader::endDocument (  )  [inherited]

Called when the document has ended.

Todo:
Recheck usage of route loaders; it is not very fine to have one that use a parser and other that do not

Definition at line 81 of file ROTypedXMLRoutesLoader.cpp.

References ROTypedXMLRoutesLoader::myEnded.

00081                                     {
00082     myEnded = true;
00083 }

bool ROTypedXMLRoutesLoader::ended (  )  const throw () [inline, virtual, inherited]

Returns the information whether no routes are available from this loader anymore.

Returns:
Whether the whole input has been processed

Implements ROAbstractRouteDefLoader.

Definition at line 97 of file ROTypedXMLRoutesLoader.h.

References ROTypedXMLRoutesLoader::myEnded.

Referenced by ROTypedXMLRoutesLoader::readRoutesAtLeastUntil().

00097                                {
00098         return myEnded;
00099     }

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
Todo:
do not generate and report the string-representation

Definition at line 118 of file GenericSAXHandler.cpp.

References TplConvert< E >::_2str(), GenericSAXHandler::convertTag(), GenericSAXHandler::myCharacters(), GenericSAXHandler::myCharactersVector, GenericSAXHandler::myEndElement(), GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, XMLSubSys::setHandler(), SUMO_TAG_INCLUDE, and SUMO_TAG_NOTHING.

00120                                                         {
00121     std::string name = TplConvert<XMLCh>::_2str(qname);
00122     SumoXMLTag element = convertTag(name);
00123     // collect characters
00124     if (myCharactersVector.size()!=0) {
00125         size_t len = 0;
00126         unsigned i;
00127         for (i=0; i<myCharactersVector.size(); ++i) {
00128             len += myCharactersVector[i].length();
00129         }
00130         char *buf = new char[len+1];
00131         size_t pos = 0;
00132         for (i=0; i<myCharactersVector.size(); ++i) {
00133             memcpy((unsigned char*) buf+pos, (unsigned char*) myCharactersVector[i].c_str(),
00134                    sizeof(char)*myCharactersVector[i].length());
00135             pos += myCharactersVector[i].length();
00136         }
00137         buf[pos] = 0;
00138 
00139         // call user handler
00140         try {
00141             myCharacters(element, buf);
00142         } catch (std::runtime_error &) {
00143             delete[] buf;
00144             throw;
00145         }
00146         delete[] buf;
00147     }
00148     if (element != SUMO_TAG_INCLUDE) {
00149         myEndElement(element);
00150         if (myParentHandler && myParentIndicator == element) {
00151             XMLSubSys::setHandler(*myParentHandler);
00152             myParentIndicator = SUMO_TAG_NOTHING;
00153             myParentHandler = 0;
00154         }
00155     }
00156 }

void SUMOSAXHandler::error ( const SAXParseException &  exception  )  throw (ProcessError) [inherited]

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Parameters:
[in] exception The occured exception to process
Exceptions:
ProcessError On any call

Definition at line 74 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage().

00074                                                                             {
00075     throw ProcessError(buildErrorMessage(exception));
00076 }

void SUMOSAXHandler::fatalError ( const SAXParseException &  exception  )  throw (ProcessError) [inherited]

Handler for XML-errors.

The message is built using buildErrorMessage and thrown within a ProcessError.

Exceptions:
ProcessError On any call
Parameters:
[in] exception The occured exception to process

Definition at line 80 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage().

00080                                                                                  {
00081     throw ProcessError(buildErrorMessage(exception));
00082 }

ROEdge * RORDLoader_TripDefs::getEdge ( const SUMOSAXAttributes attrs,
const std::string &  purpose,
SumoXMLAttr  which,
const std::string &  id,
bool  emptyAllowed 
) [protected, inherited]

Parses a named edge frm the attributes.

Definition at line 116 of file RORDLoader_TripDefs.cpp.

References RONet::getEdge(), MsgHandler::getErrorInstance(), SUMOSAXAttributes::getStringReporting(), MsgHandler::inform(), ROAbstractRouteDefLoader::myNet, and SUMO_ATTR_FROM_TAZ.

Referenced by RORDLoader_TripDefs::myStartElement(), and parseFlowAmountDef().

00119                                                 {
00120     bool ok = true;
00121     std::string id = attrs.getStringReporting(which, 0, 0, ok, !emptyAllowed);
00122     if (which == SUMO_ATTR_FROM_TAZ) {
00123         id += "-source";
00124     }
00125     ROEdge *e = myNet.getEdge(id);
00126     if (e==0 && !emptyAllowed) {
00127         MsgHandler::getErrorInstance()->inform("The edge '" + id + "' is not known.\n Vehicle id='" + vid + "'.");
00128     }
00129     return e;
00130 }

const std::string & GenericSAXHandler::getFileName (  )  const throw () [inherited]

std::string RORDLoader_TripDefs::getLane ( const SUMOSAXAttributes attrs  )  [protected, inherited]

Parses and returns the name of the lane the vehicle starts at This value is optional.

Definition at line 158 of file RORDLoader_TripDefs.cpp.

References SUMOSAXAttributes::getOptStringReporting(), and SUMO_ATTR_LANE.

00158                                                            {
00159     bool ok = true;
00160     return attrs.getOptStringReporting(SUMO_ATTR_LANE, 0, 0, ok, "");
00161 }

SUMOTime RORDLoader_TripDefs::getLastReadTimeStep (  )  const throw () [inline, virtual, inherited]

Returns the time the current (last read) route starts at.

Returns:
The least time step that was read by this reader

Implements ROAbstractRouteDefLoader.

Definition at line 68 of file RORDLoader_TripDefs.h.

References RORDLoader_TripDefs::myDepartureTime.

00068                                                  {
00069         return myDepartureTime;
00070     }

SUMOTime RORDLoader_TripDefs::getPeriod ( const SUMOSAXAttributes attrs,
const std::string &  id 
) [protected, inherited]

Parses and returns the period the trip shall be repeated with.

Definition at line 134 of file RORDLoader_TripDefs.cpp.

References SUMOSAXAttributes::getSUMOTimeReporting(), SUMOSAXAttributes::hasAttribute(), and SUMO_ATTR_PERIOD.

00135                                                     {
00136     if (!attrs.hasAttribute(SUMO_ATTR_PERIOD)) {
00137         return -1;
00138     }
00139     // get the repetition period
00140     bool ok = true;
00141     return attrs.getSUMOTimeReporting(SUMO_ATTR_PERIOD, "tripdef", id.c_str(), ok);
00142 }

int RORDLoader_TripDefs::getRepetitionNumber ( const SUMOSAXAttributes attrs,
const std::string &  id 
) [protected, inherited]

Parses and returns the number of cars that shall use the same parameter.

Definition at line 146 of file RORDLoader_TripDefs.cpp.

References SUMOSAXAttributes::getIntReporting(), SUMOSAXAttributes::hasAttribute(), and SUMO_ATTR_REPNUMBER.

00147                              {
00148     if (!attrs.hasAttribute(SUMO_ATTR_REPNUMBER)) {
00149         return -1;
00150     }
00151     // get the repetition number
00152     bool ok = true;
00153     return attrs.getIntReporting(SUMO_ATTR_REPNUMBER, "tripdef", id.c_str(), ok);
00154 }

std::string RORDLoader_TripDefs::getVehicleID ( const SUMOSAXAttributes attrs  )  [protected, inherited]

Parses the vehicle id.

Definition at line 103 of file RORDLoader_TripDefs.cpp.

References IDSupplier::getNext(), RORDLoader_TripDefs::myIdSupplier, and SUMOSAXAttributes::setIDFromAttributes().

Referenced by RORDLoader_TripDefs::myStartElement(), and parseFlowAmountDef().

00103                                                                 {
00104     // get the id, report an error if not given or empty...
00105     std::string id;
00106     attrs.setIDFromAttributes("tripdef", id, false);
00107     // get a valid vehicle id
00108     if (id=="") {
00109         id = myIdSupplier.getNext();
00110     }
00111     return id;
00112 }

void GenericSAXHandler::myCharacters ( SumoXMLTag  element,
const std::string &  chars 
) throw (ProcessError) [protected, virtual, inherited]

Callback method for characters to implement by derived classes.

Called by "endElement" (see there).

Parameters:
[in] element The opened element, given as a SumoXMLTag
[in] chars The complete embedded character string ProcessError These method may throw a ProcessError if something fails

Reimplemented in ROJTRTurnDefLoader, MSRouteHandler, NIImporter_OpenDrive, NIImporter_SUMO, NLHandler, PCLoaderXML, PCNetProjectionLoader, and RORDLoader_SUMOBase.

Definition at line 189 of file GenericSAXHandler.cpp.

Referenced by GenericSAXHandler::endElement().

00189 {}

void RORDGenerator_ODAmounts::myEndElement ( SumoXMLTag  element  )  throw (ProcessError) [protected, virtual]

Called when a closing tag occurs.

Parameters:
[in] element ID of the currently opened element
Exceptions:
ProcessError If something fails
See also:
GenericSAXHandler::myEndElement

Reimplemented from RORDLoader_TripDefs.

Definition at line 255 of file RORDGenerator_ODAmounts.cpp.

References RORDLoader_TripDefs::myEndElement(), myEndFlowAmountDef(), myEndInterval(), SUMO_TAG_FLOW, and SUMO_TAG_INTERVAL.

00255                                                                             {
00256     RORDLoader_TripDefs::myEndElement(element);
00257     if (element == SUMO_TAG_FLOW) {
00258         myEndFlowAmountDef();
00259     } else if (element == SUMO_TAG_INTERVAL) {
00260         myEndInterval();
00261     }
00262 }

void RORDGenerator_ODAmounts::myEndFlowAmountDef (  )  [protected]

Closes the trip amount parsing.

!! set double in route def and flowdef?

Definition at line 273 of file RORDGenerator_ODAmounts.cpp.

References RONet::addRouteDef(), SUMOVehicleParameter::color, MsgHandler::getErrorInstance(), RONet::getVehicleTypeSecure(), SUMOVehicleParameter::id, ROAbstractRouteDefLoader::myBegin, RORDLoader_TripDefs::myBeginEdge, RORDLoader_TripDefs::myEndEdge, myFlows, myIntervalBegin, myIntervalEnd, ROAbstractRouteDefLoader::myNet, RORDLoader_TripDefs::myNextRouteRead, RORDLoader_TripDefs::myParameter, myRandom, myVehicle2EmitNumber, VEHPARS_COLOR_SET, SUMOVehicleParameter::vtypeid, and SUMOVehicleParameter::wasSet().

Referenced by myEndElement().

00273                                             {
00274     if (!MsgHandler::getErrorInstance()->wasInformed()) {
00275 
00276         if (myIntervalEnd<myBegin) {
00277             return;
00278         }
00279         // add the vehicle type, the vehicle and the route to the net
00280         RGBColor *col = myParameter->wasSet(VEHPARS_COLOR_SET) ? new RGBColor(myParameter->color) : 0;
00281         RORouteDef *route = new RORouteDef_OrigDest(myParameter->id, col, myBeginEdge, myEndEdge);
00282         SUMOVTypeParameter *type = myNet.getVehicleTypeSecure(myParameter->vtypeid);
00283         // check whether any errors occured
00284         if (MsgHandler::getErrorInstance()->wasInformed()) {
00285             return;
00286         }
00287         // build the vehicle
00288         myNet.addRouteDef(route);
00289         myNextRouteRead = true;
00290         ROVehicle *vehicle = new ROVehicle(*myParameter, route, type);
00291         // add to the container
00292         FlowDef *fd = new FlowDef(vehicle, type, route, myIntervalBegin, myIntervalEnd, myVehicle2EmitNumber, myRandom);
00293         myFlows.push_back(fd);
00294         delete myParameter;
00295         myParameter = 0;
00296     }
00297 }

void RORDGenerator_ODAmounts::myEndInterval (  )  [protected]

Closes the current embedding interval.

Definition at line 266 of file RORDGenerator_ODAmounts.cpp.

References myUpperIntervalBegin, and myUpperIntervalEnd.

Referenced by myEndElement().

00266                                        {
00267     myUpperIntervalBegin = 0; // !!! was -1
00268     myUpperIntervalEnd = 0; // !!! was: -1
00269 }

void RORDGenerator_ODAmounts::myStartElement ( SumoXMLTag  element,
const SUMOSAXAttributes attrs 
) throw (ProcessError) [protected, virtual]

Called on the opening of a tag;.

Parameters:
[in] element ID of the currently opened element
[in] attrs Attributes within the currently opened element
Exceptions:
ProcessError If something fails
See also:
GenericSAXHandler::myStartElement

Reimplemented from RORDLoader_TripDefs.

Definition at line 204 of file RORDGenerator_ODAmounts.cpp.

References RORDLoader_TripDefs::myStartElement(), parseFlowAmountDef(), parseInterval(), SUMO_TAG_FLOW, and SUMO_TAG_INTERVAL.

00205                                                                                             {
00206     RORDLoader_TripDefs::myStartElement(element, attrs);
00207     if (element == SUMO_TAG_FLOW) {
00208         parseFlowAmountDef(attrs);
00209     } else if (element == SUMO_TAG_INTERVAL) {
00210         parseInterval(attrs);
00211     }
00212 }

bool RORDLoader_TripDefs::nextRouteRead (  )  throw () [inline, protected, virtual, inherited]

Returns the information whether a route was read

Returns:
Whether a further route was read
See also:
ROTypedXMLRoutesLoader::nextRouteRead

Implements ROTypedXMLRoutesLoader.

Definition at line 108 of file RORDLoader_TripDefs.h.

References RORDLoader_TripDefs::myNextRouteRead.

00108                                  {
00109         return myNextRouteRead;
00110     }

RORDGenerator_ODAmounts& RORDGenerator_ODAmounts::operator= ( const RORDGenerator_ODAmounts src  )  [private]

Invalidated assignment operator.

void RORDGenerator_ODAmounts::parseFlowAmountDef ( const SUMOSAXAttributes attrs  )  throw (ProcessError) [protected]

Parses the trip amount definition.

Definition at line 216 of file RORDGenerator_ODAmounts.cpp.

References RORDLoader_TripDefs::getEdge(), RORDLoader_TripDefs::getVehicleID(), SUMOVehicleParameter::id, RORDLoader_TripDefs::myBeginEdge, RORDLoader_TripDefs::myEmptyDestinationsAllowed, RORDLoader_TripDefs::myEndEdge, myIntervalBegin, myIntervalEnd, myKnownIDs, RORDLoader_TripDefs::myParameter, myUpperIntervalBegin, myUpperIntervalEnd, myVehicle2EmitNumber, SUMOVehicleParserHelper::parseVehicleAttributes(), StringUtils::replace(), SUMO_ATTR_BEGIN, SUMO_ATTR_END, SUMO_ATTR_FROM, SUMO_ATTR_NO, and SUMO_ATTR_TO.

Referenced by myStartElement().

00216                                                                                               {
00217     // get the vehicle id, the edges, the speed and position and
00218     //  the departure time and other information
00219     std::string id = getVehicleID(attrs);
00220     if (myKnownIDs.find(id)!=myKnownIDs.end()) {
00221         throw ProcessError("The id '" + id + "' appears twice within the flow descriptions.'");
00222     }
00223     myKnownIDs.insert(id); // !!! a local storage is not save
00224     myBeginEdge = getEdge(attrs, "origin", SUMO_ATTR_FROM, id, false);
00225     myEndEdge = getEdge(attrs, "destination",
00226                         SUMO_ATTR_TO, id, myEmptyDestinationsAllowed);
00227     try {
00228         myParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, true, true);
00229     } catch (ProcessError &e) {
00230         throw ProcessError(StringUtils::replace(e.what(), "''", id.c_str()));
00231     }
00232     myParameter->id = id;
00233     bool ok = true;
00234     myIntervalBegin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, "flow", id.c_str(), ok, myUpperIntervalBegin);
00235     myIntervalEnd = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, "flow", id.c_str(), ok, myUpperIntervalEnd);
00236     myVehicle2EmitNumber = attrs.getIntReporting(SUMO_ATTR_NO, "flow", id.c_str(), ok); // !!! no real error handling
00237     if (!ok) {
00238         throw ProcessError();
00239     }
00240     if (myIntervalEnd<=myIntervalBegin) {
00241         throw ProcessError("The interval must be larger than 0.\n The current values are: begin=" + toString<unsigned int>(myIntervalBegin) + " end=" + toString<unsigned int>(myIntervalEnd));
00242     }
00243 }

void RORDGenerator_ODAmounts::parseInterval ( const SUMOSAXAttributes attrs  )  [protected]

Parses the interval information.

Definition at line 247 of file RORDGenerator_ODAmounts.cpp.

References SUMOSAXAttributes::getOptSUMOTimeReporting(), myUpperIntervalBegin, myUpperIntervalEnd, SUMO_ATTR_BEGIN, and SUMO_ATTR_END.

Referenced by myStartElement().

00247                                                                      {
00248     bool ok = true;
00249     myUpperIntervalBegin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, "interval", 0, ok, -1); // !!!really optional ?
00250     myUpperIntervalEnd = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, "interval", 0, ok, -1); // !!!really optional ?
00251 }

bool RORDGenerator_ODAmounts::readRoutesAtLeastUntil ( SUMOTime  until,
bool  skipping 
) throw (ProcessError) [virtual]

Adds routes from the file until the given time is reached.

Parameters:
[in] time The time until which route definitions shall be loaded
[in] skipping Whether routes shall not be added
Returns:
Whether any errors occured
Exceptions:
ProcessError If a major error occured
See also:
ROAbstractRouteDefLoader::readRoutesAtLeastUntil

Reimplemented from ROTypedXMLRoutesLoader.

Definition at line 161 of file RORDGenerator_ODAmounts.cpp.

References buildRoutes(), ROAbstractRouteDefLoader::myBegin, and RORDLoader_TripDefs::myDepartureTime.

00161                                                                                                  {
00162     // skip routes before begin
00163     if (until<myBegin) {
00164         myDepartureTime = until;
00165         return true;
00166     }
00167     // build route definitions for the given timestep
00168     buildRoutes(until);
00169     return true;
00170 }

void GenericSAXHandler::registerParent ( const SumoXMLTag  tag,
GenericSAXHandler handler 
) [inherited]

Assigning a parent handler which is enabled when the specified tag is closed.

Definition at line 160 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myParentHandler, GenericSAXHandler::myParentIndicator, and XMLSubSys::setHandler().

Referenced by NLTriggerBuilder::parseAndBuildLaneSpeedTrigger().

00160                                                                                   {
00161     myParentHandler = handler;
00162     myParentIndicator = tag;
00163     XMLSubSys::setHandler(*this);
00164 }

void GenericSAXHandler::setFileName ( const std::string &  name  )  throw () [inherited]

Sets the current file name.

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

Definition at line 72 of file GenericSAXHandler.cpp.

References GenericSAXHandler::myFileName.

Referenced by PCNetProjectionLoader::loadIfSet(), ROLoader::loadNet(), NIImporter_OpenStreetMap::loadNetwork(), NILoader::loadXMLType(), and traci::TraCIServer::TraCIServer().

00072                                                             {
00073     myFileName = name;
00074 }

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
Todo:
do not generate and report the string-representation

Definition at line 97 of file GenericSAXHandler.cpp.

References TplConvert< E >::_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.

00100                                                          {
00101     std::string name = TplConvert<XMLCh>::_2str(qname);
00102     SumoXMLTag element = convertTag(name);
00103     myCharactersVector.clear();
00104     SUMOSAXAttributesImpl_Xerces na(attrs, myPredefinedTags, myPredefinedTagsMML);
00105     if (element == SUMO_TAG_INCLUDE) {
00106         std::string file = na.getString(SUMO_ATTR_HREF);
00107         if (!FileHelpers::isAbsolute(file)) {
00108             file = FileHelpers::getConfigurationRelative(getFileName(), file);
00109         }
00110         XMLSubSys::runParser(*this, file);
00111     } else {
00112         myStartElement(element, na);
00113     }
00114 }

void SUMOSAXHandler::warning ( const SAXParseException &  exception  )  throw () [inherited]

Handler for XML-warnings.

The message is built using buildErrorMessage and reported to the warning-instance of the MsgHandler.

Parameters:
[in] exception The occured exception to process

Definition at line 68 of file SUMOSAXHandler.cpp.

References SUMOSAXHandler::buildErrorMessage(), MsgHandler::getWarningInstance(), and MsgHandler::inform().


Field Documentation

The time for which the first route shall be loaded.

Definition at line 107 of file ROAbstractRouteDefLoader.h.

Referenced by RORDLoader_SUMOBase::closeVehicle(), myEndFlowAmountDef(), readRoutesAtLeastUntil(), and RORDGenerator_ODAmounts().

ROEdge* RORDLoader_TripDefs::myBeginEdge [protected, inherited]

The current time step read.

Definition at line 193 of file RORDGenerator_ODAmounts.h.

The currently parsed vehicle type.

Definition at line 162 of file RORDLoader_TripDefs.h.

Referenced by RORDLoader_TripDefs::myEndElement(), and RORDLoader_TripDefs::myStartElement().

Information whether empty destinations are allowed This is a feature used for the handling of explicite routes within the jp-router where the destination is not necessary.

Definition at line 153 of file RORDLoader_TripDefs.h.

Referenced by RORDLoader_TripDefs::myStartElement(), and parseFlowAmountDef().

SUMOTime ROAbstractRouteDefLoader::myEnd [protected, inherited]

The time for which the first route shall be loaded.

Definition at line 110 of file ROAbstractRouteDefLoader.h.

Referenced by buildForTimeStep(), RORDLoader_SUMOBase::closeVehicle(), and RORDLoader_TripDefs::myEndElement().

bool ROTypedXMLRoutesLoader::myEnded [protected, inherited]

Information whether the whole file has been parsed.

Definition at line 139 of file ROTypedXMLRoutesLoader.h.

Referenced by buildForTimeStep(), ROTypedXMLRoutesLoader::endDocument(), and ROTypedXMLRoutesLoader::ended().

ROEdge* RORDLoader_TripDefs::myEndEdge [protected, inherited]

The definitions of the read flows.

Definition at line 199 of file RORDGenerator_ODAmounts.h.

Referenced by buildForTimeStep(), myEndFlowAmountDef(), and ~RORDGenerator_ODAmounts().

generates numerical ids

Definition at line 142 of file RORDLoader_TripDefs.h.

Referenced by RORDLoader_TripDefs::getVehicleID().

The begin of the interval current read.

Definition at line 178 of file RORDGenerator_ODAmounts.h.

Referenced by myEndFlowAmountDef(), and parseFlowAmountDef().

The end of the interval current read.

Definition at line 181 of file RORDGenerator_ODAmounts.h.

Referenced by myEndFlowAmountDef(), and parseFlowAmountDef().

std::set<std::string> RORDGenerator_ODAmounts::myKnownIDs [private]

A storage for ids (!!! this should be done router-wide).

Definition at line 202 of file RORDGenerator_ODAmounts.h.

Referenced by parseFlowAmountDef().

RONet& ROAbstractRouteDefLoader::myNet [protected, inherited]

The information whether the next route was read.

Definition at line 159 of file RORDLoader_TripDefs.h.

Referenced by RORDLoader_TripDefs::beginNextRoute(), RORDLoader_TripDefs::myEndElement(), myEndFlowAmountDef(), and RORDLoader_TripDefs::nextRouteRead().

SAX2XMLReader* ROTypedXMLRoutesLoader::myParser [protected, inherited]

Information whether randomized departures are used.

Definition at line 205 of file RORDGenerator_ODAmounts.h.

Referenced by myEndFlowAmountDef().

XMLPScanToken ROTypedXMLRoutesLoader::myToken [protected, inherited]

Information about the current position within the file.

Definition at line 136 of file ROTypedXMLRoutesLoader.h.

Referenced by ROTypedXMLRoutesLoader::readRoutesAtLeastUntil(), and RORDGenerator_ODAmounts().

The begin of the embedding interval (if given).

Definition at line 184 of file RORDGenerator_ODAmounts.h.

Referenced by myEndInterval(), parseFlowAmountDef(), and parseInterval().

The end of the embedding interval (if given).

Definition at line 187 of file RORDGenerator_ODAmounts.h.

Referenced by myEndInterval(), parseFlowAmountDef(), and parseInterval().

The number of vehicles to emit.

Definition at line 190 of file RORDGenerator_ODAmounts.h.

Referenced by myEndFlowAmountDef(), and parseFlowAmountDef().

const bool RORDLoader_TripDefs::myWithTaz [protected, inherited]

Information whether zones (districts) are used as origins / destinations.

Definition at line 156 of file RORDLoader_TripDefs.h.

Referenced by RORDLoader_TripDefs::myStartElement().


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

Generated on Wed May 5 00:06:59 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6