|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // This class computes the logic of a junction 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef NBRequest_h 00024 #define NBRequest_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <string> 00037 #include <vector> 00038 #include <map> 00039 #include <bitset> 00040 #include "NBConnectionDefs.h" 00041 #include "NBContHelper.h" 00042 #include <utils/common/UtilExceptions.h> 00043 00044 00045 // =========================================================================== 00046 // class declarations 00047 // =========================================================================== 00048 class NBEdge; 00049 class NBJunctionTypeIO; 00050 class NBTrafficLightLogic; 00051 class OptionsCont; 00052 class NBTrafficLightDefinition; 00053 class NBEdgeCont; 00054 class OutputDevice; 00055 00056 00057 // =========================================================================== 00058 // class definitions 00059 // =========================================================================== 00066 class NBRequest { 00067 public: 00073 NBRequest(const NBEdgeCont& ec, 00074 NBNode* junction, 00075 const EdgeVector& all, 00076 const EdgeVector& incoming, 00077 const EdgeVector& outgoing, 00078 const NBConnectionProhibits& loadedProhibits); 00079 00081 ~NBRequest(); 00082 00084 void buildBitfieldLogic(bool leftHanded); 00085 00088 std::pair<unsigned int, unsigned int> getSizes() const; 00089 00097 bool mustBrake(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo, 00098 const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo) const ; 00099 00100 00106 bool mustBrake(const NBEdge* const from, const NBEdge* const to) const ; // !!! 00107 00115 bool foes(const NBEdge* const from1, const NBEdge* const to1, 00116 const NBEdge* const from2, const NBEdge* const to2) const ; 00117 00118 00127 bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo, 00128 const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo, 00129 bool regardNonSignalisedLowerPriority) const ; 00130 00133 void writeLogic(std::string key, OutputDevice& into) const; 00134 00136 friend std::ostream& operator<<(std::ostream& os, const NBRequest& r); 00137 00139 static void reportWarnings(); 00140 00141 00142 private: 00145 void setBlocking(bool leftHanded, NBEdge* from1, NBEdge* to1, NBEdge* from2, NBEdge* to2); 00146 00149 int writeLaneResponse(OutputDevice& od, NBEdge* from, int lane, 00150 int pos) const; 00151 00170 void writeResponse(OutputDevice& od, const NBEdge* const from, const NBEdge* const to, 00171 int fromLane, int toLane, bool mayDefinitelyPass) const; 00172 00173 00175 void writeAreFoes(OutputDevice& od, NBEdge* from, NBEdge* to, 00176 bool isInnerEnd) const; 00177 00178 00187 int getIndex(const NBEdge* const from, const NBEdge* const to) const ; 00188 00189 00192 size_t distanceCounterClockwise(NBEdge* from, NBEdge* to); 00193 00196 void computeRightOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to); 00197 00200 void computeLeftOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to); 00201 00202 00203 void resetSignalised(); 00204 00205 private: 00207 NBNode* myJunction; 00208 00210 const EdgeVector& myAll; 00211 00213 const EdgeVector& myIncoming; 00214 00216 const EdgeVector& myOutgoing; 00217 00220 typedef std::vector<bool> LinkInfoCont; 00221 00224 typedef std::vector<LinkInfoCont> CombinationsCont; 00225 00227 typedef std::map<NBEdge*, LaneVector> OccupiedLanes; 00228 00230 CombinationsCont myForbids; 00231 00233 CombinationsCont myDone; 00234 00235 private: 00236 static size_t myGoodBuilds, myNotBuild; 00237 00238 }; 00239 00240 00241 #endif 00242 00243 /****************************************************************************/ 00244