|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // The class holds a description of a connection between two edges 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 NBConnection_h 00020 #define NBConnection_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 "NBEdge.h" 00034 00035 00036 // =========================================================================== 00037 // class declarations 00038 // =========================================================================== 00039 class NBNode; 00040 00041 00042 // =========================================================================== 00043 // class definitions 00044 // =========================================================================== 00048 class NBConnection { 00049 public: 00051 NBConnection(NBEdge* from, NBEdge* to); 00052 00054 NBConnection(NBEdge* from, int fromLane, NBEdge* to, int toLane, int tlIndex = InvalidTlIndex); 00055 00057 NBConnection(const std::string& fromID, NBEdge* from, 00058 const std::string& toID, NBEdge* to); 00059 00061 NBConnection(const NBConnection& c); 00062 00064 virtual ~NBConnection(); 00065 00067 NBEdge* getFrom() const; 00068 00070 NBEdge* getTo() const; 00071 00073 bool replaceFrom(NBEdge* which, NBEdge* by); 00074 00076 bool replaceFrom(NBEdge* which, int whichLane, NBEdge* by, int byLane); 00077 00079 bool replaceTo(NBEdge* which, NBEdge* by); 00080 00082 bool replaceTo(NBEdge* which, int whichLane, NBEdge* by, int byLane); 00083 00085 bool check(const NBEdgeCont& ec); 00086 00088 int getFromLane() const; 00089 00091 int getToLane() const; 00092 00093 /* @brief returns the index within the controlling tls or InvalidTLIndex if this 00094 * link is unontrolled */ 00095 int getTLIndex() const { 00096 return myTlIndex; 00097 } 00098 00099 // @brief reset the tlIndex 00100 void setTLIndex(int tlIndex) { 00101 myTlIndex = tlIndex; 00102 } 00103 00105 std::string getID() const; 00106 00108 friend bool operator<(const NBConnection& c1, const NBConnection& c2); 00109 00111 bool operator==(const NBConnection& c) const; 00112 00114 bool operator!=(const NBConnection& c) const { 00115 return !(*this == c); 00116 } 00117 00118 const static int InvalidTlIndex; 00119 const static NBConnection InvalidConnection; 00120 00121 private: 00123 NBEdge* checkFrom(const NBEdgeCont& ec); 00124 00126 NBEdge* checkTo(const NBEdgeCont& ec); 00127 00128 private: 00130 NBEdge* myFrom, *myTo; 00131 00133 std::string myFromID, myToID; 00134 00136 int myFromLane, myToLane; 00137 00138 // @brief the index within the controlling tls if this connection is tls-controlled 00139 int myTlIndex; 00140 00141 }; 00142 00143 00144 #endif 00145 00146 /****************************************************************************/ 00147