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 std::string getResponseString(const NBEdge* const from, const NBEdge* const to, 00171 int fromLane, bool mayDefinitelyPass) const; 00172 00173 00175 std::string getFoesString(NBEdge* from, NBEdge* to) const; 00176 00177 00186 int getIndex(const NBEdge* const from, const NBEdge* const to) const ; 00187 00188 00191 size_t distanceCounterClockwise(NBEdge* from, NBEdge* to); 00192 00195 void computeRightOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to); 00196 00199 void computeLeftOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to); 00200 00201 00202 void resetSignalised(); 00203 00204 private: 00206 NBNode* myJunction; 00207 00209 const EdgeVector& myAll; 00210 00212 const EdgeVector& myIncoming; 00213 00215 const EdgeVector& myOutgoing; 00216 00219 typedef std::vector<bool> LinkInfoCont; 00220 00223 typedef std::vector<LinkInfoCont> CombinationsCont; 00224 00226 typedef std::map<NBEdge*, LaneVector> OccupiedLanes; 00227 00229 CombinationsCont myForbids; 00230 00232 CombinationsCont myDone; 00233 00234 private: 00235 static size_t myGoodBuilds, myNotBuild; 00236 00237 }; 00238 00239 00240 #endif 00241 00242 /****************************************************************************/ 00243