/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NBConnection.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Sascha Krieg17/// @date Sept 200218///19// The class holds a description of a connection between two edges20/****************************************************************************/21#pragma once22#include <config.h>2324#include <string>25#include "NBEdge.h"262728// ===========================================================================29// class declarations30// ===========================================================================31class NBNode;323334// ===========================================================================35// class definitions36// ===========================================================================37/**38* @class NBConnection39*/40class NBConnection {41public:42/// @brief Constructor43NBConnection(NBEdge* from, NBEdge* to);4445/// @brief Constructor46NBConnection(NBEdge* from, int fromLane, NBEdge* to, int toLane, int tlIndex = InvalidTlIndex, int tlIndex2 = InvalidTlIndex);4748/// @brief Constructor49NBConnection(const std::string& fromID, NBEdge* from,50const std::string& toID, NBEdge* to);5152/// @brief Constructor53NBConnection(const NBConnection& c);5455/// @brief Destructor56virtual ~NBConnection();5758/// @brief returns the from-edge (start of the connection)59NBEdge* getFrom() const;6061/// @brief returns the to-edge (end of the connection)62NBEdge* getTo() const;6364/// @brief replaces the from-edge by the one given65bool replaceFrom(NBEdge* which, NBEdge* by);6667/// @brief replaces the from-edge by the one given68bool replaceFrom(NBEdge* which, int whichLane, NBEdge* by, int byLane);6970/// @brief replaces the to-edge by the one given71bool replaceTo(NBEdge* which, NBEdge* by);7273/// @brief replaces the to-edge by the one given74bool replaceTo(NBEdge* which, int whichLane, NBEdge* by, int byLane);7576/** @brief patches lane indices refering to the given edge and above the77* threshold by the given offset */78void shiftLaneIndex(NBEdge* edge, int offset, int threshold = -1);7980/// @brief checks whether the edges are still valid81bool check(const NBEdgeCont& ec);8283/// @brief returns the from-lane84int getFromLane() const;8586/// @brief returns the to-lane87int getToLane() const;8889/// @brief returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled90int getTLIndex() const {91return myTlIndex;92}93int getTLIndex2() const {94return myTlIndex2;95}9697// @brief reset the tlIndex98void setTLIndex(int tlIndex) {99myTlIndex = tlIndex;100}101void setTLIndex2(int tlIndex) {102myTlIndex2 = tlIndex;103}104105/// @brief returns the id of the connection (!!! not really pretty)106std::string getID() const;107108/// @brief Compares both connections in order to allow sorting109friend bool operator<(const NBConnection& c1, const NBConnection& c2);110111/// @brief Comparison operator112bool operator==(const NBConnection& c) const;113114/// @brief Comparison operator115bool operator!=(const NBConnection& c) const {116return !(*this == c);117}118119/// @brief Output operator120friend std::ostream& operator<<(std::ostream& os, const NBConnection& c);121122const static int InvalidTlIndex;123const static NBConnection InvalidConnection;124125private:126/// @brief Checks whether the from-edge is still valid127NBEdge* checkFrom(const NBEdgeCont& ec);128129/// @brief Checks whether the to-edge is still valid130NBEdge* checkTo(const NBEdgeCont& ec);131132private:133/// @brief The from- and the to-edges134NBEdge* myFrom, *myTo;135136/// @brief The names of both edges, needed for verification of validity137std::string myFromID, myToID;138139/// @brief The lanes; may be -1 if no certain lane was specified140int myFromLane, myToLane;141142// @brief the index within the controlling tls if this connection is tls-controlled143int myTlIndex;144/// @brief The index of the internal junction within the controlling traffic light (optional)145int myTlIndex2;146};147148149