NBConnection Class Reference

#include <NBConnection.h>


Detailed Description

Definition at line 48 of file NBConnection.h.


Public Member Functions

bool check (const NBEdgeCont &ec)
 checks whether the edges are still valid
NBEdgegetFrom () const
 returns the from-edge (start of the connection)
int getFromLane () const
 returns the from-lane
std::string getID () const
 returns the id of the connection (!!! not really pretty)
NBEdgegetTo () const
 returns the to-edge (end of the connection)
int getToLane () const
 returns the to-lane
 NBConnection (const NBConnection &c)
 Constructor.
 NBConnection (const std::string &fromID, NBEdge *from, const std::string &toID, NBEdge *to)
 Constructor.
 NBConnection (NBEdge *from, int fromLane, NBEdge *to, int toLane)
 Constructor.
 NBConnection (NBEdge *from, NBEdge *to)
 Constructor.
bool replaceFrom (NBEdge *which, int whichLane, NBEdge *by, int byLane)
 replaces the from-edge by the one given
bool replaceFrom (NBEdge *which, NBEdge *by)
 replaces the from-edge by the one given
bool replaceTo (NBEdge *which, int whichLane, NBEdge *by, int byLane)
 replaces the to-edge by the one given
bool replaceTo (NBEdge *which, NBEdge *by)
 replaces the to-edge by the one given
 ~NBConnection ()
 Destructor.

Private Member Functions

NBEdgecheckFrom (const NBEdgeCont &ec)
 Checks whether the from-edge is still valid.
NBEdgecheckTo (const NBEdgeCont &ec)
 Checks whether the to-edge is still valid.

Private Attributes

NBEdgemyFrom
 The from- and the to-edges.
std::string myFromID
 The names of both edges, needed for verification of validity.
int myFromLane
 The lanes; may be -1 if no certain lane was specified.
NBEdgemyTo
std::string myToID
int myToLane

Friends

bool operator< (const NBConnection &c1, const NBConnection &c2)
 Compares both connections in order to allow sorting.

Constructor & Destructor Documentation

NBConnection::NBConnection ( NBEdge from,
NBEdge to 
)

Constructor.

Definition at line 45 of file NBConnection.cpp.

References NBEdge::getID(), myFromID, and myToID.

00046         : myFrom(from), myTo(to), myFromLane(-1), myToLane(-1) {
00047     myFromID = from->getID();
00048     myToID = to->getID();
00049 }

NBConnection::NBConnection ( NBEdge from,
int  fromLane,
NBEdge to,
int  toLane 
)

Constructor.

Definition at line 58 of file NBConnection.cpp.

References NBEdge::getID(), myFromID, myFromLane, myToID, and myToLane.

00060         : myFrom(from), myTo(to), myFromLane(fromLane), myToLane(toLane) {
00061     assert(myFromLane<0||from->getNoLanes()>(size_t) myFromLane);
00062     assert(myToLane<0||to->getNoLanes()>(size_t) myToLane);
00063     myFromID = from->getID();
00064     myToID = to!=0 ? to->getID() : "";
00065 }

NBConnection::NBConnection ( const std::string &  fromID,
NBEdge from,
const std::string &  toID,
NBEdge to 
)

Constructor.

Definition at line 52 of file NBConnection.cpp.

00054         : myFrom(from), myTo(to), myFromID(fromID), myToID(toID),
00055         myFromLane(-1), myToLane(-1) {}

NBConnection::NBConnection ( const NBConnection c  ) 

Constructor.

Definition at line 71 of file NBConnection.cpp.

00072         : myFrom(c.myFrom), myTo(c.myTo),
00073         myFromID(c.myFromID), myToID(c.myToID),
00074         myFromLane(c.myFromLane), myToLane(c.myToLane) {}

NBConnection::~NBConnection (  ) 

Destructor.

Definition at line 68 of file NBConnection.cpp.

00068 {}


Member Function Documentation

bool NBConnection::check ( const NBEdgeCont ec  ) 

checks whether the edges are still valid

Definition at line 148 of file NBConnection.cpp.

References checkFrom(), checkTo(), myFrom, and myTo.

Referenced by NIVissimDisturbance::addToNode(), NBLoadedTLDef::buildPhaseState(), NBLoadedTLDef::mustBrake(), and NBRequest::NBRequest().

00148                                         {
00149     myFrom = checkFrom(ec);
00150     myTo = checkTo(ec);
00151     return myFrom!=0 && myTo!=0;
00152 }

NBEdge * NBConnection::checkFrom ( const NBEdgeCont ec  )  [private]

Checks whether the from-edge is still valid.

Definition at line 156 of file NBConnection.cpp.

References myFrom, myFromID, myToID, NBEdgeCont::retrieve(), and NBEdgeCont::retrievePossiblySplitted().

Referenced by check().

00156                                             {
00157     NBEdge *e = ec.retrieve(myFromID);
00158     // ok, the edge was not changed
00159     if (e==myFrom) {
00160         return myFrom;
00161     }
00162     // try to get the edge
00163     return ec.retrievePossiblySplitted(myFromID, myToID, true);
00164 }

NBEdge * NBConnection::checkTo ( const NBEdgeCont ec  )  [private]

Checks whether the to-edge is still valid.

Definition at line 168 of file NBConnection.cpp.

References myFromID, myTo, myToID, NBEdgeCont::retrieve(), and NBEdgeCont::retrievePossiblySplitted().

Referenced by check().

00168                                           {
00169     NBEdge *e = ec.retrieve(myToID);
00170     // ok, the edge was not changed
00171     if (e==myTo) {
00172         return myTo;
00173     }
00174     // try to get the edge
00175     return ec.retrievePossiblySplitted(myToID, myFromID, false);
00176 }

NBEdge * NBConnection::getFrom (  )  const

int NBConnection::getFromLane (  )  const

returns the from-lane

Definition at line 188 of file NBConnection.cpp.

References myFromLane.

Referenced by NBTrafficLightDefinition::collectLinks(), NBOwnTLDef::setTLControllingInformation(), and NBLoadedTLDef::setTLControllingInformation().

00188                                 {
00189     return myFromLane;
00190 }

std::string NBConnection::getID (  )  const

returns the id of the connection (!!! not really pretty)

Definition at line 180 of file NBConnection.cpp.

References myFromID, myFromLane, myToID, and myToLane.

00180                           {
00181     std::stringstream str;
00182     str << myFromID << "_" << myFromLane << "->" << myToID << "_" << myToLane;
00183     return str.str();
00184 }

NBEdge * NBConnection::getTo (  )  const

int NBConnection::getToLane (  )  const

returns the to-lane

Definition at line 194 of file NBConnection.cpp.

References myToLane.

Referenced by NBTrafficLightDefinition::collectLinks(), NBOwnTLDef::setTLControllingInformation(), and NBLoadedTLDef::setTLControllingInformation().

00194                               {
00195     return myToLane;
00196 }

bool NBConnection::replaceFrom ( NBEdge which,
int  whichLane,
NBEdge by,
int  byLane 
)

replaces the from-edge by the one given

Definition at line 101 of file NBConnection.cpp.

References NBEdge::getID(), myFrom, myFromID, and myFromLane.

00102                                                   {
00103     if (myFrom==which&&(myFromLane==(int) whichLane||myFromLane<0)) {
00104         myFrom = by;
00105         myFromID = myFrom->getID();
00106         myFromLane = byLane;
00107         return true;
00108     }
00109     return false;
00110 }

bool NBConnection::replaceFrom ( NBEdge which,
NBEdge by 
)

replaces the from-edge by the one given

Definition at line 90 of file NBConnection.cpp.

References NBEdge::getID(), myFrom, and myFromID.

Referenced by NBLoadedTLDef::SignalGroup::remapIncoming(), and NBNode::replaceInConnectionProhibitions().

00090                                                    {
00091     if (myFrom==which) {
00092         myFrom = by;
00093         myFromID = myFrom->getID();
00094         return true;
00095     }
00096     return false;
00097 }

bool NBConnection::replaceTo ( NBEdge which,
int  whichLane,
NBEdge by,
int  byLane 
)

replaces the to-edge by the one given

Definition at line 125 of file NBConnection.cpp.

References NBEdge::getID(), myFromLane, myTo, myToID, and myToLane.

00126                                                 {
00127     if (myTo==which&&(myToLane==(int) whichLane||myFromLane<0)) {
00128         myTo = by;
00129         myToID = myTo->getID();
00130         myToLane = byLane;
00131         return true;
00132     }
00133     return false;
00134 }

bool NBConnection::replaceTo ( NBEdge which,
NBEdge by 
)

replaces the to-edge by the one given

Definition at line 114 of file NBConnection.cpp.

References NBEdge::getID(), myTo, and myToID.

Referenced by NBLoadedTLDef::SignalGroup::remapOutgoing(), and NBNode::replaceInConnectionProhibitions().

00114                                                  {
00115     if (myTo==which) {
00116         myTo = by;
00117         myToID = myTo->getID();
00118         return true;
00119     }
00120     return false;
00121 }


Friends And Related Function Documentation

bool operator< ( const NBConnection c1,
const NBConnection c2 
) [friend]

Compares both connections in order to allow sorting.

Definition at line 138 of file NBConnection.cpp.

00138                                                           {
00139     return
00140         std::pair<NBEdge*, NBEdge*>(c1.getFrom(), c1.getTo())
00141         <
00142         std::pair<NBEdge*, NBEdge*>(c2.getFrom(), c2.getTo());
00143 }


Field Documentation

The from- and the to-edges.

Definition at line 108 of file NBConnection.h.

Referenced by check(), checkFrom(), getFrom(), and replaceFrom().

std::string NBConnection::myFromID [private]

The names of both edges, needed for verification of validity.

Definition at line 111 of file NBConnection.h.

Referenced by checkFrom(), checkTo(), getID(), NBConnection(), and replaceFrom().

int NBConnection::myFromLane [private]

The lanes; may be -1 if no certain lane was specified.

Definition at line 114 of file NBConnection.h.

Referenced by getFromLane(), getID(), NBConnection(), replaceFrom(), and replaceTo().

Definition at line 108 of file NBConnection.h.

Referenced by check(), checkTo(), getTo(), and replaceTo().

std::string NBConnection::myToID [private]

Definition at line 111 of file NBConnection.h.

Referenced by checkFrom(), checkTo(), getID(), NBConnection(), and replaceTo().

int NBConnection::myToLane [private]

Definition at line 114 of file NBConnection.h.

Referenced by getID(), getToLane(), NBConnection(), and replaceTo().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:51 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6