RORouteDef_Complete Class Reference

#include <RORouteDef_Complete.h>

Inheritance diagram for RORouteDef_Complete:

RORouteDef ReferencedItem Named

Detailed Description

A complete route description containing all edges the driver will pass.

Definition at line 53 of file RORouteDef_Complete.h.


Public Member Functions

void addAlternative (SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
 Adds an route alternative (see further comments).
RORoutebuildCurrentRoute (SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
 Builds the route.
RORouteDefcopy (const std::string &id) const
 Returns a copy of the route definition.
const RGBColor *const getColor () const
 Returns the color of the route.
const std::string & getID () const throw ()
 Returns the id.
bool isSaved () const throw ()
 Returns the information whether this item was already saved.
void markSaved () throw ()
 Marks the item as saved.
 RORouteDef_Complete (const std::string &id, const RGBColor *const color, const std::vector< const ROEdge * > &edges, bool tryRepair) throw ()
 Constructor.
virtual OutputDevicewriteXMLDefinition (SUMOAbstractRouter< ROEdge, ROVehicle > &router, OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
 Saves the built route / route alternatives.
virtual ~RORouteDef_Complete () throw ()
 Destructor.

Protected Member Functions

const RGBColor *const copyColorIfGiven () const throw ()

Protected Attributes

const RGBColor *const myColor
 The color the route shall have.
std::vector< const ROEdge * > myEdges
 The list of edges the driver passes.
std::string myID
 The name of the object.
SUMOTime myStartTime
 The begin of the route.
bool myTryRepair

Private Member Functions

RORouteDef_Completeoperator= (const RORouteDef_Complete &src)
 Invalidated assignment operator.
 RORouteDef_Complete (const RORouteDef_Complete &src)
 Invalidated copy constructor.

Constructor & Destructor Documentation

RORouteDef_Complete::RORouteDef_Complete ( const std::string &  id,
const RGBColor *const   color,
const std::vector< const ROEdge * > &  edges,
bool  tryRepair 
) throw ()

Constructor.

Definition at line 51 of file RORouteDef_Complete.cpp.

Referenced by copy().

00055         : RORouteDef(id, color), myEdges(edges), myTryRepair(tryRepair) {
00056 }

RORouteDef_Complete::~RORouteDef_Complete (  )  throw () [virtual]

Destructor.

Definition at line 59 of file RORouteDef_Complete.cpp.

00059 {}

RORouteDef_Complete::RORouteDef_Complete ( const RORouteDef_Complete src  )  [private]

Invalidated copy constructor.


Member Function Documentation

void RORouteDef_Complete::addAlternative ( SUMOAbstractRouter< ROEdge, ROVehicle > &  router,
const ROVehicle * const  ,
RORoute current,
SUMOTime  begin 
) [virtual]

Adds an route alternative (see further comments).

Here, as in most cases, the alternative is the route that was build as last and will stay the only route known

Implements RORouteDef.

Definition at line 100 of file RORouteDef_Complete.cpp.

References myStartTime.

00101                                                                                               {
00102     myStartTime = begin;
00103     delete current;
00104 }

RORoute * RORouteDef_Complete::buildCurrentRoute ( SUMOAbstractRouter< ROEdge, ROVehicle > &  router,
SUMOTime  begin,
const ROVehicle veh 
) const [virtual]

Builds the route.

Implements RORouteDef.

Definition at line 63 of file RORouteDef_Complete.cpp.

References SUMOAbstractRouter< E, V >::compute(), RORouteDef::copyColorIfGiven(), OptionsCont::getBool(), MsgHandler::getErrorInstance(), Named::getID(), ROVehicle::getID(), OptionsCont::getOptions(), MsgHandler::getWarningInstance(), MsgHandler::inform(), myEdges, Named::myID, myTryRepair, SUMOAbstractRouter< E, V >::recomputeCosts(), and SUMOReal.

00064                                                                                    {
00065     if (myTryRepair) {
00066         const std::vector<const ROEdge*> &oldEdges = myEdges;
00067         if (oldEdges.size()==0) {
00068             MsgHandler *m = OptionsCont::getOptions().getBool("continue-on-unbuild") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance();
00069             m->inform("Could not repair empty route of vehicle '" + veh.getID() + "'.");
00070             return new RORoute(myID, 0, 1, std::vector<const ROEdge*>(), copyColorIfGiven());
00071         }
00072         std::vector<const ROEdge*> newEdges;
00073         newEdges.push_back(*(oldEdges.begin()));
00074         for (std::vector<const ROEdge*>::const_iterator i=oldEdges.begin()+1; i!=oldEdges.end(); ++i) {
00075             if ((*(i-1))->isConnectedTo(*i)) {
00076                 newEdges.push_back(*i);
00077             } else {
00078                 std::vector<const ROEdge*> edges;
00079                 router.compute(*(i-1), *i, &veh, begin, edges);
00080                 if (edges.size()==0) {
00081                     return 0;
00082                 }
00083                 std::copy(edges.begin()+1, edges.end(), back_inserter(newEdges));
00084             }
00085         }
00086         if (myEdges!=newEdges) {
00087             MsgHandler::getWarningInstance()->inform("Repaired route of vehicle '" + veh.getID() + "'.");
00088         }
00089         myEdges = newEdges;
00090     }
00091     SUMOReal costs = router.recomputeCosts(myEdges, &veh, begin);
00092     if (costs<0) {
00093         throw ProcessError("Route '" + getID() + "' (vehicle '" + veh.getID() + "') is not valid.");
00094     }
00095     return new RORoute(myID, 0, 1, myEdges, copyColorIfGiven());
00096 }

RORouteDef * RORouteDef_Complete::copy ( const std::string &  id  )  const [virtual]

Returns a copy of the route definition.

Implements RORouteDef.

Definition at line 108 of file RORouteDef_Complete.cpp.

References RORouteDef::copyColorIfGiven(), myEdges, myTryRepair, and RORouteDef_Complete().

00108                                                    {
00109     return new RORouteDef_Complete(id, copyColorIfGiven(), myEdges, myTryRepair);
00110 }

const RGBColor *const RORouteDef::copyColorIfGiven (  )  const throw () [protected, inherited]

Definition at line 63 of file RORouteDef.cpp.

References RORouteDef::myColor.

Referenced by RORouteDef_OrigDest::buildCurrentRoute(), buildCurrentRoute(), RORouteDef_Alternatives::buildCurrentRoute(), RORouteDef_OrigDest::copy(), and copy().

00063                                            {
00064     if (myColor==0) {
00065         return 0;
00066     }
00067     return new RGBColor(*myColor);
00068 }

const RGBColor* const RORouteDef::getColor (  )  const [inline, inherited]

Returns the color of the route.

Definition at line 92 of file RORouteDef.h.

References RORouteDef::myColor.

00092                                             {
00093         return myColor;
00094     }

const std::string& Named::getID (  )  const throw () [inline, inherited]

Returns the id.

Returns:
The stored id

Definition at line 59 of file Named.h.

References Named::myID.

Referenced by RORouteDef_Alternatives::addAlternative(), MSRouteProbe::addRoute(), MSEmitter::MSEmitter_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSCalibrator::MSCalibrator_FileTriggeredChild::buildAndScheduleFlowVehicle(), buildCurrentRoute(), ODDistrictHandler::closeDistrict(), NBTrafficLightDefinition::collectLinks(), NBTrafficLightDefinition::compute(), GUIPointOfInterest::drawGL(), MSInductLoop::enterDetectorByMove(), MSVTypeProbe::execute(), MSNet::getBusStopID(), GUITriggeredRerouter::getMicrosimID(), GUIPointOfInterest::getMicrosimID(), GUILaneSpeedTrigger::getMicrosimID(), GUIInductLoop::MyWrapper::getMicrosimID(), GUIEmitter::getMicrosimID(), GUIBusStop::getMicrosimID(), GUI_E2_ZS_Collector::MyWrapper::getMicrosimID(), traci::TraCIServer::handlePoiDomain(), RORDLoader_SUMOBase::myCharacters(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), MSTriggeredRerouter::myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), NBLoadedTLDef::SignalGroup::patchTYellow(), TraCIServerAPI_Vehicle::processGet(), MSVehicle::replaceRoute(), MSVehicle::saveState(), NBOwnTLDef::setTLControllingInformation(), NBLoadedTLDef::setTLControllingInformation(), RORDLoader_SUMOBase::startRoute(), GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute(), NBTrafficLightLogic::writeXML(), MSRouteProbe::writeXMLOutput(), MSInductLoop::writeXMLOutput(), MSE2Collector::writeXMLOutput(), and MSVehicle::~MSVehicle().

00059                                            {
00060         return myID;
00061     }

bool ReferencedItem::isSaved (  )  const throw () [inline, inherited]

Returns the information whether this item was already saved.

Returns:
Whether this item was saved

Definition at line 58 of file ReferencedItem.h.

References ReferencedItem::myWasSaved.

Referenced by RONet::computeRoute(), and ROVehicle::saveAllAsXML().

00058                                   {
00059         return myWasSaved;
00060     }

void ReferencedItem::markSaved (  )  throw () [inline, inherited]

Marks the item as saved.

Definition at line 65 of file ReferencedItem.h.

References ReferencedItem::myWasSaved.

00065                               {
00066         myWasSaved = true;
00067     }

RORouteDef_Complete& RORouteDef_Complete::operator= ( const RORouteDef_Complete src  )  [private]

Invalidated assignment operator.

OutputDevice & RORouteDef_Complete::writeXMLDefinition ( SUMOAbstractRouter< ROEdge, ROVehicle > &  router,
OutputDevice dev,
const ROVehicle *const   veh,
bool  asAlternatives,
bool  withExitTimes 
) const [virtual]

Saves the built route / route alternatives.

Writes the route into the given stream.

Parameters:
[in] dev The device to write the route into
[in] asAlternatives Whether the route shall be saved as route alternatives
Returns:
The same device for further usage

Implements RORouteDef.

Definition at line 114 of file RORouteDef_Complete.cpp.

References OutputDevice::closeTag(), ROVehicle::getDepartureTime(), RORouteDef::myColor, myEdges, OutputDevice::openTag(), SUMOAbstractRouter< E, V >::recomputeCosts(), and SUMOReal.

00116                                                                                        {
00117     // (optional) alternatives header
00118     if (asAlternatives) {
00119         dev.openTag("routeDistribution") << " last=\"0\">\n";
00120     }
00121     // the route
00122     dev.openTag("route");
00123     if (asAlternatives) {
00124         dev << " cost=\"" << router.recomputeCosts(myEdges, veh, veh->getDepartureTime());
00125         dev << "\" probability=\"1.00\"";
00126     }
00127     if (myColor!=0) {
00128         dev << " color=\"" << *myColor << "\"";
00129     }
00130     dev << " edges=\"" << myEdges;
00131     if (withExitTimes) {
00132         SUMOReal time = (SUMOReal) veh->getDepartureTime() / 1000.;
00133         dev << "\" exitTimes=\"";
00134         std::vector<const ROEdge*>::const_iterator i = myEdges.begin();
00135         for (; i!=myEdges.end(); ++i) {
00136             if (i != myEdges.begin()) {
00137                 dev << " ";
00138             }
00139             time += (*i)->getTravelTime(veh, (SUMOTime) time);
00140             dev << time;
00141         }
00142     }
00143     (dev << "\"").closeTag(true);
00144     // (optional) alternatives end
00145     if (asAlternatives) {
00146         dev.closeTag();
00147     }
00148     return dev;
00149 }


Field Documentation

const RGBColor* const RORouteDef::myColor [protected, inherited]

std::vector<const ROEdge*> RORouteDef_Complete::myEdges [mutable, protected]

The list of edges the driver passes.

Definition at line 83 of file RORouteDef_Complete.h.

Referenced by buildCurrentRoute(), copy(), and writeXMLDefinition().

std::string Named::myID [protected, inherited]

The begin of the route.

Definition at line 86 of file RORouteDef_Complete.h.

Referenced by addAlternative().

Definition at line 88 of file RORouteDef_Complete.h.

Referenced by buildCurrentRoute(), and copy().


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

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