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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Helpers for link vector
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include "MSLinkCont.h"
25 #include "MSLane.h"
26 
27 
28 // ===========================================================================
29 // method definitions
30 // ===========================================================================
31 const MSEdge*
33  const MSEdge* followerAfterInternal) {
34  //@todo to be optimized
35  const MSLinkCont& lc = fromLane->getLinkCont();
36  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
37  MSLink* link = *j;
38  if (&link->getLane()->getEdge() == followerAfterInternal) {
39  if (link->getViaLane() != nullptr) {
40  return &link->getViaLane()->getEdge();
41  } else {
42  return nullptr; // network without internal links
43  }
44  }
45  }
46  return nullptr;
47 }
48 
49 
50 const MSLane*
52  const MSLane* followerAfterInternal) {
53  //@todo to be optimized
54  const MSLinkCont& lc = fromLane->getLinkCont();
55  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
56  MSLink* link = *j;
57  if (link->getLane() == followerAfterInternal) {
58  if (link->getViaLane() != nullptr) {
59  return link->getViaLane();
60  } else {
61  return nullptr; // network without internal links
62  }
63  }
64  }
65  return nullptr;
66 }
67 
68 
69 MSLink*
71  const MSLinkCont& lc = from.getLinkCont();
72  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
73  MSLink* link = *j;
74  if (link->getLane() == &to) {
75  return link;
76  } else if (link->getViaLaneOrLane() == &to) {
77  return link;
78  }
79  }
80  return nullptr;
81 }
82 
83 
84 
85 /****************************************************************************/
86 
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSLane::getLinkCont
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:2110
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
config.h
MSLane.h