NBRequest.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef NBRequest_h
00020 #define NBRequest_h
00021
00022
00023
00024
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
00043
00044 class NBEdge;
00045 class NBJunctionTypeIO;
00046 class NBTrafficLightLogic;
00047 class OptionsCont;
00048 class NBTrafficLightDefinition;
00049 class NBEdgeCont;
00050 class NBJunctionLogicCont;
00051
00052
00053
00054
00055
00062 class NBRequest {
00063 public:
00069 NBRequest(const NBEdgeCont &ec,
00070 NBNode *junction, const EdgeVector * const all,
00071 const EdgeVector * const incoming,
00072 const EdgeVector * const outgoing,
00073 const NBConnectionProhibits &loadedProhibits);
00074
00076 ~NBRequest();
00077
00079 void buildBitfieldLogic(bool leftHanded, NBJunctionLogicCont &jc,
00080 const std::string &key);
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
00128 friend std::ostream &operator<<(std::ostream &os, const NBRequest &r);
00129
00131 static void reportWarnings();
00132
00133
00134 private:
00137 void setBlocking(bool leftHanded, NBEdge *from1, NBEdge *to1, NBEdge *from2, NBEdge *to2);
00138
00141 std::string bitsetToXML(std::string key);
00142
00145 int writeLaneResponse(std::ostream &os, NBEdge *from, int lane,
00146 int pos);
00147
00166 void writeResponse(std::ostream &os, const NBEdge * const from, const NBEdge * const to,
00167 int fromLane, int toLane, bool mayDefinitelyPass) const throw(IOError);
00168
00169
00171 void writeAreFoes(std::ostream &os, NBEdge *from, NBEdge *to,
00172 bool isInnerEnd);
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 * const myAll;
00207
00209 const EdgeVector * const myIncoming;
00210
00212 const EdgeVector * const 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