SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // Loader for networks and route imports 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 #ifndef ROLoader_h 00023 #define ROLoader_h 00024 00025 00026 // =========================================================================== 00027 // included modules 00028 // =========================================================================== 00029 #ifdef _MSC_VER 00030 #include <windows_config.h> 00031 #else 00032 #include <config.h> 00033 #endif 00034 00035 #include <string> 00036 #include <xercesc/sax2/SAX2XMLReader.hpp> 00037 #include <utils/common/SUMOTime.h> 00038 #include <utils/common/SUMOAbstractRouter.h> 00039 #include <utils/common/ValueTimeLine.h> 00040 #include <utils/xml/SAXWeightsHandler.h> 00041 00042 00043 // =========================================================================== 00044 // class declarations 00045 // =========================================================================== 00046 class OptionsCont; 00047 class RONet; 00048 class ROTypedXMLRoutesLoader; 00049 class ROAbstractEdgeBuilder; 00050 class GUIRouterRunThread; 00051 class ROVehicle; 00052 00053 00054 // =========================================================================== 00055 // class definitions 00056 // =========================================================================== 00065 class ROLoader { 00066 public: 00073 ROLoader(OptionsCont& oc, bool emptyDestinationsAllowed) ; 00074 00075 00077 virtual ~ROLoader(); 00078 00080 virtual void loadNet(RONet& toFill, ROAbstractEdgeBuilder& eb); 00081 00083 bool loadWeights(RONet& net, const std::string& optionName, 00084 const std::string& measure, bool useLanes); 00085 00088 unsigned int openRoutes(RONet& net); 00089 00092 void processRoutesStepWise(SUMOTime start, SUMOTime end, 00093 RONet& net, SUMOAbstractRouter<ROEdge, ROVehicle> &router); 00094 00097 void processAllRoutes(SUMOTime start, SUMOTime end, 00098 RONet& net, SUMOAbstractRouter<ROEdge, ROVehicle> &router); 00099 00101 void processAllRoutesWithBulkRouter(SUMOTime start, SUMOTime end, 00102 RONet& net, SUMOAbstractRouter<ROEdge, ROVehicle> &router); 00103 00104 bool makeSingleStep(SUMOTime end, RONet& net, SUMOAbstractRouter<ROEdge, ROVehicle> &router); 00105 00106 protected: 00128 bool openTypedRoutes(const std::string& optionName, RONet& net) ; 00129 00130 00140 SUMOTime getMinTimeStep() const ; 00141 00142 00143 00149 class EdgeFloatTimeLineRetriever_EdgeWeight : public SAXWeightsHandler::EdgeFloatTimeLineRetriever { 00150 public: 00152 EdgeFloatTimeLineRetriever_EdgeWeight(RONet& net) : myNet(net) {} 00153 00155 ~EdgeFloatTimeLineRetriever_EdgeWeight() { } 00156 00165 void addEdgeWeight(const std::string& id, 00166 SUMOReal val, SUMOReal beg, SUMOReal end) const ; 00167 00168 private: 00170 RONet& myNet; 00171 00172 }; 00173 00174 00180 class EdgeFloatTimeLineRetriever_EdgeTravelTime : public SAXWeightsHandler::EdgeFloatTimeLineRetriever { 00181 public: 00183 EdgeFloatTimeLineRetriever_EdgeTravelTime(RONet& net) : myNet(net) {} 00184 00186 ~EdgeFloatTimeLineRetriever_EdgeTravelTime() {} 00187 00196 void addEdgeWeight(const std::string& id, 00197 SUMOReal val, SUMOReal beg, SUMOReal end) const ; 00198 00199 private: 00201 RONet& myNet; 00202 00203 }; 00204 00205 00206 00207 protected: 00208 ROTypedXMLRoutesLoader* buildNamedHandler(const std::string& optionName, 00209 const std::string& file, RONet& net) ; 00210 00211 00212 void writeStats(SUMOTime time, SUMOTime start, int absNo) ; 00213 00214 00216 void destroyHandlers() ; 00217 00218 00219 protected: 00221 OptionsCont& myOptions; 00222 00224 typedef std::vector<ROTypedXMLRoutesLoader*> RouteLoaderCont; 00225 00227 RouteLoaderCont myHandler; 00228 00230 bool myEmptyDestinationsAllowed; 00231 00232 00233 private: 00235 ROLoader(const ROLoader& src); 00236 00238 ROLoader& operator=(const ROLoader& src); 00239 00241 bool myLogSteps; 00242 }; 00243 00244 00245 #endif 00246 00247 /****************************************************************************/ 00248