00001 /****************************************************************************/ 00007 // An XML-handler for network weights 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 #ifndef SAXWeightsHandler_h 00020 #define SAXWeightsHandler_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include <utils/xml/SUMOSAXHandler.h> 00034 #include <utils/common/SUMOTime.h> 00035 00036 00037 // =========================================================================== 00038 // class declarations 00039 // =========================================================================== 00040 class OptionsCont; 00041 class RONet; 00042 class ROEdge; 00043 00044 00045 // =========================================================================== 00046 // class definitions 00047 // =========================================================================== 00073 class SAXWeightsHandler : public SUMOSAXHandler { 00074 public: 00079 class EdgeFloatTimeLineRetriever { 00080 public: 00082 EdgeFloatTimeLineRetriever() throw() { } 00083 00085 virtual ~EdgeFloatTimeLineRetriever() throw() { } 00086 00094 virtual void addEdgeWeight(const std::string &id, 00095 SUMOReal val, SUMOReal beg, SUMOReal end) const throw() = 0; 00096 00097 }; 00098 00103 class ToRetrieveDefinition { 00104 public: 00106 ToRetrieveDefinition(const std::string &attributeName, bool edgeBased, 00107 EdgeFloatTimeLineRetriever &destination); 00108 00110 ~ToRetrieveDefinition(); 00111 00112 public: 00114 std::string myAttributeName; 00115 00117 EdgeFloatTimeLineRetriever &myDestination; 00118 00120 bool myAmEdgeBased; 00121 00123 SUMOReal myAggValue; 00124 00126 size_t myNoLanes; 00127 00129 bool myHadAttribute; 00130 00131 private: 00133 ToRetrieveDefinition(const ToRetrieveDefinition&); 00134 00136 ToRetrieveDefinition& operator=(const ToRetrieveDefinition&); 00137 00138 }; 00139 00146 SAXWeightsHandler(const std::vector<ToRetrieveDefinition*> &defs, 00147 const std::string &file); 00148 00149 00155 SAXWeightsHandler(ToRetrieveDefinition *def, 00156 const std::string &file); 00157 00158 00160 ~SAXWeightsHandler() throw(); 00161 00162 00163 protected: 00165 00166 00174 void myStartElement(SumoXMLTag element, 00175 const SUMOSAXAttributes &attrs) throw(ProcessError); 00176 00177 00184 void myEndElement(SumoXMLTag elemente) throw(); 00186 00187 00188 private: 00190 void tryParse(const SUMOSAXAttributes &attrs, bool isEdge); 00191 00192 00193 private: 00195 std::vector<ToRetrieveDefinition*> myDefinitions; 00196 00198 SUMOReal myCurrentTimeBeg; 00199 00201 SUMOReal myCurrentTimeEnd; 00202 00204 std::string myCurrentEdgeID; 00205 00206 00207 private: 00209 SAXWeightsHandler(const SAXWeightsHandler &src); 00210 00212 SAXWeightsHandler &operator=(const SAXWeightsHandler &src); 00213 00214 }; 00215 00216 00217 #endif 00218 00219 /****************************************************************************/ 00220
1.5.6