MSEdge.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A road/street connecting two junctions
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 MSEdge_h
00020 #define MSEdge_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 <vector>
00033 #include <map>
00034 #include <string>
00035 #include <iostream>
00036 #include "MSLinkCont.h"
00037 #include <utils/common/SUMOTime.h>
00038 #include <utils/common/SUMOVehicleClass.h>
00039 #include <utils/common/ValueTimeLine.h>
00040 #include <utils/common/UtilExceptions.h>
00041 
00042 
00043 // ===========================================================================
00044 // class declarations
00045 // ===========================================================================
00046 class MSLane;
00047 class MSLaneChanger;
00048 class OutputDevice;
00049 class SUMOVehicle;
00050 
00051 
00052 // ===========================================================================
00053 // class definitions
00054 // ===========================================================================
00062 class MSEdge {
00063 public:
00071     enum EdgeBasicFunction {
00073         EDGEFUNCTION_UNKNOWN = -1,
00075         EDGEFUNCTION_NORMAL = 0,
00077         EDGEFUNCTION_CONNECTOR = 1,
00079         EDGEFUNCTION_INTERNAL = 2,
00081         EDGEFUNCTION_DISTRICT = 3
00082     };
00083 
00084 
00086     typedef std::map< const MSEdge*, std::vector<MSLane*>* > AllowedLanesCont;
00087 
00089     typedef std::map< SUMOVehicleClass, AllowedLanesCont > ClassedAllowedLanesCont;
00090 
00091 
00092 public:
00102     MSEdge(const std::string &id, unsigned int numericalID) throw();
00103 
00104 
00106     virtual ~MSEdge() throw();
00107 
00108 
00116     void initialize(MSLane* departLane, std::vector<MSLane*>* lanes, EdgeBasicFunction function) throw();
00117 
00118 
00120     void closeBuilding();
00121 
00122 
00125 
00132     MSLane * const leftLane(const MSLane * const lane) const throw();
00133 
00134 
00141     MSLane * const rightLane(const MSLane* const lane) const throw();
00142 
00143 
00148     const std::vector<MSLane*> &getLanes() const throw() {
00149         return *myLanes;
00150     }
00151 
00152 
00161     const std::vector<MSLane*>* allowedLanes(const MSEdge& destination,
00162             SUMOVehicleClass vclass=SVC_UNKNOWN) const throw();
00163 
00164 
00172     const std::vector<MSLane*>* allowedLanes(SUMOVehicleClass vclass=SVC_UNKNOWN) const throw();
00174 
00175 
00176 
00179 
00183     const std::string &getID() const throw() {
00184         return myID;
00185     }
00186 
00187 
00192     EdgeBasicFunction getPurpose() const throw() {
00193         return myFunction;
00194     }
00195 
00196 
00200     unsigned int getNumericalID() const throw() {
00201         return myNumericalID;
00202     }
00204 
00205 
00206 
00209 
00213     void addFollower(MSEdge* edge) throw() {
00214         mySuccessors.push_back(edge);
00215     }
00216 
00217 
00221     const std::vector<MSEdge*> &getIncomingEdges() const throw() {
00222         return myPredeccesors;
00223     }
00224 
00225 
00229     unsigned int getNoFollowing() const throw() {
00230         return (unsigned int) mySuccessors.size();
00231     }
00232 
00237     const MSEdge * const getFollower(unsigned int n) const throw() {
00238         return mySuccessors[n];
00239     }
00241 
00242 
00243 
00246 
00250     bool isVaporizing() const throw() {
00251         return myVaporizationRequests>0;
00252     }
00253 
00254 
00264     SUMOTime incVaporization(SUMOTime t) throw(ProcessError);
00265 
00266 
00276     SUMOTime decVaporization(SUMOTime t) throw(ProcessError);
00278 
00279 
00288     SUMOReal getCurrentTravelTime() const throw();
00289 
00290 
00291 
00294 
00308     bool emit(MSVehicle &v, SUMOTime time) const throw(ProcessError);
00309 
00310 
00321     MSLane* getFreeLane(const SUMOVehicleClass vclass) const throw();
00322 
00323 
00335     MSLane* getDepartLane(const MSVehicle &v) const throw();
00336 
00337 
00341     inline SUMOTime getLastFailedEmissionTime() const throw() {
00342         return myLastFailedEmissionTime;
00343     }
00344 
00345 
00349     inline void setLastFailedEmissionTime(SUMOTime time) const throw() {
00350         myLastFailedEmissionTime = time;
00351     }
00353 
00354 
00356     virtual void changeLanes(SUMOTime t) throw();
00357 
00358 
00359 #ifdef HAVE_INTERNAL_LANES
00361     const MSEdge *getInternalFollowingEdge(MSEdge *followerAfterInternal) const throw();
00362 #endif
00363 
00365     bool prohibits(const SUMOVehicle * const vehicle) const throw();
00366 
00367     void rebuildAllowedLanes() throw();
00368 
00369 
00370 
00374     static bool dictionary(const std::string &id, MSEdge* edge) throw();
00375 
00377     static MSEdge* dictionary(const std::string &id) throw();
00378 
00380     static MSEdge* dictionary(size_t index) throw();
00381 
00383     static size_t dictSize() throw();
00384 
00386     static void clear() throw();
00387 
00389     static void insertIDs(std::vector<std::string> &into) throw();
00390 
00391 
00392 public:
00395 
00404     static void parseEdgesList(const std::string &desc, std::vector<const MSEdge*> &into,
00405                                const std::string &rid) throw(ProcessError);
00406 
00407 
00414     static void parseEdgesList(const std::vector<std::string> &desc, std::vector<const MSEdge*> &into,
00415                                const std::string &rid) throw(ProcessError);
00417 
00418 
00419 protected:
00423     class by_id_sorter {
00424     public:
00426         explicit by_id_sorter() { }
00427 
00429         int operator()(const MSEdge * const e1, const MSEdge * const e2) const {
00430             return e1->getID()<e2->getID();
00431         }
00432 
00433     };
00434 
00435 
00444     const std::vector<MSLane*>* allowedLanes(const MSEdge *destination,
00445             SUMOVehicleClass vclass=SVC_UNKNOWN) const throw();
00446 
00447 protected:
00449     std::string myID;
00450 
00452     unsigned int myNumericalID;
00453 
00455     std::vector<MSLane*>* myLanes;
00456 
00458     MSLane* myDepartLane;
00459 
00461     MSLaneChanger* myLaneChanger;
00462 
00464     EdgeBasicFunction myFunction;
00465 
00467     int myVaporizationRequests;
00468 
00470     mutable SUMOTime myLastFailedEmissionTime;
00471 
00473     std::vector<MSEdge*> mySuccessors;
00474 
00476     std::vector<MSEdge*> myPredeccesors;
00477 
00478 
00479 
00482 
00484     AllowedLanesCont myAllowed;
00485 
00487     ClassedAllowedLanesCont myClassedAllowed;
00488 
00490     bool myHaveClassConstraints;
00492 
00493 
00494 
00497 
00499     typedef std::map< std::string, MSEdge* > DictType;
00500 
00504     static DictType myDict;
00505 
00509     static std::vector<MSEdge*> myEdges;
00511 
00512 
00513 
00514 private:
00516     MSEdge(const MSEdge&);
00517 
00519     MSEdge& operator=(const MSEdge&);
00520 
00521 };
00522 
00523 
00524 #endif
00525 
00526 /****************************************************************************/
00527 

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