SUMO - Simulation of Urban MObility
NBConnection.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // The class holds a description of a connection between two edges
20 /****************************************************************************/
21 #ifndef NBConnection_h
22 #define NBConnection_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include "NBEdge.h"
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class NBNode;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
50 class NBConnection {
51 public:
53  NBConnection(NBEdge* from, NBEdge* to);
54 
56  NBConnection(NBEdge* from, int fromLane, NBEdge* to, int toLane, int tlIndex = InvalidTlIndex);
57 
59  NBConnection(const std::string& fromID, NBEdge* from,
60  const std::string& toID, NBEdge* to);
61 
63  NBConnection(const NBConnection& c);
64 
66  virtual ~NBConnection();
67 
69  NBEdge* getFrom() const;
70 
72  NBEdge* getTo() const;
73 
75  bool replaceFrom(NBEdge* which, NBEdge* by);
76 
78  bool replaceFrom(NBEdge* which, int whichLane, NBEdge* by, int byLane);
79 
81  bool replaceTo(NBEdge* which, NBEdge* by);
82 
84  bool replaceTo(NBEdge* which, int whichLane, NBEdge* by, int byLane);
85 
87  void shiftLaneIndex(NBEdge* edge, int offset);
88 
90  bool check(const NBEdgeCont& ec);
91 
93  int getFromLane() const;
94 
96  int getToLane() const;
97 
99  int getTLIndex() const {
100  return myTlIndex;
101  }
102 
103  // @brief reset the tlIndex
104  void setTLIndex(int tlIndex) {
105  myTlIndex = tlIndex;
106  }
107 
109  std::string getID() const;
110 
112  friend bool operator<(const NBConnection& c1, const NBConnection& c2);
113 
115  bool operator==(const NBConnection& c) const;
116 
118  bool operator!=(const NBConnection& c) const {
119  return !(*this == c);
120  }
121 
123  friend std::ostream& operator<<(std::ostream& os, const NBConnection& c);
124 
125  const static int InvalidTlIndex;
127 
128 private:
130  NBEdge* checkFrom(const NBEdgeCont& ec);
131 
133  NBEdge* checkTo(const NBEdgeCont& ec);
134 
135 private:
138 
140  std::string myFromID, myToID;
141 
144 
145  // @brief the index within the controlling tls if this connection is tls-controlled
147 };
148 
149 
150 #endif
151 
152 /****************************************************************************/
153 
std::string myFromID
The names of both edges, needed for verification of validity.
Definition: NBConnection.h:140
std::string getID() const
returns the id of the connection (!!! not really pretty)
bool check(const NBEdgeCont &ec)
checks whether the edges are still valid
virtual ~NBConnection()
Destructor.
static const NBConnection InvalidConnection
Definition: NBConnection.h:126
The representation of a single edge during network building.
Definition: NBEdge.h:70
bool replaceTo(NBEdge *which, NBEdge *by)
replaces the to-edge by the one given
friend bool operator<(const NBConnection &c1, const NBConnection &c2)
Compares both connections in order to allow sorting.
bool operator!=(const NBConnection &c) const
Comparison operator.
Definition: NBConnection.h:118
NBEdge * getFrom() const
returns the from-edge (start of the connection)
void shiftLaneIndex(NBEdge *edge, int offset)
patches lane indices refering to the given edge
void setTLIndex(int tlIndex)
Definition: NBConnection.h:104
int myFromLane
The lanes; may be -1 if no certain lane was specified.
Definition: NBConnection.h:143
static const int InvalidTlIndex
Definition: NBConnection.h:125
bool replaceFrom(NBEdge *which, NBEdge *by)
replaces the from-edge by the one given
NBEdge * checkTo(const NBEdgeCont &ec)
Checks whether the to-edge is still valid.
friend std::ostream & operator<<(std::ostream &os, const NBConnection &c)
Output operator.
NBEdge * myTo
Definition: NBConnection.h:137
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
NBConnection(NBEdge *from, NBEdge *to)
Constructor.
std::string myToID
Definition: NBConnection.h:140
bool operator==(const NBConnection &c) const
Comparison operator.
int getToLane() const
returns the to-lane
NBEdge * getTo() const
returns the to-edge (end of the connection)
int getFromLane() const
returns the from-lane
Represents a single node (junction) during network building.
Definition: NBNode.h:74
NBEdge * myFrom
The from- and the to-edges.
Definition: NBConnection.h:137
int getTLIndex() const
returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled ...
Definition: NBConnection.h:99
NBEdge * checkFrom(const NBEdgeCont &ec)
Checks whether the from-edge is still valid.