ROTypedXMLRoutesLoader.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Base class for loading routes from XML-files
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 // ===========================================================================
00020 // included modules
00021 // ===========================================================================
00022 #ifdef _MSC_VER
00023 #include <windows_config.h>
00024 #else
00025 #include <config.h>
00026 #endif
00027 
00028 #include <string>
00029 #include <xercesc/parsers/SAXParser.hpp>
00030 #include <xercesc/util/PlatformUtils.hpp>
00031 #include <xercesc/util/TransService.hpp>
00032 #include <xercesc/sax2/SAX2XMLReader.hpp>
00033 #include <utils/common/UtilExceptions.h>
00034 #include <utils/common/MsgHandler.h>
00035 #include <utils/xml/XMLSubSys.h>
00036 #include "ROAbstractRouteDefLoader.h"
00037 #include "ROTypedXMLRoutesLoader.h"
00038 #include "RONet.h"
00039 
00040 #ifdef CHECK_MEMORY_LEAKS
00041 #include <foreign/nvwa/debug_new.h>
00042 #endif // CHECK_MEMORY_LEAKS
00043 
00044 
00045 // ===========================================================================
00046 // method definitions
00047 // ===========================================================================
00048 ROTypedXMLRoutesLoader::ROTypedXMLRoutesLoader(RONet &net,
00049         SUMOTime begin,
00050         SUMOTime end,
00051         const std::string &file) throw(ProcessError)
00052         : ROAbstractRouteDefLoader(net, begin, end),
00053         SUMOSAXHandler(file),
00054         myParser(XMLSubSys::getSAXReader(*this)), myToken(), myEnded(false) {
00055     try {
00056         myParser->parseFirst(getFileName().c_str(), myToken);
00057     } catch (...) {
00058         throw ProcessError();
00059     }
00060 }
00061 
00062 
00063 ROTypedXMLRoutesLoader::~ROTypedXMLRoutesLoader() throw() {
00064     delete myParser;
00065 }
00066 
00067 
00068 bool
00069 ROTypedXMLRoutesLoader::readRoutesAtLeastUntil(SUMOTime time, bool skipping) throw(ProcessError) {
00070     while (getLastReadTimeStep()<time&&!ended()) {
00071         beginNextRoute();
00072         while (!nextRouteRead()&&!ended()) {
00073             myParser->parseNext(myToken);
00074         }
00075     }
00076     return true;
00077 }
00078 
00079 
00080 void
00081 ROTypedXMLRoutesLoader::endDocument() {
00082     myEnded = true;
00083 }
00084 
00085 
00086 
00087 
00088 /****************************************************************************/
00089 

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