MSLink.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSLink_h
00020 #define MSLink_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include "MSLogicJunction.h"
00033
00034
00035
00036
00037
00038 class MSVehicle;
00039 class MSTrafficLightLogic;
00040
00041
00042
00043
00044
00068 class MSLink {
00069 public:
00078 enum LinkState {
00080 LINKSTATE_TL_GREEN_MAJOR = 'G',
00082 LINKSTATE_TL_GREEN_MINOR = 'g',
00084 LINKSTATE_TL_RED = 'r',
00086 LINKSTATE_TL_YELLOW_MAJOR = 'Y',
00088 LINKSTATE_TL_YELLOW_MINOR = 'y',
00090 LINKSTATE_TL_OFF_BLINKING = 'b',
00092 LINKSTATE_TL_OFF_NOSIGNAL = 'O',
00094 LINKSTATE_MAJOR = 'M',
00096 LINKSTATE_MINOR = 'm',
00098 LINKSTATE_EQUAL = '=',
00100 LINKSTATE_DEADEND = '-'
00101 };
00102
00103
00108 enum LinkDirection {
00110 LINKDIR_STRAIGHT = 0,
00112 LINKDIR_TURN,
00114 LINKDIR_LEFT,
00116 LINKDIR_RIGHT,
00118 LINKDIR_PARTLEFT,
00120 LINKDIR_PARTRIGHT,
00122 LINKDIR_NODIR
00123 };
00124
00125
00126 #ifndef HAVE_INTERNAL_LANES
00127
00134 MSLink(MSLane* succLane,
00135 bool yield, LinkDirection dir, LinkState state, SUMOReal length) throw();
00136 #else
00137
00146 MSLink(MSLane* succLane, MSLane *via,
00147 bool yield, LinkDirection dir, LinkState state, bool internalEnd,
00148 SUMOReal length) throw();
00149 #endif
00150
00152 ~MSLink() throw();
00153
00154
00168 void setRequestInformation(MSLogicJunction::Request *request, unsigned int requestIdx,
00169 MSLogicJunction::Respond *respond, unsigned int respondIdx,
00170 const MSLogicJunction::LinkFoes &foes, bool isCrossing, bool isCont,
00171 const std::vector<MSLink*> &foeLinks, const std::vector<MSLane*> &foeLanes) throw();
00172
00173
00181 void setApproaching(MSVehicle *approaching, SUMOTime arrivalTime, SUMOReal speed) throw();
00182
00183 void removeApproaching(MSVehicle *veh);
00184
00192 MSVehicle *getApproaching() const throw() {
00193 return myApproaching;
00194 };
00195
00196
00203 void setPriority(bool prio) throw();
00204
00205
00212 bool opened(SUMOTime arrivalTime, SUMOReal arrivalSpeed) const throw();
00213
00214 bool blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime) const throw();
00215
00216
00223 bool hasApproachingFoe(SUMOTime arrivalTime, SUMOTime leaveTime) const throw();
00224
00225
00230 void deleteRequest() throw();
00231
00232
00237 LinkState getState() const throw() {
00238 return myState;
00239 }
00240
00241
00246 LinkDirection getDirection() const throw();
00247
00248
00253 void setTLState(LinkState state) throw();
00254
00255
00260 MSLane *getLane() const throw();
00261
00262
00267 unsigned int getRespondIndex() const throw();
00268
00269
00274 bool havePriority() const throw() {
00275 return myPrio;
00276 }
00277
00278
00283 SUMOReal getLength() const throw() {
00284 return myLength;
00285 }
00286
00291 bool isCrossing() const throw() {
00292 return myIsCrossing;
00293 }
00294
00295
00296 #ifdef HAVE_INTERNAL_LANES
00297
00301 MSLane * const getViaLane() const throw();
00302
00303
00310 void resetInternalPriority() throw();
00311
00312 #endif
00313
00314 private:
00316 MSLane* myLane;
00317
00319 bool myPrio;
00320
00322 MSVehicle *myApproaching;
00323
00325 MSLogicJunction::Request *myRequest;
00326 MSJunction::LinkApproachingVehicles myApproachingVehicles;
00327
00329 unsigned int myRequestIdx;
00330
00332 MSLogicJunction::Respond *myRespond;
00333
00335 unsigned int myRespondIdx;
00336
00338 LinkState myState;
00339
00341 LinkDirection myDirection;
00342
00344 SUMOReal myLength;
00345
00347 MSLogicJunction::LinkFoes myFoes;
00348
00350 bool myIsCrossing;
00351
00352 bool myAmCont;
00353
00354 #ifdef HAVE_INTERNAL_LANES
00356 MSLane * const myJunctionInlane;
00357
00359 bool myIsInternalEnd;
00360 #endif
00361
00362 std::vector<MSLink*> myFoeLinks;
00363 std::vector<MSLane*> myFoeLanes;
00364
00365
00366 private:
00368 MSLink(const MSLink &s);
00369
00371 MSLink &operator=(const MSLink &s);
00372
00373 };
00374
00375
00376 #endif
00377
00378
00379