NLSucceedingLaneBuilder Class Reference

#include <NLSucceedingLaneBuilder.h>


Detailed Description

Temporary storage for a lanes succeeding lanes while parsing them.

Todo:
Consider moving this functionality to another class

Definition at line 51 of file NLSucceedingLaneBuilder.h.


Public Member Functions

void addSuccLane (bool yield, const std::string &laneId, MSLink::LinkDirection dir, MSLink::LinkState state, bool internalEnd, const std::string &tlid="", unsigned int linkNo=0) throw (InvalidArgument)
 Adds a succeeding lane.
void closeSuccLane () throw (InvalidArgument)
 Ends the computation of a container holding the succeeding lanes of a lane.
const std::string & getCurrentLaneName () const throw ()
 Returns the name of the lane the succeeding lanes are added to.
 NLSucceedingLaneBuilder (NLJunctionControlBuilder &jb) throw ()
 Constructor.
void openSuccLane (const std::string &laneId) throw ()
 Begins the computation of a container holding the succeeding lanes of a lane.
 ~NLSucceedingLaneBuilder () throw ()
 Destructor.

Private Member Functions

 NLSucceedingLaneBuilder (const NLSucceedingLaneBuilder &s)
 invalid copy constructor
NLSucceedingLaneBuilderoperator= (const NLSucceedingLaneBuilder &s)
 invalid assignment operator

Private Attributes

std::string myCurrentLane
 ID of the lane the succeeding lanes are added to.
NLJunctionControlBuildermyJunctionControlBuilder
 The junction control builder to obtain referenced tls from.
MSLinkContmySuccLanes
 The list of connections.

Constructor & Destructor Documentation

NLSucceedingLaneBuilder::NLSucceedingLaneBuilder ( NLJunctionControlBuilder jb  )  throw ()

Constructor.

Parameters:
[in] jb The junction control builder to obtain referenced tls from

Definition at line 54 of file NLSucceedingLaneBuilder.cpp.

00055         : myJunctionControlBuilder(jb) {
00056     mySuccLanes = new MSLinkCont();
00057     mySuccLanes->reserve(10);
00058 }

NLSucceedingLaneBuilder::~NLSucceedingLaneBuilder (  )  throw ()

Destructor.

Definition at line 61 of file NLSucceedingLaneBuilder.cpp.

References mySuccLanes.

00061                                                           {
00062     delete mySuccLanes;
00063 }

NLSucceedingLaneBuilder::NLSucceedingLaneBuilder ( const NLSucceedingLaneBuilder s  )  [private]

invalid copy constructor


Member Function Documentation

void NLSucceedingLaneBuilder::addSuccLane ( bool  yield,
const std::string &  laneId,
MSLink::LinkDirection  dir,
MSLink::LinkState  state,
bool  internalEnd,
const std::string &  tlid = "",
unsigned int  linkNo = 0 
) throw (InvalidArgument)

Adds a succeeding lane.

If either the current, or the succeeding lane is not known, an InvalidArgument is thrown (with the proper message). Also if a tls-logic is referenced, but not known to the junction control builder, an InvalidArgument is thrown.

Parameters:
[in] yield Whether the vehicles on the link have to wait
[in] laneId ID of the lane to add a connection to (from the last opened lane)
[in] viaID The junction-internal lane to use to reach the destination lane
[in] pass Theoretically: the maximum filling rate at the internal link; unused currently
[in] dir The abstract direction of the link
[in] state The abstract state of the link
[in] internalEnd Whether the link is followed by an internal end lane
[in] tlid (optional) ID of the tls that controls the link
[in] linkNo (optional) index of the link within the controlling tls
Todo:
Recheck usage of "pass"
Exceptions:
InvalidArgument If one of the referenced structures was not found or is invalid
See also:
MSLink::LinkDirection

MSLink::LinkState

MSLink

Definition at line 73 of file NLSucceedingLaneBuilder.cpp.

References MSLane::addIncomingLane(), MSTLLogicControl::TLSLogicVariants::addLink(), MSLane::dictionary(), MSLane::getLength(), MSLane::getShape(), NLJunctionControlBuilder::getTLLogic(), MSGlobals::gUsingInternalLanes, MSLink::LINKDIR_NODIR, MSLink::LINKSTATE_DEADEND, myCurrentLane, myJunctionControlBuilder, mySuccLanes, and SUMOReal.

Referenced by NLHandler::addSuccLane().

00081                                                                                                         {
00082     // check whether the link is a dead link
00083     if (laneId=="SUMO_NO_DESTINATION") {
00084         // build the dead link and add it to the container
00085 #ifdef HAVE_INTERNAL_LANES
00086         MSLink *link = new MSLink(0, 0, yield, MSLink::LINKDIR_NODIR, MSLink::LINKSTATE_DEADEND, false, 0.);
00087 #else
00088         MSLink *link = new MSLink(0, yield, MSLink::LINKDIR_NODIR, MSLink::LINKSTATE_DEADEND, 0.);
00089 #endif
00090         mySuccLanes->push_back(link);
00091         if (tlid!="") {
00092             MSTLLogicControl::TLSLogicVariants &logics = myJunctionControlBuilder.getTLLogic(tlid);
00093             MSLane *current = MSLane::dictionary(myCurrentLane);
00094             if (current==0) {
00095                 throw InvalidArgument("An unknown lane ('" + myCurrentLane + "') should be assigned to a tl-logic.");
00096             }
00097             logics.addLink(link, current, linkNo);
00098         }
00099         return;
00100     }
00101 
00102     // get the lane the link belongs to
00103     MSLane *lane = MSLane::dictionary(laneId);
00104     if (lane==0) {
00105         throw InvalidArgument("An unknown lane ('" + laneId + "') should be set as a follower for lane '" + myCurrentLane + "'.");
00106     }
00107 #ifdef HAVE_INTERNAL_LANES
00108     MSLane *via = 0;
00109     if (viaID!="" && MSGlobals::gUsingInternalLanes) {
00110         via = MSLane::dictionary(viaID);
00111         if (via==0) {
00112             throw InvalidArgument("An unknown lane ('" + viaID + "') should be set as a via-lane for lane '" + myCurrentLane + "'.");
00113         }
00114     }
00115     if (pass>=0) {
00116         static_cast<MSInternalLane*>(lane)->setPassPosition(pass);
00117     }
00118 #endif
00119     MSLane *orig = MSLane::dictionary(myCurrentLane);
00120     if (orig==0) {
00121         return;
00122     }
00123 
00124 
00125     // build the link
00126     SUMOReal length = orig!=0&&lane!=0
00127                       ? orig->getShape()[-1].distanceTo(lane->getShape()[0])
00128                       : 0;
00129 #ifdef HAVE_INTERNAL_LANES
00130     if (via!=0) {
00131         length = via->getLength();
00132     }
00133     MSLink *link = new MSLink(lane, via, yield, dir, state, internalEnd, length);
00134 #else
00135     MSLink *link = new MSLink(lane, yield, dir, state, length);
00136 #endif
00137 
00138     if (MSLane::dictionary(myCurrentLane)!=0) {
00139 #ifdef HAVE_INTERNAL_LANES
00140         if (via!=0) {
00141             // from a normal in to a normal out via
00142             //  --> via incomes in out
00143             lane->addIncomingLane(via, link);
00144             //  --> in incomes in via
00145             via->addIncomingLane(MSLane::dictionary(myCurrentLane), link);
00146         } else {
00147             if (myCurrentLane[0]!=':') {
00148                 // internal not wished; other case already set
00149                 lane->addIncomingLane(MSLane::dictionary(myCurrentLane), link);
00150             }
00151         }
00152 #else
00153         lane->addIncomingLane(MSLane::dictionary(myCurrentLane), link);
00154 #endif
00155     }
00156     // if a traffic light is responsible for it, inform the traffic light
00157     // check whether this link is controlled by a traffic light
00158     if (tlid!="") {
00159         MSTLLogicControl::TLSLogicVariants &logics = myJunctionControlBuilder.getTLLogic(tlid);
00160         MSLane *current = MSLane::dictionary(myCurrentLane);
00161         if (current==0) {
00162             throw InvalidArgument("An unknown lane ('" + myCurrentLane + "') should be assigned to a tl-logic.");
00163         }
00164         logics.addLink(link, current, linkNo);
00165     }
00166     // add the link to the container
00167     mySuccLanes->push_back(link);
00168 }

void NLSucceedingLaneBuilder::closeSuccLane (  )  throw (InvalidArgument)

Ends the computation of a container holding the succeeding lanes of a lane.

The current lane is determined and the parsed connections are added to it. If the lane is not known, an InvalidArgument is thrown.

Exceptions:
InvalidArgument If the current lane is not known

Definition at line 172 of file NLSucceedingLaneBuilder.cpp.

References MSLane::dictionary(), MSLane::initialize(), myCurrentLane, and mySuccLanes.

Referenced by NLHandler::closeSuccLane().

00172                                                               {
00173     MSLane *current = MSLane::dictionary(myCurrentLane);
00174     if (current==0) {
00175         throw InvalidArgument("Trying to close connections of an unknown lane ('" + myCurrentLane + "').");
00176     }
00177     MSLinkCont *cont = new MSLinkCont();
00178     cont->reserve(mySuccLanes->size());
00179     copy(mySuccLanes->begin(), mySuccLanes->end(), back_inserter(*cont));
00180     current->initialize(cont);
00181     mySuccLanes->clear();
00182 }

const std::string & NLSucceedingLaneBuilder::getCurrentLaneName (  )  const throw ()

Returns the name of the lane the succeeding lanes are added to.

Returns:
The ID of the currently opened lane

Definition at line 186 of file NLSucceedingLaneBuilder.cpp.

References myCurrentLane.

00186                                                           {
00187     return myCurrentLane;
00188 }

void NLSucceedingLaneBuilder::openSuccLane ( const std::string &  laneId  )  throw ()

Begins the computation of a container holding the succeeding lanes of a lane.

Parameters:
[in] laneId The id of the lane from which connections will be built
Todo:
Why is the ID kept, not already the lane itself?

Definition at line 67 of file NLSucceedingLaneBuilder.cpp.

References myCurrentLane.

Referenced by NLHandler::openSucc().

00067                                                                      {
00068     myCurrentLane = laneId;
00069 }

NLSucceedingLaneBuilder& NLSucceedingLaneBuilder::operator= ( const NLSucceedingLaneBuilder s  )  [private]

invalid assignment operator


Field Documentation

ID of the lane the succeeding lanes are added to.

Todo:
Why is not the lane itself saved?

Definition at line 121 of file NLSucceedingLaneBuilder.h.

Referenced by addSuccLane(), closeSuccLane(), getCurrentLaneName(), and openSuccLane().

The junction control builder to obtain referenced tls from.

Definition at line 128 of file NLSucceedingLaneBuilder.h.

Referenced by addSuccLane().

The list of connections.

Todo:
Is it really necessary to have this as a pointer - the link container is rebuilt anyway

Definition at line 125 of file NLSucceedingLaneBuilder.h.

Referenced by addSuccLane(), closeSuccLane(), and ~NLSucceedingLaneBuilder().


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

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