Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NBConnection.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// The class holds a description of a connection between two edges
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <string>
26#include "NBEdge.h"
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32class NBNode;
33
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
42public:
44 NBConnection(NBEdge* from, NBEdge* to);
45
47 NBConnection(NBEdge* from, int fromLane, NBEdge* to, int toLane, int tlIndex = InvalidTlIndex, int tlIndex2 = InvalidTlIndex);
48
50 NBConnection(const std::string& fromID, NBEdge* from,
51 const std::string& toID, NBEdge* to);
52
54 NBConnection(const NBConnection& c);
55
57 virtual ~NBConnection();
58
60 NBEdge* getFrom() const;
61
63 NBEdge* getTo() const;
64
66 bool replaceFrom(NBEdge* which, NBEdge* by);
67
69 bool replaceFrom(NBEdge* which, int whichLane, NBEdge* by, int byLane);
70
72 bool replaceTo(NBEdge* which, NBEdge* by);
73
75 bool replaceTo(NBEdge* which, int whichLane, NBEdge* by, int byLane);
76
79 void shiftLaneIndex(NBEdge* edge, int offset, int threshold = -1);
80
82 bool check(const NBEdgeCont& ec);
83
85 int getFromLane() const;
86
88 int getToLane() const;
89
91 int getTLIndex() const {
92 return myTlIndex;
93 }
94 int getTLIndex2() const {
95 return myTlIndex2;
96 }
97
98 // @brief reset the tlIndex
99 void setTLIndex(int tlIndex) {
100 myTlIndex = tlIndex;
101 }
102 void setTLIndex2(int tlIndex) {
103 myTlIndex2 = tlIndex;
104 }
105
107 std::string getID() const;
108
110 friend bool operator<(const NBConnection& c1, const NBConnection& c2);
111
113 bool operator==(const NBConnection& c) const;
114
116 bool operator!=(const NBConnection& c) const {
117 return !(*this == c);
118 }
119
121 friend std::ostream& operator<<(std::ostream& os, const NBConnection& c);
122
123 const static int InvalidTlIndex;
125
126private:
128 NBEdge* checkFrom(const NBEdgeCont& ec);
129
131 NBEdge* checkTo(const NBEdgeCont& ec);
132
133private:
136
138 std::string myFromID, myToID;
139
142
143 // @brief the index within the controlling tls if this connection is tls-controlled
147};
NBEdge * getFrom() const
returns the from-edge (start of the connection)
std::string getID() const
returns the id of the connection (!!! not really pretty)
std::string myToID
int getFromLane() const
returns the from-lane
bool replaceTo(NBEdge *which, NBEdge *by)
replaces the to-edge by the one given
NBEdge * myFrom
The from- and the to-edges.
friend bool operator<(const NBConnection &c1, const NBConnection &c2)
Compares both connections in order to allow sorting.
int myTlIndex2
The index of the internal junction within the controlling traffic light (optional)
int getTLIndex2() const
int myFromLane
The lanes; may be -1 if no certain lane was specified.
int getTLIndex() const
returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled
static const int InvalidTlIndex
bool operator==(const NBConnection &c) const
Comparison operator.
void shiftLaneIndex(NBEdge *edge, int offset, int threshold=-1)
patches lane indices refering to the given edge and above the threshold by the given offset
bool replaceFrom(NBEdge *which, NBEdge *by)
replaces the from-edge by the one given
NBEdge * checkFrom(const NBEdgeCont &ec)
Checks whether the from-edge is still valid.
void setTLIndex(int tlIndex)
bool operator!=(const NBConnection &c) const
Comparison operator.
NBEdge * myTo
int getToLane() const
returns the to-lane
friend std::ostream & operator<<(std::ostream &os, const NBConnection &c)
Output operator.
void setTLIndex2(int tlIndex)
NBEdge * getTo() const
returns the to-edge (end of the connection)
virtual ~NBConnection()
Destructor.
bool check(const NBEdgeCont &ec)
checks whether the edges are still valid
std::string myFromID
The names of both edges, needed for verification of validity.
NBEdge * checkTo(const NBEdgeCont &ec)
Checks whether the to-edge is still valid.
static const NBConnection InvalidConnection
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
The representation of a single edge during network building.
Definition NBEdge.h:92
Represents a single node (junction) during network building.
Definition NBNode.h:66