SUMO - Simulation of Urban MObility
MSLinkCont.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // Helpers for link vector
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2004-2015 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "MSLinkCont.h"
33 #include "MSLane.h"
34 
35 #ifdef CHECK_MEMORY_LEAKS
36 #include <foreign/nvwa/debug_new.h>
37 #endif // CHECK_MEMORY_LEAKS
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 #ifdef HAVE_INTERNAL_LANES
44 const MSEdge*
45 MSLinkContHelper::getInternalFollowingEdge(const MSLane* fromLane,
46  const MSEdge* followerAfterInternal) {
47  //@todo to be optimized
48  const MSLinkCont& lc = fromLane->getLinkCont();
49  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
50  MSLink* link = *j;
51  if (&link->getLane()->getEdge() == followerAfterInternal) {
52  if (link->getViaLane() != 0) {
53  return &link->getViaLane()->getEdge();
54  } else {
55  return 0; // network without internal links
56  }
57  }
58  }
59  return 0;
60 }
61 
62 
63 const MSLane*
64 MSLinkContHelper::getInternalFollowingLane(const MSLane* fromLane,
65  const MSLane* followerAfterInternal) {
66  //@todo to be optimized
67  const MSLinkCont& lc = fromLane->getLinkCont();
68  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
69  MSLink* link = *j;
70  if (link->getLane() == followerAfterInternal) {
71  if (link->getViaLane() != 0) {
72  return link->getViaLane();
73  } else {
74  return 0; // network without internal links
75  }
76  }
77  }
78  return 0;
79 }
80 #endif
81 
82 
83 MSLink*
85  const MSLinkCont& lc = from.getLinkCont();
86  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); j++) {
87  MSLink* link = *j;
88  if (link->getLane() == &to) {
89  return link;
90  } else if (link->getViaLaneOrLane() == &to) {
91  return link;
92  }
93  }
94  return 0;
95 }
96 
97 
98 
99 /****************************************************************************/
100 
MSEdge & getEdge() const
Returns the lane&#39;s edge.
Definition: MSLane.h:461
A road/street connecting two junctions.
Definition: MSEdge.h:81
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:1059
Representation of a lane in the micro simulation.
Definition: MSLane.h:77