SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBRequest.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // This class computes the logic of a junction
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef NBRequest_h
24 #define NBRequest_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
38 #include <map>
39 #include <bitset>
40 #include "NBConnectionDefs.h"
41 #include "NBContHelper.h"
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class NBEdge;
49 class NBJunctionTypeIO;
51 class OptionsCont;
53 class NBEdgeCont;
54 class OutputDevice;
55 
56 
57 // ===========================================================================
58 // class definitions
59 // ===========================================================================
66 class NBRequest {
67 public:
73  NBRequest(const NBEdgeCont& ec,
74  NBNode* junction,
75  const EdgeVector& all,
76  const EdgeVector& incoming,
77  const EdgeVector& outgoing,
78  const NBConnectionProhibits& loadedProhibits);
79 
81  ~NBRequest();
82 
84  void buildBitfieldLogic(bool leftHanded);
85 
88  std::pair<unsigned int, unsigned int> getSizes() const;
89 
97  bool mustBrake(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
98  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo) const;
99 
100 
106  bool mustBrake(const NBEdge* const from, const NBEdge* const to) const; // !!!
107 
114  bool mustBrakeForCrossing(const NBEdge* const from, const NBEdge* const to, const NBNode::Crossing& crossing) const;
115 
123  bool foes(const NBEdge* const from1, const NBEdge* const to1,
124  const NBEdge* const from2, const NBEdge* const to2) const;
125 
126 
135  bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
136  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
137  bool regardNonSignalisedLowerPriority) const;
138 
141  void writeLogic(std::string key, OutputDevice& into, const bool checkLaneFoes) const;
142 
144  friend std::ostream& operator<<(std::ostream& os, const NBRequest& r);
145 
147  static void reportWarnings();
148 
149 
150 private:
153  void setBlocking(bool leftHanded, NBEdge* from1, NBEdge* to1, NBEdge* from2, NBEdge* to2);
154 
157  int writeLaneResponse(OutputDevice& od, NBEdge* from, int lane,
158  int pos, const bool checkLaneFoes) const;
159 
162  int writeCrossingResponse(OutputDevice& od, const NBNode::Crossing& crossing, int pos) const;
163 
182  std::string getResponseString(const NBEdge* const from, const NBEdge* const to,
183  int fromLane, int toLane, bool mayDefinitelyPass, const bool checkLaneFoes) const;
184 
185 
187  std::string getFoesString(NBEdge* from, NBEdge* to,
188  int fromLane, int toLane, const bool checkLaneFoes) const;
189 
190 
199  int getIndex(const NBEdge* const from, const NBEdge* const to) const;
200 
201 
204  size_t distanceCounterClockwise(NBEdge* from, NBEdge* to);
205 
208  void computeRightOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to);
209 
212  void computeLeftOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to);
213 
214 
215  void resetSignalised();
216 
217 
219  void resetCooperating();
220 
224  bool laneConflict(const NBEdge* from, const NBEdge* to, int toLane, const NBEdge* prohibitorFrom, const NBEdge* prohibitorTo, int prohibitorToLane) const;
225 
228  bool rightTurnConflict(const NBEdge* from, const NBEdge* to, int fromLane, const NBEdge* prohibitorFrom, const NBEdge* prohibitorTo, int prohibitorFromLane) const;
229 
231  inline size_t numLinks() const;
232 
233 
234 private:
237 
240 
243 
246 
248  const std::vector<NBNode::Crossing>& myCrossings;
249 
252  typedef std::vector<bool> LinkInfoCont;
253 
256  typedef std::vector<LinkInfoCont> CombinationsCont;
257 
259  typedef std::map<NBEdge*, LaneVector> OccupiedLanes;
260 
263 
266 
267 private:
268  static size_t myGoodBuilds, myNotBuild;
269 
270 private:
272  NBRequest& operator=(const NBRequest& s);
273 };
274 
275 #endif
276 
277 /****************************************************************************/
278