SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NBConnection.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // The class holds a description of a connection between two edges
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef NBConnection_h
23 #define NBConnection_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include "NBEdge.h"
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class NBNode;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
51 class NBConnection {
52 public:
54  NBConnection(NBEdge* from, NBEdge* to);
55 
57  NBConnection(NBEdge* from, int fromLane, NBEdge* to, int toLane, int tlIndex = InvalidTlIndex);
58 
60  NBConnection(const std::string& fromID, NBEdge* from,
61  const std::string& toID, NBEdge* to);
62 
64  NBConnection(const NBConnection& c);
65 
67  virtual ~NBConnection();
68 
70  NBEdge* getFrom() const;
71 
73  NBEdge* getTo() const;
74 
76  bool replaceFrom(NBEdge* which, NBEdge* by);
77 
79  bool replaceFrom(NBEdge* which, int whichLane, NBEdge* by, int byLane);
80 
82  bool replaceTo(NBEdge* which, NBEdge* by);
83 
85  bool replaceTo(NBEdge* which, int whichLane, NBEdge* by, int byLane);
86 
88  bool check(const NBEdgeCont& ec);
89 
91  int getFromLane() const;
92 
94  int getToLane() const;
95 
96  /* @brief returns the index within the controlling tls or InvalidTLIndex if this
97  * link is unontrolled */
98  int getTLIndex() const {
99  return myTlIndex;
100  }
101 
102  // @brief reset the tlIndex
103  void setTLIndex(int tlIndex) {
104  myTlIndex = tlIndex;
105  }
106 
108  std::string getID() const;
109 
111  friend bool operator<(const NBConnection& c1, const NBConnection& c2);
112 
114  bool operator==(const NBConnection& c) const;
115 
117  bool operator!=(const NBConnection& c) const {
118  return !(*this == c);
119  }
120 
121  const static int InvalidTlIndex;
123 
124 private:
126  NBEdge* checkFrom(const NBEdgeCont& ec);
127 
129  NBEdge* checkTo(const NBEdgeCont& ec);
130 
131 private:
134 
136  std::string myFromID, myToID;
137 
140 
141  // @brief the index within the controlling tls if this connection is tls-controlled
143 
144 };
145 
146 
147 #endif
148 
149 /****************************************************************************/
150 
std::string myFromID
The names of both edges, needed for verification of validity.
Definition: NBConnection.h:136
bool check(const NBEdgeCont &ec)
checks whether the edges are still valid
int getTLIndex() const
Definition: NBConnection.h:98
virtual ~NBConnection()
Destructor.
static const NBConnection InvalidConnection
Definition: NBConnection.h:122
The representation of a single edge during network building.
Definition: NBEdge.h:71
bool replaceTo(NBEdge *which, NBEdge *by)
replaces the to-edge by the one given
friend bool operator<(const NBConnection &c1, const NBConnection &c2)
Compares both connections in order to allow sorting.
int getFromLane() const
returns the from-lane
NBEdge * getFrom() const
returns the from-edge (start of the connection)
void setTLIndex(int tlIndex)
Definition: NBConnection.h:103
int myFromLane
The lanes; may be -1 if no certain lane was specified.
Definition: NBConnection.h:139
std::string getID() const
returns the id of the connection (!!! not really pretty)
bool operator==(const NBConnection &c) const
Comparison operator.
static const int InvalidTlIndex
Definition: NBConnection.h:121
bool replaceFrom(NBEdge *which, NBEdge *by)
replaces the from-edge by the one given
NBEdge * checkTo(const NBEdgeCont &ec)
Checks whether the to-edge is still valid.
NBEdge * myTo
Definition: NBConnection.h:133
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:66
NBConnection(NBEdge *from, NBEdge *to)
Constructor.
std::string myToID
Definition: NBConnection.h:136
bool operator!=(const NBConnection &c) const
Comparison operator.
Definition: NBConnection.h:117
int getToLane() const
returns the to-lane
NBEdge * getTo() const
returns the to-edge (end of the connection)
Represents a single node (junction) during network building.
Definition: NBNode.h:74
NBEdge * myFrom
The from- and the to-edges.
Definition: NBConnection.h:133
NBEdge * checkFrom(const NBEdgeCont &ec)
Checks whether the from-edge is still valid.