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.sourceforge.net/
13 // Copyright (C) 2001-2013 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 
115  bool foes(const NBEdge* const from1, const NBEdge* const to1,
116  const NBEdge* const from2, const NBEdge* const to2) const;
117 
118 
127  bool forbids(const NBEdge* const possProhibitorFrom, const NBEdge* const possProhibitorTo,
128  const NBEdge* const possProhibitedFrom, const NBEdge* const possProhibitedTo,
129  bool regardNonSignalisedLowerPriority) const;
130 
133  void writeLogic(std::string key, OutputDevice& into) const;
134 
136  friend std::ostream& operator<<(std::ostream& os, const NBRequest& r);
137 
139  static void reportWarnings();
140 
141 
142 private:
145  void setBlocking(bool leftHanded, NBEdge* from1, NBEdge* to1, NBEdge* from2, NBEdge* to2);
146 
149  int writeLaneResponse(OutputDevice& od, NBEdge* from, int lane,
150  int pos) const;
151 
170  std::string getResponseString(const NBEdge* const from, const NBEdge* const to,
171  int fromLane, bool mayDefinitelyPass) const;
172 
173 
175  std::string getFoesString(NBEdge* from, NBEdge* to) const;
176 
177 
186  int getIndex(const NBEdge* const from, const NBEdge* const to) const;
187 
188 
191  size_t distanceCounterClockwise(NBEdge* from, NBEdge* to);
192 
195  void computeRightOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to);
196 
199  void computeLeftOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to);
200 
201 
202  void resetSignalised();
203 
204 
206  void resetCooperating();
207 
208 private:
211 
214 
217 
220 
223  typedef std::vector<bool> LinkInfoCont;
224 
227  typedef std::vector<LinkInfoCont> CombinationsCont;
228 
230  typedef std::map<NBEdge*, LaneVector> OccupiedLanes;
231 
234 
237 
238 private:
239  static size_t myGoodBuilds, myNotBuild;
240 
241 private:
243  NBRequest& operator=(const NBRequest& s);
244 };
245 
246 #endif
247 
248 /****************************************************************************/
249