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 
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 bool checkLaneFoes) 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 bool checkLaneFoes) const;
151 
170  std::string getResponseString(const NBEdge* const from, const NBEdge* const to,
171  int fromLane, int toLane, bool mayDefinitelyPass, const bool checkLaneFoes) const;
172 
173 
175  std::string getFoesString(NBEdge* from, NBEdge* to,
176  int fromLane, int toLane, const bool checkLaneFoes) const;
177 
178 
187  int getIndex(const NBEdge* const from, const NBEdge* const to) const;
188 
189 
192  size_t distanceCounterClockwise(NBEdge* from, NBEdge* to);
193 
196  void computeRightOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to);
197 
200  void computeLeftOutgoingLinkCrossings(bool leftHanded, NBEdge* from, NBEdge* to);
201 
202 
203  void resetSignalised();
204 
205 
207  void resetCooperating();
208 
212  bool laneConflict(const NBEdge* from, const NBEdge* to, int toLane, const NBEdge* prohibitorFrom, const NBEdge* prohibitorTo, int prohibitorToLane) const;
213 
216  bool rightTurnConflict(const NBEdge* from, const NBEdge* to, int fromLane, const NBEdge* prohibitorFrom, const NBEdge* prohibitorTo, int prohibitorFromLane) const;
217 
218 private:
221 
224 
227 
230 
233  typedef std::vector<bool> LinkInfoCont;
234 
237  typedef std::vector<LinkInfoCont> CombinationsCont;
238 
240  typedef std::map<NBEdge*, LaneVector> OccupiedLanes;
241 
244 
247 
248 private:
249  static size_t myGoodBuilds, myNotBuild;
250 
251 private:
253  NBRequest& operator=(const NBRequest& s);
254 };
255 
256 #endif
257 
258 /****************************************************************************/
259 
int getIndex(const NBEdge *const from, const NBEdge *const to) const
Returns the index to the internal combination container for the given edge combination.
Definition: NBRequest.cpp:611
void computeLeftOutgoingLinkCrossings(bool leftHanded, NBEdge *from, NBEdge *to)
Definition: NBRequest.cpp:190
std::vector< bool > LinkInfoCont
Definition: NBRequest.h:233
NBRequest(const NBEdgeCont &ec, NBNode *junction, const EdgeVector &all, const EdgeVector &incoming, const EdgeVector &outgoing, const NBConnectionProhibits &loadedProhibits)
Definition: NBRequest.cpp:68
A SUMO-compliant built logic for a traffic light.
bool forbids(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
Definition: NBRequest.cpp:445
The representation of a single edge during network building.
Definition: NBEdge.h:71
NBNode * myJunction
the node the request is assigned to
Definition: NBRequest.h:220
The base class for traffic light logic definitions.
std::vector< LinkInfoCont > CombinationsCont
Definition: NBRequest.h:237
const EdgeVector & myOutgoing
Definition: NBRequest.h:229
NBRequest & operator=(const NBRequest &s)
Invalidated assignment operator.
void writeLogic(std::string key, OutputDevice &into, const bool checkLaneFoes) const
Definition: NBRequest.cpp:334
std::string getResponseString(const NBEdge *const from, const NBEdge *const to, int fromLane, int toLane, bool mayDefinitelyPass, const bool checkLaneFoes) const
Writes the response of a certain link.
Definition: NBRequest.cpp:496
size_t distanceCounterClockwise(NBEdge *from, NBEdge *to)
Definition: NBRequest.cpp:319
const EdgeVector & myIncoming
Definition: NBRequest.h:226
CombinationsCont myDone
Definition: NBRequest.h:246
static void reportWarnings()
reports warnings if any occured
Definition: NBRequest.cpp:676
bool rightTurnConflict(const NBEdge *from, const NBEdge *to, int fromLane, const NBEdge *prohibitorFrom, const NBEdge *prohibitorTo, int prohibitorFromLane) const
return whether the given laneToLane connection is a right turn which must yield to pedestrian or bicy...
Definition: NBRequest.cpp:588
void buildBitfieldLogic(bool leftHanded)
Definition: NBRequest.cpp:156
bool mustBrake(const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo) const
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
Definition: NBRequest.cpp:666
bool laneConflict(const NBEdge *from, const NBEdge *to, int toLane, const NBEdge *prohibitorFrom, const NBEdge *prohibitorTo, int prohibitorToLane) const
return whether the given laneToLane connections prohibit each other under the assumption that the edg...
Definition: NBRequest.cpp:566
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
std::string getFoesString(NBEdge *from, NBEdge *to, int fromLane, int toLane, const bool checkLaneFoes) const
Definition: NBRequest.cpp:537
const EdgeVector & myAll
Definition: NBRequest.h:223
void setBlocking(bool leftHanded, NBEdge *from1, NBEdge *to1, NBEdge *from2, NBEdge *to2)
Definition: NBRequest.cpp:208
std::map< NBEdge *, LaneVector > OccupiedLanes
Definition: NBRequest.h:240
static size_t myNotBuild
Definition: NBRequest.h:249
std::map< NBConnection, NBConnectionVector > NBConnectionProhibits
Definition of a container for connection block dependencies Includes a list of all connections which ...
int writeLaneResponse(OutputDevice &od, NBEdge *from, int lane, int pos, const bool checkLaneFoes) const
writes the response of a certain lane Returns the next link index within the junction ...
Definition: NBRequest.cpp:477
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:38
A storage for options typed value containers)
Definition: OptionsCont.h:108
friend std::ostream & operator<<(std::ostream &os, const NBRequest &r)
prints the request
Definition: NBRequest.cpp:623
Represents a single node (junction) during network building.
Definition: NBNode.h:74
bool foes(const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
Returns the information whether the given flows cross.
Definition: NBRequest.cpp:426
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
static size_t myGoodBuilds
Definition: NBRequest.h:249
void resetCooperating()
reset foes it the number of lanes matches (or exceeds) the number of incoming connections for an edge...
Definition: NBRequest.cpp:685
CombinationsCont myForbids
Definition: NBRequest.h:243
std::pair< unsigned int, unsigned int > getSizes() const
returns the number of the junction's lanes and the number of the junction's links in respect...
Definition: NBRequest.cpp:407
void computeRightOutgoingLinkCrossings(bool leftHanded, NBEdge *from, NBEdge *to)
Definition: NBRequest.cpp:172
void resetSignalised()
Definition: NBRequest.cpp:347