|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // This class computes the logic of a junction 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 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 NBRequest_h 00020 #define NBRequest_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 <bitset> 00036 #include "NBConnectionDefs.h" 00037 #include "NBContHelper.h" 00038 #include <utils/common/UtilExceptions.h> 00039 00040 00041 // =========================================================================== 00042 // class declarations 00043 // =========================================================================== 00044 class NBEdge; 00045 class NBJunctionTypeIO; 00046 class NBTrafficLightLogic; 00047 class OptionsCont; 00048 class NBTrafficLightDefinition; 00049 class NBEdgeCont; 00050 class OutputDevice; 00051 00052 00053 // =========================================================================== 00054 // class definitions 00055 // =========================================================================== 00062 class NBRequest { 00063 public: 00069 NBRequest(const NBEdgeCont& ec, 00070 NBNode* junction, 00071 const EdgeVector& all, 00072 const EdgeVector& incoming, 00073 const EdgeVector& outgoing, 00074 const NBConnectionProhibits& loadedProhibits); 00075 00077 ~NBRequest(); 00078 00080 void buildBitfieldLogic(bool leftHanded); 00081 00084 std::pair<unsigned int, unsigned int> getSizes() const; 00085 00093 bool mustBrake(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo, 00094 const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo) const throw(); 00095 00096 00102 bool mustBrake(const NBEdge* const from, const NBEdge* const to) const throw(); // !!! 00103 00111 bool foes(const NBEdge* const from1, const NBEdge* const to1, 00112 const NBEdge* const from2, const NBEdge* const to2) const throw(); 00113 00114 00123 bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo, 00124 const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo, 00125 bool regardNonSignalisedLowerPriority) const throw(); 00126 00129 void writeLogic(std::string key, OutputDevice& into) const; 00130 00132 friend std::ostream& operator<<(std::ostream& os, const NBRequest& r); 00133 00135 static void reportWarnings(); 00136 00137 00138 private: 00141 void setBlocking(bool leftHanded, NBEdge* from1, NBEdge* to1, NBEdge* from2, NBEdge* to2); 00142 00145 int writeLaneResponse(OutputDevice& od, NBEdge* from, int lane, 00146 int pos) const; 00147 00166 void writeResponse(OutputDevice& od, const NBEdge* const from, const NBEdge* const to, 00167 int fromLane, int toLane, bool mayDefinitelyPass) const throw(IOError); 00168 00169 00171 void writeAreFoes(OutputDevice& od, NBEdge* from, NBEdge* to, 00172 bool isInnerEnd) const; 00173 00174 00183 int getIndex(const NBEdge* const from, const NBEdge* const to) const throw(); 00184 00185 00188 size_t distanceCounterClockwise(NBEdge* from, NBEdge* to); 00189 00192 void computeRightOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to); 00193 00196 void computeLeftOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to); 00197 00198 00199 void resetSignalised(); 00200 00201 private: 00203 NBNode* myJunction; 00204 00206 const EdgeVector& myAll; 00207 00209 const EdgeVector& myIncoming; 00210 00212 const EdgeVector& myOutgoing; 00213 00216 typedef std::vector<bool> LinkInfoCont; 00217 00220 typedef std::vector<LinkInfoCont> CombinationsCont; 00221 00223 typedef std::map<NBEdge*, LaneVector> OccupiedLanes; 00224 00226 CombinationsCont myForbids; 00227 00229 CombinationsCont myDone; 00230 00231 private: 00232 static size_t myGoodBuilds, myNotBuild; 00233 00234 }; 00235 00236 00237 #endif 00238 00239 /****************************************************************************/ 00240