00001 /****************************************************************************/ 00007 // The base class for an intersection 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 MSJunction_h 00020 #define MSJunction_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 <vector> 00034 #include <map> 00035 #include <utils/geom/Position2D.h> 00036 #include <utils/geom/Position2DVector.h> 00037 #include <utils/common/SUMOTime.h> 00038 #include <utils/common/UtilExceptions.h> 00039 00040 00041 class MSVehicle; 00042 class MSLink; 00043 class MSLane; 00044 00045 // =========================================================================== 00046 // class definitions 00047 // =========================================================================== 00052 class MSJunction { 00053 public: 00054 struct ApproachingVehicleInformation { 00055 ApproachingVehicleInformation(SUMOReal _arrivalTime, SUMOReal _leavingTime, MSVehicle *_vehicle) 00056 : arrivalTime(_arrivalTime), leavingTime(_leavingTime), vehicle(_vehicle) {} 00057 SUMOReal arrivalTime; 00058 SUMOReal leavingTime; 00059 MSVehicle *vehicle; 00060 }; 00061 00062 typedef std::vector<ApproachingVehicleInformation> LinkApproachingVehicles; 00063 00064 class vehicle_in_request_finder { 00065 public: 00066 explicit vehicle_in_request_finder(const MSVehicle * const v) : myVehicle(v) { } 00067 bool operator()(const ApproachingVehicleInformation &vo) { 00068 return vo.vehicle == myVehicle; 00069 } 00070 private: 00071 const MSVehicle * const myVehicle; 00072 00073 }; 00074 00075 00076 00078 virtual ~MSJunction(); 00079 00085 MSJunction(const std::string &id, const Position2D &position, 00086 const Position2DVector &shape) throw(); 00087 00090 virtual void postloadInit() throw(ProcessError); 00091 00094 virtual bool clearRequests() = 0; 00095 00097 virtual bool setAllowed() = 0; 00098 00100 const Position2D &getPosition() const; 00101 00103 const std::string &getID() const; 00104 00108 const Position2DVector &getShape() const throw() { 00109 return myShape; 00110 } 00111 00112 virtual const std::vector<MSLink*> &getFoeLinks(const MSLink *const srcLink) const throw() { 00113 return myEmptyLinks; 00114 } 00115 00116 virtual const std::vector<MSLane*> &getFoeInternalLanes(const MSLink *const srcLink) const throw() { 00117 return myEmptyLanes; 00118 } 00119 00120 protected: 00122 std::string myID; 00123 00125 Position2D myPosition; 00126 00128 Position2DVector myShape; 00129 00130 std::vector<MSLink*> myEmptyLinks; 00131 std::vector<MSLane*> myEmptyLanes; 00132 00133 00134 00135 00136 private: 00138 MSJunction(const MSJunction&); 00139 00141 MSJunction& operator=(const MSJunction&); 00142 00143 }; 00144 00145 00146 #endif 00147 00148 /****************************************************************************/ 00149
1.5.6