SUMO - Simulation of Urban MObility

SAXWeightsHandler.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // An XML-handler for network weights
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 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     private:
00098         EdgeFloatTimeLineRetriever& operator=(const EdgeFloatTimeLineRetriever&); // just to avoid a compiler warning
00099     };
00100 
00105     class ToRetrieveDefinition {
00106     public:
00108         ToRetrieveDefinition(const std::string& attributeName, bool edgeBased,
00109                              EdgeFloatTimeLineRetriever& destination);
00110 
00112         ~ToRetrieveDefinition();
00113 
00114     public:
00116         std::string myAttributeName;
00117 
00119         bool myAmEdgeBased;
00120 
00122         EdgeFloatTimeLineRetriever& myDestination;
00123 
00125         SUMOReal myAggValue;
00126 
00128         size_t myNoLanes;
00129 
00131         bool myHadAttribute;
00132 
00133     private:
00135         ToRetrieveDefinition(const ToRetrieveDefinition&);
00136 
00138         ToRetrieveDefinition& operator=(const ToRetrieveDefinition&);
00139 
00140     };
00141 
00148     SAXWeightsHandler(const std::vector<ToRetrieveDefinition*> &defs,
00149                       const std::string& file);
00150 
00151 
00157     SAXWeightsHandler(ToRetrieveDefinition* def,
00158                       const std::string& file);
00159 
00160 
00162     ~SAXWeightsHandler() throw();
00163 
00164 
00165 protected:
00167 
00168 
00176     void myStartElement(int element,
00177                         const SUMOSAXAttributes& attrs) throw(ProcessError);
00178 
00179 
00186     void myEndElement(int elemente) throw();
00188 
00189 
00190 private:
00192     void tryParse(const SUMOSAXAttributes& attrs, bool isEdge);
00193 
00194 
00195 private:
00197     std::vector<ToRetrieveDefinition*> myDefinitions;
00198 
00200     SUMOReal myCurrentTimeBeg;
00201 
00203     SUMOReal myCurrentTimeEnd;
00204 
00206     std::string myCurrentEdgeID;
00207 
00208 
00209 private:
00211     SAXWeightsHandler(const SAXWeightsHandler& src);
00212 
00214     SAXWeightsHandler& operator=(const SAXWeightsHandler& src);
00215 
00216 };
00217 
00218 
00219 #endif
00220 
00221 /****************************************************************************/
00222 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines