Eclipse SUMO - Simulation of Urban MObility
MSLinkCont.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2004-2020 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 /****************************************************************************/
19 // Helpers for link vector
20 /****************************************************************************/
21 #include <config.h>
22 
23 #include "MSLinkCont.h"
24 #include "MSLane.h"
25 
26 
27 // ===========================================================================
28 // method definitions
29 // ===========================================================================
30 const MSEdge*
32  const MSEdge* followerAfterInternal) {
33  //@todo to be optimized
34  const MSLinkCont& lc = fromLane->getLinkCont();
35  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
36  MSLink* link = *j;
37  if (&link->getLane()->getEdge() == followerAfterInternal) {
38  if (link->getViaLane() != nullptr) {
39  return &link->getViaLane()->getEdge();
40  } else {
41  return nullptr; // network without internal links
42  }
43  }
44  }
45  return nullptr;
46 }
47 
48 
49 const MSLane*
51  const MSLane* followerAfterInternal) {
52  //@todo to be optimized
53  const MSLinkCont& lc = fromLane->getLinkCont();
54  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
55  MSLink* link = *j;
56  if (link->getLane() == followerAfterInternal) {
57  if (link->getViaLane() != nullptr) {
58  return link->getViaLane();
59  } else {
60  return nullptr; // network without internal links
61  }
62  }
63  }
64  return nullptr;
65 }
66 
67 
68 MSLink*
70  const MSLinkCont& lc = from.getLinkCont();
71  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
72  MSLink* link = *j;
73  if (link->getLane() == &to) {
74  return link;
75  } else if (link->getViaLaneOrLane() == &to) {
76  return link;
77  }
78  }
79  return nullptr;
80 }
81 
82 
83 /****************************************************************************/
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:675
A road/street connecting two junctions.
Definition: MSEdge.h:77
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:2153
Representation of a lane in the micro simulation.
Definition: MSLane.h:82