SUMO - Simulation of Urban MObility
NBConnection.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // The class holds a description of a connection between two edges
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef NBConnection_h
00023 #define NBConnection_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <string>
00036 #include "NBEdge.h"
00037 
00038 
00039 // ===========================================================================
00040 // class declarations
00041 // ===========================================================================
00042 class NBNode;
00043 
00044 
00045 // ===========================================================================
00046 // class definitions
00047 // ===========================================================================
00051 class NBConnection {
00052 public:
00054     NBConnection(NBEdge* from, NBEdge* to);
00055 
00057     NBConnection(NBEdge* from, int fromLane, NBEdge* to, int toLane, int tlIndex = InvalidTlIndex);
00058 
00060     NBConnection(const std::string& fromID, NBEdge* from,
00061                  const std::string& toID, NBEdge* to);
00062 
00064     NBConnection(const NBConnection& c);
00065 
00067     virtual ~NBConnection();
00068 
00070     NBEdge* getFrom() const;
00071 
00073     NBEdge* getTo() const;
00074 
00076     bool replaceFrom(NBEdge* which, NBEdge* by);
00077 
00079     bool replaceFrom(NBEdge* which, int whichLane, NBEdge* by, int byLane);
00080 
00082     bool replaceTo(NBEdge* which, NBEdge* by);
00083 
00085     bool replaceTo(NBEdge* which, int whichLane, NBEdge* by, int byLane);
00086 
00088     bool check(const NBEdgeCont& ec);
00089 
00091     int getFromLane() const;
00092 
00094     int getToLane() const;
00095 
00096     /* @brief returns the index within the controlling tls or InvalidTLIndex if this
00097      * link is unontrolled */
00098     int getTLIndex() const {
00099         return myTlIndex;
00100     }
00101 
00102     // @brief reset the tlIndex
00103     void setTLIndex(int tlIndex) {
00104         myTlIndex = tlIndex;
00105     }
00106 
00108     std::string getID() const;
00109 
00111     friend bool operator<(const NBConnection& c1, const NBConnection& c2);
00112 
00114     bool operator==(const NBConnection& c) const;
00115 
00117     bool operator!=(const NBConnection& c) const {
00118         return !(*this == c);
00119     }
00120 
00121     const static int InvalidTlIndex;
00122     const static NBConnection InvalidConnection;
00123 
00124 private:
00126     NBEdge* checkFrom(const NBEdgeCont& ec);
00127 
00129     NBEdge* checkTo(const NBEdgeCont& ec);
00130 
00131 private:
00133     NBEdge* myFrom, *myTo;
00134 
00136     std::string myFromID, myToID;
00137 
00139     int myFromLane, myToLane;
00140 
00141     // @brief the index within the controlling tls if this connection is tls-controlled
00142     int myTlIndex;
00143 
00144 };
00145 
00146 
00147 #endif
00148 
00149 /****************************************************************************/
00150 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines