SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBConnection.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // The class holds a description of a connection between two edges
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NBConnection_h
23 #define NBConnection_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include "NBEdge.h"
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class NBNode;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
51 class NBConnection {
52 public:
54  NBConnection(NBEdge* from, NBEdge* to);
55 
57  NBConnection(NBEdge* from, int fromLane, NBEdge* to, int toLane, int tlIndex = InvalidTlIndex);
58 
60  NBConnection(const std::string& fromID, NBEdge* from,
61  const std::string& toID, NBEdge* to);
62 
64  NBConnection(const NBConnection& c);
65 
67  virtual ~NBConnection();
68 
70  NBEdge* getFrom() const;
71 
73  NBEdge* getTo() const;
74 
76  bool replaceFrom(NBEdge* which, NBEdge* by);
77 
79  bool replaceFrom(NBEdge* which, int whichLane, NBEdge* by, int byLane);
80 
82  bool replaceTo(NBEdge* which, NBEdge* by);
83 
85  bool replaceTo(NBEdge* which, int whichLane, NBEdge* by, int byLane);
86 
88  bool check(const NBEdgeCont& ec);
89 
91  int getFromLane() const;
92 
94  int getToLane() const;
95 
96  /* @brief returns the index within the controlling tls or InvalidTLIndex if this
97  * link is unontrolled */
98  int getTLIndex() const {
99  return myTlIndex;
100  }
101 
102  // @brief reset the tlIndex
103  void setTLIndex(int tlIndex) {
104  myTlIndex = tlIndex;
105  }
106 
108  std::string getID() const;
109 
111  friend bool operator<(const NBConnection& c1, const NBConnection& c2);
112 
114  bool operator==(const NBConnection& c) const;
115 
117  bool operator!=(const NBConnection& c) const {
118  return !(*this == c);
119  }
120 
121  const static int InvalidTlIndex;
123 
124 private:
126  NBEdge* checkFrom(const NBEdgeCont& ec);
127 
129  NBEdge* checkTo(const NBEdgeCont& ec);
130 
131 private:
134 
136  std::string myFromID, myToID;
137 
140 
141  // @brief the index within the controlling tls if this connection is tls-controlled
143 
144 };
145 
146 
147 #endif
148 
149 /****************************************************************************/
150