MSXMLRawOut Class Reference

#include <MSXMLRawOut.h>


Detailed Description

Realises dumping the complete network state.

The class offers a static method, which writes the complete dump of the given network into the given OutputDevice.

Todo:
consider error-handling on write (using IOError)

Definition at line 56 of file MSXMLRawOut.h.


Static Public Member Functions

static void write (OutputDevice &of, const MSEdgeControl &ec, SUMOTime timestep) throw (IOError)
 Writes the complete network state of the given edges into the given device.
static void writeVehicle (OutputDevice &of, const SUMOVehicle &veh) throw (IOError)
 Writes the dump of the given vehicle into the given device.

Private Member Functions

 MSXMLRawOut (const MSXMLRawOut &)
 Invalidated copy constructor.
MSXMLRawOutoperator= (const MSXMLRawOut &)
 Invalidated assignment operator.

Static Private Member Functions

static void writeEdge (OutputDevice &of, const MSEdge &edge) throw (IOError)
 Writes the dump of the given edge into the given device.
static void writeLane (OutputDevice &of, const MSLane &lane) throw (IOError)
 Writes the dump of the given lane into the given device.

Constructor & Destructor Documentation

MSXMLRawOut::MSXMLRawOut ( const MSXMLRawOut  )  [private]

Invalidated copy constructor.


Member Function Documentation

MSXMLRawOut& MSXMLRawOut::operator= ( const MSXMLRawOut  )  [private]

Invalidated assignment operator.

void MSXMLRawOut::write ( OutputDevice of,
const MSEdgeControl ec,
SUMOTime  timestep 
) throw (IOError) [static]

Writes the complete network state of the given edges into the given device.

Opens the current time step, goes through the edges and writes each using writeEdge.

Parameters:
[in] of The output device to use
[in] ec The EdgeControl which holds the edges to write
[in] timestep The current time step
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Definition at line 51 of file MSXMLRawOut.cpp.

References time2string().

Referenced by MSNet::writeOutput().

00052                                                      {
00053     of.openTag("timestep") << " time=\"" << time2string(timestep) << "\">\n";
00054     const std::vector<MSEdge*> &edges = ec.getEdges();
00055     for (std::vector<MSEdge*>::const_iterator e=edges.begin(); e!=edges.end(); ++e) {
00056         writeEdge(of, **e);
00057     }
00058     of.closeTag();
00059 }

void MSXMLRawOut::writeEdge ( OutputDevice of,
const MSEdge edge 
) throw (IOError) [static, private]

Writes the dump of the given edge into the given device.

If the edge is not empty or also empty edges shall be dumped, the edge description is opened and writeLane is called for each lane.

Parameters:
[in] of The output device to use
[in] edge The edge to dump
Todo:
MSGlobals::gOmitEmptyEdgesOnDump should not be used; rather the according option read in write
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Definition at line 63 of file MSXMLRawOut.cpp.

References MSGlobals::gOmitEmptyEdgesOnDump.

00063                                                                           {
00064     //en
00065     bool dump = !MSGlobals::gOmitEmptyEdgesOnDump;
00066     if (!dump) {
00067 #ifdef HAVE_MESOSIM
00068         if (MSGlobals::gUseMesoSim) {
00069             MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(edge);
00070             while (seg != 0) {
00071                 if (seg->getCarNumber()!=0) {
00072                     dump = true;
00073                     break;
00074                 }
00075                 seg = seg->getNextSegment();
00076             }
00077         } else {
00078 #endif
00079             const std::vector<MSLane*> &lanes = edge.getLanes();
00080             for (std::vector<MSLane*>::const_iterator lane=lanes.begin(); lane!=lanes.end(); ++lane) {
00081                 if (((**lane).getVehicleNumber()!=0)) {
00082                     dump = true;
00083                     break;
00084                 }
00085             }
00086 #ifdef HAVE_MESOSIM
00087         }
00088 #endif
00089     }
00090     //en
00091     if (dump) {
00092         of.openTag("edge") << " id=\"" << edge.getID() << "\">\n";
00093 #ifdef HAVE_MESOSIM
00094         if (MSGlobals::gUseMesoSim) {
00095             MESegment* seg = MSGlobals::gMesoNet->getSegmentForEdge(edge);
00096             while (seg != 0) {
00097                 seg->writeVehicles(of);
00098                 seg = seg->getNextSegment();
00099             }
00100         } else {
00101 #endif
00102             const std::vector<MSLane*> &lanes = edge.getLanes();
00103             for (std::vector<MSLane*>::const_iterator lane=lanes.begin(); lane!=lanes.end(); ++lane) {
00104                 writeLane(of, **lane);
00105             }
00106 #ifdef HAVE_MESOSIM
00107         }
00108 #endif
00109         of.closeTag();
00110     }
00111 }

void MSXMLRawOut::writeLane ( OutputDevice of,
const MSLane lane 
) throw (IOError) [static, private]

Writes the dump of the given lane into the given device.

Opens the lane description and goes through all vehicles, calling writeVehicle for each.

Parameters:
[in] of The output device to use
[in] lane The lane to dump
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Definition at line 115 of file MSXMLRawOut.cpp.

00115                                                                           {
00116     of.openTag("lane") << " id=\"" << lane.myID << "\"";
00117     if (lane.getVehicleNumber()!=0) {
00118         of << ">\n";
00119         for (std::vector<MSVehicle*>::const_iterator veh = lane.myVehBuffer.begin();
00120                 veh != lane.myVehBuffer.end(); ++veh) {
00121             writeVehicle(of, **veh);
00122         }
00123         for (MSLane::VehCont::const_iterator veh = lane.myVehicles.begin();
00124                 veh != lane.myVehicles.end(); ++veh) {
00125             writeVehicle(of, **veh);
00126         }
00127     }
00128     of.closeTag(lane.getVehicleNumber()==0);
00129 }

void MSXMLRawOut::writeVehicle ( OutputDevice of,
const SUMOVehicle veh 
) throw (IOError) [static]

Writes the dump of the given vehicle into the given device.

Parameters:
[in] of The output device to use
[in] veh The vehicle to dump
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Definition at line 133 of file MSXMLRawOut.cpp.

00133                                                                                  {
00134     of.openTag("vehicle") << " id=\"" << veh.getID() << "\" pos=\""
00135     << veh.getPositionOnLane() << "\" speed=\"" << veh.getSpeed() << "\"";
00136     of.closeTag(true);
00137 }


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

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