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-sim.org/
12 // Copyright (C) 2001-2014 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  void shiftLaneIndex(NBEdge* edge, int offset);
89 
91  bool check(const NBEdgeCont& ec);
92 
94  int getFromLane() const;
95 
97  int getToLane() const;
98 
99  /* @brief returns the index within the controlling tls or InvalidTLIndex if this
100  * link is unontrolled */
101  int getTLIndex() const {
102  return myTlIndex;
103  }
104 
105  // @brief reset the tlIndex
106  void setTLIndex(int tlIndex) {
107  myTlIndex = tlIndex;
108  }
109 
111  std::string getID() const;
112 
114  friend bool operator<(const NBConnection& c1, const NBConnection& c2);
115 
117  bool operator==(const NBConnection& c) const;
118 
120  bool operator!=(const NBConnection& c) const {
121  return !(*this == c);
122  }
123 
124  const static int InvalidTlIndex;
126 
127 private:
129  NBEdge* checkFrom(const NBEdgeCont& ec);
130 
132  NBEdge* checkTo(const NBEdgeCont& ec);
133 
134 private:
137 
139  std::string myFromID, myToID;
140 
143 
144  // @brief the index within the controlling tls if this connection is tls-controlled
146 
147 };
148 
149 
150 #endif
151 
152 /****************************************************************************/
153