SUMO - Simulation of Urban MObility
SAXWeightsHandler.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // An XML-handler for network weights
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 SAXWeightsHandler_h
00023 #define SAXWeightsHandler_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 <utils/xml/SUMOSAXHandler.h>
00037 #include <utils/common/SUMOTime.h>
00038 
00039 
00040 // ===========================================================================
00041 // class declarations
00042 // ===========================================================================
00043 class OptionsCont;
00044 class RONet;
00045 class ROEdge;
00046 
00047 
00048 // ===========================================================================
00049 // class definitions
00050 // ===========================================================================
00076 class SAXWeightsHandler : public SUMOSAXHandler {
00077 public:
00082     class EdgeFloatTimeLineRetriever {
00083     public:
00085         EdgeFloatTimeLineRetriever() { }
00086 
00088         virtual ~EdgeFloatTimeLineRetriever() { }
00089 
00097         virtual void addEdgeWeight(const std::string& id,
00098                                    SUMOReal val, SUMOReal beg, SUMOReal end) const = 0;
00099 
00100     private:
00101         EdgeFloatTimeLineRetriever& operator=(const EdgeFloatTimeLineRetriever&); // just to avoid a compiler warning
00102     };
00103 
00108     class ToRetrieveDefinition {
00109     public:
00111         ToRetrieveDefinition(const std::string& attributeName, bool edgeBased,
00112                              EdgeFloatTimeLineRetriever& destination);
00113 
00115         ~ToRetrieveDefinition();
00116 
00117     public:
00119         std::string myAttributeName;
00120 
00122         bool myAmEdgeBased;
00123 
00125         EdgeFloatTimeLineRetriever& myDestination;
00126 
00128         SUMOReal myAggValue;
00129 
00131         size_t myNoLanes;
00132 
00134         bool myHadAttribute;
00135 
00136     private:
00138         ToRetrieveDefinition(const ToRetrieveDefinition&);
00139 
00141         ToRetrieveDefinition& operator=(const ToRetrieveDefinition&);
00142 
00143     };
00144 
00151     SAXWeightsHandler(const std::vector<ToRetrieveDefinition*> &defs,
00152                       const std::string& file);
00153 
00154 
00160     SAXWeightsHandler(ToRetrieveDefinition* def,
00161                       const std::string& file);
00162 
00163 
00165     ~SAXWeightsHandler() ;
00166 
00167 
00168 protected:
00170 
00171 
00179     void myStartElement(int element,
00180                         const SUMOSAXAttributes& attrs) ;
00181 
00182 
00189     void myEndElement(int elemente) ;
00191 
00192 
00193 private:
00195     void tryParse(const SUMOSAXAttributes& attrs, bool isEdge);
00196 
00197 
00198 private:
00200     std::vector<ToRetrieveDefinition*> myDefinitions;
00201 
00203     SUMOReal myCurrentTimeBeg;
00204 
00206     SUMOReal myCurrentTimeEnd;
00207 
00209     std::string myCurrentEdgeID;
00210 
00211 
00212 private:
00214     SAXWeightsHandler(const SAXWeightsHandler& src);
00215 
00217     SAXWeightsHandler& operator=(const SAXWeightsHandler& src);
00218 
00219 };
00220 
00221 
00222 #endif
00223 
00224 /****************************************************************************/
00225 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines