NLHandler.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // The XML-Handler for network loading
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 NLHandler_h
00020 #define NLHandler_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 <xercesc/sax/HandlerBase.hpp>
00033 #include <xercesc/sax/SAXException.hpp>
00034 #include <xercesc/sax/AttributeList.hpp>
00035 #include "NLBuilder.h"
00036 #include "NLDiscreteEventBuilder.h"
00037 #include "NLSucceedingLaneBuilder.h"
00038 #include <microsim/MSLink.h>
00039 #include <microsim/MSRouteHandler.h>
00040 #include <microsim/traffic_lights/MSSimpleTrafficLightLogic.h>
00041 #include <microsim/traffic_lights/MSActuatedTrafficLightLogic.h>
00042 #include <microsim/MSBitSetLogic.h>
00043 #include <utils/common/SUMOTime.h>
00044 
00045 
00046 // ===========================================================================
00047 // class declarations
00048 // ===========================================================================
00049 class NLContainer;
00050 class NLDetectorBuilder;
00051 class NLTriggerBuilder;
00052 class MSTrafficLightLogic;
00053 class NLGeomShapeBuilder;
00054 
00055 
00056 // ===========================================================================
00057 // class definitions
00058 // ===========================================================================
00067 class NLHandler : public MSRouteHandler {
00068 public:
00070     typedef std::vector<MSLane*> LaneVector;
00071 
00072 public:
00083     NLHandler(const std::string &file, MSNet &net,
00084               NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder,
00085               NLEdgeControlBuilder &edgeBuilder,
00086               NLJunctionControlBuilder &junctionBuilder,
00087               NLGeomShapeBuilder &shapeBuilder) throw();
00088 
00089 
00091     virtual ~NLHandler() throw();
00092 
00093 
00094 protected:
00096 
00097 
00106     virtual void myStartElement(SumoXMLTag element,
00107                                 const SUMOSAXAttributes &attrs) throw(ProcessError);
00108 
00109 
00118     virtual void myCharacters(SumoXMLTag element,
00119                               const std::string &chars) throw(ProcessError);
00120 
00121 
00129     virtual void myEndElement(SumoXMLTag element) throw(ProcessError);
00131 
00132 
00133 protected:
00134     void addParam(const SUMOSAXAttributes &attrs);
00135 
00139     virtual void addDetector(const SUMOSAXAttributes &attrs);
00140 
00141 
00145     virtual void addE1Detector(const SUMOSAXAttributes &attrs);
00146 
00150     virtual void addE2Detector(const SUMOSAXAttributes &attrs);
00151 
00152 #ifdef _MESSAGES
00153 
00156     virtual void addMsgDetector(const SUMOSAXAttributes &attrs);
00157 #endif
00158 
00162     void beginE3Detector(const SUMOSAXAttributes &attrs);
00163 
00167     void addE3Entry(const SUMOSAXAttributes &attrs);
00168 
00172     void addE3Exit(const SUMOSAXAttributes &attrs);
00173 
00175     virtual void endE3Detector();
00176 
00180     virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs);
00181 
00185     virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs);
00186 
00190     virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, const char* objecttype);
00191 
00195     void endDetector();
00196 
00198     virtual void closeEdge();
00199 
00201     virtual void closeLane();
00202 
00203 
00204 protected:
00206     MSNet &myNet;
00207 
00208 
00209 private:
00211     void addLaneShape(const std::string &chars);
00212 
00214     void beginEdgeParsing(const SUMOSAXAttributes &attrs);
00215 
00217     void addLane(const SUMOSAXAttributes &attrs);
00218 
00220     void addPOI(const SUMOSAXAttributes &attrs);
00221 
00223     void addPoly(const SUMOSAXAttributes &attrs);
00224 
00226     void addLogicItem(const SUMOSAXAttributes &attrs);
00227 
00229     void initJunctionLogic(const SUMOSAXAttributes &attrs);
00230 
00232     void initTrafficLightLogic(const SUMOSAXAttributes &attrs);
00233 
00235     void addPhase(const SUMOSAXAttributes &attrs);
00236 
00237 
00239     virtual void openJunction(const SUMOSAXAttributes &attrs);
00240 
00242     virtual void addSource(const SUMOSAXAttributes &attrs);
00243 
00244 #ifdef _MESSAGES
00246     void addMsgEmitter(const SUMOSAXAttributes &attrs);
00247 #endif
00248 
00250     void addTrigger(const SUMOSAXAttributes &attrs);
00251 
00253     void openSucc(const SUMOSAXAttributes &attrs);
00254 
00256     void addSuccLane(const SUMOSAXAttributes &attrs);
00257 
00258 
00260     void addIncomingLanes(const std::string &chars);
00261 
00263     void addIncomingPolyPosititon(const std::string &chars);
00264 
00265 #ifdef HAVE_INTERNAL_LANES
00267     void addInternalLanes(const std::string &chars);
00268 #endif
00269 
00271     void addJunctionShape(const std::string &chars);
00272 
00273 
00274     virtual void openWAUT(const SUMOSAXAttributes &attrs);
00275     void addWAUTSwitch(const SUMOSAXAttributes &attrs);
00276     void addWAUTJunction(const SUMOSAXAttributes &attrs);
00277 
00279     void setLocation(const SUMOSAXAttributes &attrs);
00280 
00290     void addDistrict(const SUMOSAXAttributes &attrs) throw(ProcessError);
00291 
00292 
00303     void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource);
00304 
00305 
00307     void setRequestSize(const std::string &chars);
00308 
00310     void setLaneNumber(const std::string &chars);
00311 
00313     void setKey(const std::string &chars);
00314 
00316     void setSubKey(const std::string &chars);
00317 
00319     void setOffset(const std::string &chars);
00320 
00321 
00322 
00323 
00325     virtual void closeJunction();
00326 
00327     void closeWAUT();
00328 
00330     void closeSuccLane();
00331 
00333     MSLink::LinkDirection parseLinkDir(char dir);
00334 
00336     MSLink::LinkState parseLinkState(char state);
00337 
00338 
00339 protected:
00341     NLDiscreteEventBuilder myActionBuilder;
00342 
00344     bool myCurrentIsInternalToSkip;
00345 
00347     NLDetectorBuilder &myDetectorBuilder;
00348 
00350     std::string myCurrentDetectorType;
00351 
00353     NLTriggerBuilder &myTriggerBuilder;
00354 
00356     NLEdgeControlBuilder &myEdgeControlBuilder;
00357 
00359     NLJunctionControlBuilder &myJunctionControlBuilder;
00360 
00361     NLGeomShapeBuilder &myShapeBuilder;
00362 
00364     NLSucceedingLaneBuilder mySucceedingLaneBuilder;
00365 
00366 
00368 
00369 
00371     std::string myCurrentLaneID;
00372 
00374     std::string myCurrentDistrictID;
00375 
00377     bool myLaneIsDepart;
00378 
00380     SUMOReal myCurrentMaxSpeed;
00381 
00383     SUMOReal myCurrentLength;
00384 
00386     std::vector<SUMOVehicleClass> myAllowedClasses;
00387 
00389     std::vector<SUMOVehicleClass> myDisallowedClasses;
00390 
00392     Position2DVector myShape;
00394 
00396     bool myAmInTLLogicMode;
00397 
00399     std::string myCurrentWAUTID;
00400 
00402     Position2D myNetworkOffset;
00403 
00405     Boundary myOrigBoundary, myConvBoundary;
00406 
00407     bool myCurrentIsBroken;
00408 
00410     bool myHaveWarnedAboutDeprecatedVClass;
00411 
00413     bool myHaveWarnedAboutDeprecatedJunctionShape;
00414 
00416     bool myHaveWarnedAboutDeprecatedLaneShape;
00417 
00419     bool myHaveWarnedAboutDeprecatedPolyShape;
00420 
00422     bool myHaveWarnedAboutDeprecatedLocation;
00423 
00425     bool myHaveWarnedAboutDeprecatedPhases;
00426 
00427 private:
00429     NLHandler(const NLHandler &s);
00430 
00432     NLHandler &operator=(const NLHandler &s);
00433 
00434 };
00435 
00436 
00437 #endif
00438 
00439 /****************************************************************************/
00440 

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