Eclipse SUMO - Simulation of Urban MObility
OutputDevice Class Referenceabstract

Static storage of an output device and its base (abstract) implementation. More...

#include <OutputDevice.h>

Inheritance diagram for OutputDevice:
Collaboration diagram for OutputDevice:

Static Public Member Functions

static std::string realString (const double v, const int precision=gPrecision)
 Helper method for string formatting. More...
 
static access methods to OutputDevices
static OutputDevicegetDevice (const std::string &name)
 Returns the described OutputDevice. More...
 
static bool createDeviceByOption (const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
 Creates the device using the output definition stored in the named option. More...
 
static OutputDevicegetDeviceByOption (const std::string &name)
 Returns the device described by the option. More...
 
static void closeAll (bool keepErrorRetrievers=false)
 

OutputDevice member methods

static std::map< std::string, OutputDevice * > myOutputDevices
 map from names to output devices More...
 
OutputFormattermyFormatter
 The formatter for XML. More...
 
const bool myAmBinary
 
std::string myFilename
 
 OutputDevice (const bool binary=false, const int defaultIndentation=0, const std::string &filename="")
 Constructor. More...
 
virtual ~OutputDevice ()
 Destructor. More...
 
virtual bool ok ()
 returns the information whether one can write into the device More...
 
const std::string & getFilename ()
 get filename or suitable description of this device More...
 
void close ()
 Closes the device and removes it from the dictionary. More...
 
void setPrecision (int precision=gPrecision)
 Sets the precison or resets it to default. More...
 
int getPrecision ()
 Returns the precison of the underlying stream. More...
 
bool writeXMLHeader (const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
 Writes an XML header with optional configuration. More...
 
template<typename E >
bool writeHeader (const SumoXMLTag &rootElement)
 
OutputDeviceopenTag (const std::string &xmlElement)
 Opens an XML tag. More...
 
OutputDeviceopenTag (const SumoXMLTag &xmlElement)
 Opens an XML tag. More...
 
bool closeTag (const std::string &comment="")
 Closes the most recently opened tag and optionally adds a comment. More...
 
void lf ()
 writes a line feed if applicable More...
 
bool isBinary () const
 Returns whether we have a binary output. More...
 
template<typename T >
OutputDevicewriteAttr (const SumoXMLAttr attr, const T &val)
 writes a named attribute More...
 
template<typename T >
OutputDevicewriteAttr (const std::string &attr, const T &val)
 writes an arbitrary attribute More...
 
OutputDevicewriteNonEmptyAttr (const SumoXMLAttr attr, const std::string &val)
 writes a string attribute only if it is not the empty string and not the string "default" More...
 
OutputDevicewritePreformattedTag (const std::string &val)
 writes a preformatted tag to the device but ensures that any pending tags are closed More...
 
OutputDevicewritePadding (const std::string &val)
 writes padding (ignored for binary output) More...
 
void inform (const std::string &msg, const char progress=0)
 Retrieves a message to this device. More...
 
template<class T >
OutputDeviceoperator<< (const T &t)
 Abstract output operator. More...
 
void flush ()
 
 OutputDevice (const OutputDevice &)
 Invalidated copy constructor. More...
 
virtual std::ostream & getOStream ()=0
 Returns the associated ostream. More...
 
virtual void postWriteHook ()
 Called after every write access. More...
 
OutputDeviceoperator= (const OutputDevice &)
 Invalidated assignment operator. More...
 

Detailed Description

Static storage of an output device and its base (abstract) implementation.

OutputDevices are basically a capsule around an std::ostream, which give a unified access to sockets, files and stdout.

Usually, an application builds as many output devices as needed. Each output device may also be used to save outputs from several sources (several detectors, for example). Building is done using OutputDevice::getDevice() what also parses the given output description in order to decide what kind of an OutputDevice shall be built. OutputDevices are closed via OutputDevice::closeAll(), normally called at the application's end.

Although everything that can be written to a stream can also be written to an OutputDevice, there is special support for XML tags (remembering all open tags to close them at the end). OutputDevices are still lacking support for function pointers with the '<<' operator (no endl, use '
'). The most important method to implement in subclasses is getOStream, the most used part of the interface is the '<<' operator.

The Boolean markers are used rarely and might get removed in future versions.

Definition at line 64 of file OutputDevice.h.

Constructor & Destructor Documentation

◆ OutputDevice() [1/2]

OutputDevice::OutputDevice ( const bool  binary = false,
const int  defaultIndentation = 0,
const std::string &  filename = "" 
)

Constructor.

Definition at line 180 of file OutputDevice.cpp.

References myFormatter.

◆ ~OutputDevice()

OutputDevice::~OutputDevice ( )
virtual

Destructor.

Definition at line 191 of file OutputDevice.cpp.

References myFormatter.

◆ OutputDevice() [2/2]

OutputDevice::OutputDevice ( const OutputDevice )

Invalidated copy constructor.

Member Function Documentation

◆ close()

void OutputDevice::close ( )

Closes the device and removes it from the dictionary.

Definition at line 208 of file OutputDevice.cpp.

References closeTag(), myOutputDevices, and MsgHandler::removeRetrieverFromAllInstances().

Referenced by RONet::cleanup(), AStarRouter< MSEdge, SUMOVehicle, SUMOAbstractRouterPermissions< MSEdge, SUMOVehicle > >::compute(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_Breakpoints::onCmdSave(), GUIDialog_EditViewport::onCmdSave(), GUIParameterTracker::onCmdSave(), GNESelectorFrame::SelectionOperation::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), GNEGenericParameterDialog::GenericParametersOptions::onCmdSaveGenericParameters(), GNETLSEditorFrame::TLSFile::onCmdSaveTLSProgram(), PCPolyContainer::save(), RODFDetectorCon::save(), GUISelectedStorage::save(), GNENet::saveAdditionalsConfirmed(), RODFDetectorCon::saveAsPOIs(), GNENet::saveDemandElementsConfirmed(), PCPolyContainer::saveDlrTDP(), RODFDetectorCon::saveRoutes(), MSStateHandler::saveState(), GNENet::saveTLSPrograms(), GNEAdditional::writeAdditional(), NWWriter_DlrNavteq::writeConnectedLanes(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_XML::writeJoinedJunctions(), NWWriter_DlrNavteq::writeLinksUnsplitted(), NWWriter_SUMO::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_DlrNavteq::writeNodesUnsplitted(), NWWriter_XML::writeParkingAreas(), NWWriter_DlrNavteq::writeProhibitedManoeuvres(), NWWriter_XML::writePTLines(), NWWriter_XML::writePTStops(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_XML::writeStreetSigns(), NWWriter_XML::writeTrafficLights(), NWWriter_DlrNavteq::writeTrafficSignals(), NWWriter_XML::writeTypes(), and RODFDetectorCon::writeValidationDetectors().

◆ closeAll()

void OutputDevice::closeAll ( bool  keepErrorRetrievers = false)
static

Closes all registered devices

Definition at line 127 of file OutputDevice.cpp.

References MsgHandler::getErrorInstance(), MsgHandler::isRetriever(), myOutputDevices, and WRITE_ERROR.

Referenced by MSNet::clearAll(), SystemFrame::close(), and GUIRunThread::deleteSim().

◆ closeTag()

bool OutputDevice::closeTag ( const std::string &  comment = "")

Closes the most recently opened tag and optionally adds a comment.

The topmost xml-element from the stack is written into the stream as a closing element. Depending on the formatter used this may be something like "</" + element + ">" or "/>" or nothing at all.

Returns
Whether a further element existed in the stack and could be closed
Todo:
it is not verified that the topmost element was closed

Definition at line 254 of file OutputDevice.cpp.

References OutputFormatter::closeTag(), getOStream(), myFormatter, and postWriteHook().

Referenced by MSRoutingEngine::adaptEdgeEfforts(), RORouteHandler::addStop(), AGActivityTripWriter::addTrip(), AGActivityTripWriter::AGActivityTripWriter(), MSDevice_ToC::cleanup(), MSDevice_SSM::cleanup(), close(), RORouteHandler::closeContainer(), computeRoutes(), MSRoute::dict_saveState(), MSVTypeProbe::execute(), MSDevice_SSM::flushGlobalMeasures(), MSDevice_Bluelight::generateOutput(), MSDevice_Example::generateOutput(), MSDevice_Tripinfo::generateOutputForUnfinished(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), MSBaseVehicle::getRNG(), MSAbstractLaneChangeModel::laneChangeOutput(), RORouteHandler::myStartElement(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_EditViewport::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), GNEGenericParameterDialog::GenericParametersOptions::onCmdSaveGenericParameters(), GNETLSEditorFrame::TLSFile::onCmdSaveTLSProgram(), MSVehicleControl::removePending(), MSContainer::MSContainerStage_Driving::routeOutput(), MSPerson::MSPersonStage_Walking::routeOutput(), MSContainer::MSContainerStage_Tranship::routeOutput(), MSContainer::routeOutput(), MSPerson::MSPersonStage_Driving::routeOutput(), MSPerson::routeOutput(), MSTransportable::Stage_Waiting::routeOutput(), RODFRouteCont::save(), GUIPropertyScheme< T >::save(), RODFDetectorCon::save(), GUIVisualizationSettings::save(), ROVehicle::saveAsXML(), ROPerson::Ride::saveAsXML(), ROPerson::Walk::saveAsXML(), ROPerson::PersonTrip::saveAsXML(), ROPerson::saveAsXML(), GUIDialog_ViewSettings::saveDecals(), MSStateHandler::saveRNGs(), MSTransportableDevice_Routing::saveState(), MSVehicleTransfer::saveState(), MSDevice_Routing::saveState(), MSDevice_Vehroutes::saveState(), MSDevice_Tripinfo::saveState(), MSInsertionControl::saveState(), MESegment::saveState(), MEVehicle::saveState(), MSVehicleControl::saveState(), MSLane::saveState(), MSVehicle::saveState(), MSStopOut::stopEnded(), MSContainer::MSContainerStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Walking::tripInfoOutput(), MSContainer::MSContainerStage_Tranship::tripInfoOutput(), MSContainer::tripInfoOutput(), MSPerson::MSPersonStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Access::tripInfoOutput(), MSPerson::tripInfoOutput(), MSTransportable::Stage_Waiting::tripInfoOutput(), NBParking::write(), NBPTLine::write(), MSQueueExport::write(), MSEmissionExport::write(), MSBatteryExport::write(), MSFCDExport::write(), MSFullExport::write(), NBPTStop::write(), MSXMLRawOut::write(), MSMeanData_Emissions::MSLaneMeanDataValues::write(), MSMeanData_Harmonoise::MSLaneMeanDataValues::write(), MSMeanData_Amitran::MSLaneMeanDataValues::write(), MSMeanData_Net::MSLaneMeanDataValues::write(), MSInstantInductLoop::write(), SUMOVTypeParameter::write(), ODMatrix::write(), SUMOVehicleParameter::Stop::write(), MSVehicle::Stop::write(), GNEAdditional::writeAdditional(), MSLink::writeApproaching(), NBSign::writeAsPOI(), MSRailSignal::writeBlocks(), MSRailSignal::DriveWay::writeBlocks(), MSChargingStation::writeChargingStationOutput(), NWWriter_SUMO::writeConnection(), GNERide::writeDemandElement(), GNEPersonTrip::writeDemandElement(), GNEWalk::writeDemandElement(), GNERoute::writeDemandElement(), GNEPerson::writeDemandElement(), GNEVehicle::writeDemandElement(), NWWriter_SUMO::writeDistrict(), MSQueueExport::writeEdge(), MSFullExport::writeEdge(), MSXMLRawOut::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitters(), ODMatrix::writeFlows(), NWWriter_OpenDrive::writeGeomLines(), NWWriter_OpenDrive::writeGeomPP3(), writeHeader(), RONet::writeIntermodal(), NWWriter_SUMO::writeInternalConnection(), NWWriter_OpenDrive::writeInternalEdge(), NWWriter_SUMO::writeInternalEdges(), NWWriter_SUMO::writeInternalNodes(), writeInterval(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeJunction(), MSQueueExport::writeLane(), MSFullExport::writeLane(), MSXMLRawOut::writeLane(), NWWriter_SUMO::writeLane(), GeoConvHelper::writeLocation(), NBRequest::writeLogic(), NWWriter_SUMO::writeNetwork(), IntermodalRouter< E, L, N, V >::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_OpenDrive::writeNormalEdge(), MSDevice_SSM::writeOutConflict(), MSDevice_ToC::writeOutput(), MSNet::writeOutput(), MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(), Parameterised::writeParams(), NWWriter_SUMO::writeProhibitions(), NWWriter_OpenDrive::writeRoadObjects(), NWWriter_SUMO::writeRoundabout(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_SUMO::writeStopOffsets(), MSFullExport::writeTLS(), NWWriter_SUMO::writeTrafficLights(), MSFCDExport::writeTransportable(), MSXMLRawOut::writeTransportable(), NBTypeCont::writeTypes(), RODFDetectorCon::writeValidationDetectors(), MSAmitranTrajectories::writeVehicle(), MSXMLRawOut::writeVehicle(), MSFullExport::writeVehicles(), IntermodalRouter< E, L, N, V >::writeWeights(), GUIDialog_EditViewport::writeXML(), PointOfInterest::writeXML(), SUMOPolygon::writeXML(), RORouteDef::writeXMLDefinition(), RORoute::writeXMLDefinition(), TrajectoriesHandler::writeXMLEmissions(), MSRouteProbe::writeXMLOutput(), MSInductLoop::writeXMLOutput(), and MSMeanData::writeXMLOutput().

◆ createDeviceByOption()

bool OutputDevice::createDeviceByOption ( const std::string &  optionName,
const std::string &  rootElement = "",
const std::string &  schemaFile = "" 
)
static

Creates the device using the output definition stored in the named option.

Creates and returns the device named by the option. Asks whether the option and retrieves the name from the option if so. Optionally the XML header gets written as well. Returns whether a device was created (option was set).

Please note, that we do not have to consider the "application base" herein, because this call is only used to get file names of files referenced within XML-declarations of structures which paths already is aware of the cwd.

Parameters
[in]optionNameThe name of the option to use for retrieving the output definition
[in]rootElementThe root element to use (XML-output)
[in]schemaFileThe basename of the schema file to use (XML-output)
Returns
Whether a device was built (the option was set)
Exceptions
IOErrorIf the output could not be built for any reason (error message is supplied)

Definition at line 102 of file OutputDevice.cpp.

References getDevice(), OptionsCont::getOptions(), and writeXMLHeader().

Referenced by MSFrame::buildStreams(), computeRoutes(), MSDevice_Vehroutes::init(), MSRoutingEngine::initWeightUpdate(), main(), and RONet::writeIntermodal().

◆ flush()

void OutputDevice::flush ( )
inline

Definition at line 332 of file OutputDevice.h.

References getOStream(), and postWriteHook().

Referenced by MSVehicleControl::removePending(), and MSMeanData::writeXMLOutput().

◆ getDevice()

OutputDevice & OutputDevice::getDevice ( const std::string &  name)
static

Returns the described OutputDevice.

Creates and returns the named device. "stdout" and "stderr" refer to the relevant console streams, "hostname:port" initiates socket connection. Otherwise a filename is assumed (where "nul" and "/dev/null" do what you would expect on both platforms). If there already is a device with the same name this one is returned.

Parameters
[in]nameThe description of the output name/port/whatever
Returns
The corresponding (built or existing) device
Exceptions
IOErrorIf the output could not be built for any reason (error message is supplied)

Definition at line 55 of file OutputDevice.cpp.

References OutputDevice_COUT::getDevice(), OutputDevice_CERR::getDevice(), OptionsCont::getOptions(), getOStream(), OptionsCont::getString(), FileHelpers::isSocket(), myOutputDevices, FileHelpers::prependToLastPathComponent(), setPrecision(), and StringUtils::toInt().

Referenced by MSDetectorControl::add(), NLDetectorBuilder::buildE2Detector(), NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), NLDetectorBuilder::buildVTypeProbe(), MSDevice_ToC::cleanup(), MSDevice_SSM::cleanup(), AStarRouter< MSEdge, SUMOVehicle, SUMOAbstractRouterPermissions< MSEdge, SUMOVehicle > >::compute(), createDeviceByOption(), GUIDetectorBuilder::createInstantInductLoop(), NLDetectorBuilder::createInstantInductLoop(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), getDeviceByOption(), MsgHandler::initOutputOptions(), NIImporter_OpenDrive::loadNetwork(), main(), MSCalibrator::MSCalibrator(), MSDevice_SSM::MSDevice_SSM(), MSDevice_ToC::MSDevice_ToC(), MsgHandler::MsgHandler(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_Breakpoints::onCmdSave(), GUIDialog_EditViewport::onCmdSave(), GUIParameterTracker::onCmdSave(), GNESelectorFrame::SelectionOperation::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), GNEGenericParameterDialog::GenericParametersOptions::onCmdSaveGenericParameters(), GNETLSEditorFrame::TLSFile::onCmdSaveTLSProgram(), RONet::openOutput(), GUILoadThread::run(), PCPolyContainer::save(), RODFDetectorCon::save(), GUISelectedStorage::save(), GNENet::saveAdditionalsConfirmed(), RODFDetectorCon::saveAsPOIs(), GNENet::saveDemandElementsConfirmed(), PCPolyContainer::saveDlrTDP(), RODFDetectorCon::saveRoutes(), MSStateHandler::saveState(), GNENet::saveTLSPrograms(), GNEAdditional::writeAdditional(), NWWriter_DlrNavteq::writeConnectedLanes(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), RONet::writeIntermodal(), NWWriter_XML::writeJoinedJunctions(), NWWriter_DlrNavteq::writeLinksUnsplitted(), NWWriter_Amitran::writeNetwork(), NWWriter_OpenDrive::writeNetwork(), NWWriter_MATSim::writeNetwork(), NWWriter_SUMO::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_DlrNavteq::writeNodesUnsplitted(), NWWriter_XML::writeParkingAreas(), NWWriter_DlrNavteq::writeProhibitedManoeuvres(), NWWriter_XML::writePTLines(), NWWriter_XML::writePTStops(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_XML::writeStreetSigns(), NWWriter_XML::writeTrafficLights(), NWWriter_DlrNavteq::writeTrafficSignals(), NWWriter_XML::writeTypes(), and RODFDetectorCon::writeValidationDetectors().

◆ getDeviceByOption()

OutputDevice & OutputDevice::getDeviceByOption ( const std::string &  name)
static

Returns the device described by the option.

Returns the device named by the option. If the option is unknown, unset or the device was not created before, InvalidArgument is thrown.

Please note, that we do not have to consider the "application base" herein.

Parameters
[in]nameThe name of the option to use for retrieving the output definition
Returns
The corresponding (built or existing) device
Exceptions
IOErrorIf the output could not be built for any reason (error message is supplied)
InvalidArgumentIf the option with the given name does not exist

Definition at line 117 of file OutputDevice.cpp.

References getDevice(), OptionsCont::getOptions(), OptionsCont::getString(), and myOutputDevices.

Referenced by MSRoutingEngine::adaptEdgeEfforts(), computeRoutes(), MSTransportableControl::erase(), MSDevice_Emissions::generateOutput(), MSDevice_Bluelight::generateOutput(), MSDevice_Example::generateOutput(), MSDevice_Tripinfo::generateOutput(), MSDevice_Tripinfo::generateOutputForUnfinished(), MSBaseVehicle::getRNG(), MSStopOut::init(), MSAbstractLaneChangeModel::laneChangeOutput(), main(), MSVehicleControl::removePending(), MSNet::writeChargingStationOutput(), RONet::writeIntermodal(), MSDevice_Vehroutes::writeOutput(), MSNet::writeOutput(), MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(), and MSNet::writeRailSignalBlocks().

◆ getFilename()

const std::string & OutputDevice::getFilename ( )

get filename or suitable description of this device

Definition at line 203 of file OutputDevice.cpp.

References myFilename.

◆ getOStream()

◆ getPrecision()

int OutputDevice::getPrecision ( )
inline

Returns the precison of the underlying stream.

Definition at line 167 of file OutputDevice.h.

References getOStream(), and writeXMLHeader().

◆ inform()

void OutputDevice::inform ( const std::string &  msg,
const char  progress = 0 
)

Retrieves a message to this device.

Implementation of the MessageRetriever interface. Writes the given message to the output device.

Parameters
[in]msgThe msg to write to the device

Definition at line 268 of file OutputDevice.cpp.

References getOStream(), and postWriteHook().

Referenced by writePadding().

◆ isBinary()

bool OutputDevice::isBinary ( ) const
inline

Returns whether we have a binary output.

Returns
whether we have a binary output

Definition at line 244 of file OutputDevice.h.

References myAmBinary.

Referenced by computeRoutes(), and MSDevice_Vehroutes::writeOutput().

◆ lf()

◆ ok()

bool OutputDevice::ok ( )
virtual

returns the information whether one can write into the device

Returns
Whether the device can be used (stream is good)

Definition at line 197 of file OutputDevice.cpp.

References getOStream().

◆ openTag() [1/2]

OutputDevice & OutputDevice::openTag ( const std::string &  xmlElement)

Opens an XML tag.

An indentation, depending on the current xml-element-stack size, is written followed by the given xml element ("<" + xmlElement) The xml element is added to the stack, then.

Parameters
[in]xmlElementName of element to open
Returns
The OutputDevice for further processing

Definition at line 240 of file OutputDevice.cpp.

References getOStream(), myFormatter, and OutputFormatter::openTag().

Referenced by MSRoutingEngine::adaptEdgeEfforts(), RORouteHandler::addStop(), AGActivityTripWriter::addTrip(), AGActivityTripWriter::AGActivityTripWriter(), MSPerson::MSPersonStage_Walking::beginEventOutput(), MSContainer::MSContainerStage_Tranship::beginEventOutput(), MSTransportable::Stage_Waiting::beginEventOutput(), MSTransportable::Stage_Driving::beginEventOutput(), computeRoutes(), MSRoute::dict_saveState(), MSPerson::MSPersonStage_Walking::endEventOutput(), MSContainer::MSContainerStage_Tranship::endEventOutput(), MSTransportable::Stage_Waiting::endEventOutput(), MSTransportable::Stage_Driving::endEventOutput(), MSVTypeProbe::execute(), MSDevice_SSM::flushGlobalMeasures(), MSDevice_Emissions::generateOutput(), MSDevice_Bluelight::generateOutput(), MSDevice_Example::generateOutput(), MSDevice_Tripinfo::generateOutput(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), MSBaseVehicle::getRNG(), MSAbstractLaneChangeModel::laneChangeOutput(), MSDevice_ToC::MSDevice_ToC(), RORouteHandler::myStartElement(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_EditViewport::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), GNEGenericParameterDialog::GenericParametersOptions::onCmdSaveGenericParameters(), GNETLSEditorFrame::TLSFile::onCmdSaveTLSProgram(), MSMeanData_Amitran::openInterval(), MSMeanData::openInterval(), MSContainer::MSContainerStage_Driving::routeOutput(), MSPerson::MSPersonStage_Walking::routeOutput(), MSContainer::MSContainerStage_Tranship::routeOutput(), MSContainer::routeOutput(), MSPerson::MSPersonStage_Driving::routeOutput(), MSTransportable::Stage_Waiting::routeOutput(), RODFRouteCont::save(), GUIPropertyScheme< T >::save(), RODFDetectorCon::save(), GUIVisualizationSettings::save(), RODFDetectorCon::saveAsPOIs(), ROPerson::Ride::saveAsXML(), ROPerson::Walk::saveAsXML(), ROPerson::PersonTrip::saveAsXML(), GUIDialog_ViewSettings::saveDecals(), MSStateHandler::saveRNGs(), MSTransportableDevice_Routing::saveState(), MSVehicleTransfer::saveState(), MSDevice_Routing::saveState(), MSDevice_Vehroutes::saveState(), MSDevice_Tripinfo::saveState(), MSInsertionControl::saveState(), MESegment::saveState(), MSVehicleControl::saveState(), MSLane::saveState(), GNENet::saveTLSPrograms(), MSStopOut::stopEnded(), MSContainer::MSContainerStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Walking::tripInfoOutput(), MSContainer::MSContainerStage_Tranship::tripInfoOutput(), MSContainer::tripInfoOutput(), MSPerson::MSPersonStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Access::tripInfoOutput(), MSPerson::tripInfoOutput(), MSTransportable::Stage_Waiting::tripInfoOutput(), NBParking::write(), NBPTLine::write(), MSQueueExport::write(), MSEmissionExport::write(), MSBatteryExport::write(), MSFCDExport::write(), MSFullExport::write(), NBPTStop::write(), MSXMLRawOut::write(), MSMeanData_Amitran::MSLaneMeanDataValues::write(), MSInstantInductLoop::write(), SUMOVTypeParameter::write(), ODMatrix::write(), SUMOVehicleParameter::write(), SUMOVehicleParameter::Stop::write(), MSVehicle::Stop::write(), GNEAdditional::writeAdditional(), MSLink::writeApproaching(), NBSign::writeAsPOI(), MSRailSignal::writeBlocks(), MSRailSignal::DriveWay::writeBlocks(), MSChargingStation::writeChargingStationOutput(), NWWriter_SUMO::writeConnection(), GNERide::writeDemandElement(), GNEPersonTrip::writeDemandElement(), GNEWalk::writeDemandElement(), GNERoute::writeDemandElement(), NWWriter_SUMO::writeDistrict(), MSQueueExport::writeEdge(), MSFullExport::writeEdge(), MSXMLRawOut::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), ODMatrix::writeFlows(), NWWriter_OpenDrive::writeGeomLines(), NWWriter_OpenDrive::writeGeomPP3(), writeHeader(), RONet::writeIntermodal(), NWWriter_SUMO::writeInternalConnection(), NWWriter_OpenDrive::writeInternalEdge(), NWWriter_SUMO::writeInternalEdges(), NWWriter_SUMO::writeInternalNodes(), writeInterval(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeJunction(), MSQueueExport::writeLane(), MSFullExport::writeLane(), MSXMLRawOut::writeLane(), NWWriter_SUMO::writeLane(), GeoConvHelper::writeLocation(), NBRequest::writeLogic(), NWWriter_OpenDrive::writeNetwork(), NWWriter_SUMO::writeNetwork(), IntermodalRouter< E, L, N, V >::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_OpenDrive::writeNormalEdge(), MSDevice_SSM::writeOutConflict(), MSDevice_ToC::writeOutput(), MSNet::writeOutput(), MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(), Parameterised::writeParams(), MSMeanData_Amitran::writePrefix(), MSMeanData::writePrefix(), NWWriter_SUMO::writeProhibitions(), NWWriter_OpenDrive::writeRoadObjects(), NWWriter_SUMO::writeRoundabout(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_SUMO::writeStopOffsets(), MSFullExport::writeTLS(), NWWriter_SUMO::writeTrafficLights(), MSFCDExport::writeTransportable(), MSXMLRawOut::writeTransportable(), NBTypeCont::writeTypes(), RODFDetectorCon::writeValidationDetectors(), MSAmitranTrajectories::writeVehicle(), MSXMLRawOut::writeVehicle(), MSFullExport::writeVehicles(), IntermodalRouter< E, L, N, V >::writeWeights(), GUIDialog_EditViewport::writeXML(), PointOfInterest::writeXML(), SUMOPolygon::writeXML(), RORouteDef::writeXMLDefinition(), RORoute::writeXMLDefinition(), TrajectoriesHandler::writeXMLEmissions(), MEInductLoop::writeXMLOutput(), MSRouteProbe::writeXMLOutput(), MSInductLoop::writeXMLOutput(), and MSDevice_Vehroutes::writeXMLRoute().

◆ openTag() [2/2]

OutputDevice & OutputDevice::openTag ( const SumoXMLTag xmlElement)

Opens an XML tag.

Helper method which finds the correct string before calling openTag.

Parameters
[in]xmlElementId of the element to open
Returns
The OutputDevice for further processing

Definition at line 247 of file OutputDevice.cpp.

References getOStream(), myFormatter, and OutputFormatter::openTag().

◆ operator<<()

template<class T >
OutputDevice& OutputDevice::operator<< ( const T &  t)
inline

Abstract output operator.

Returns
The OutputDevice for further processing

Definition at line 326 of file OutputDevice.h.

References getOStream(), and postWriteHook().

◆ operator=()

OutputDevice& OutputDevice::operator= ( const OutputDevice )
private

Invalidated assignment operator.

◆ postWriteHook()

void OutputDevice::postWriteHook ( )
protectedvirtual

Called after every write access.

Default implementation does nothing.

Reimplemented in GUIMessageWindow::MsgOutputDevice, OutputDevice_Network, MsgRetrievingFunction< T >, OutputDevice_CERR, and OutputDevice_COUT.

Definition at line 264 of file OutputDevice.cpp.

Referenced by closeTag(), flush(), inform(), and operator<<().

◆ realString()

std::string OutputDevice::realString ( const double  v,
const int  precision = gPrecision 
)
static

Helper method for string formatting.

Parameters
[in]vThe floating point value to be formatted
[in]precisionthe precision to achieve
Returns
The formatted string

Definition at line 160 of file OutputDevice.cpp.

Referenced by MSDevice_Emissions::generateOutput(), and MSMeanData_Emissions::MSLaneMeanDataValues::write().

◆ setPrecision()

◆ writeAttr() [1/2]

template<typename T >
OutputDevice& OutputDevice::writeAttr ( const SumoXMLAttr  attr,
const T &  val 
)
inline

writes a named attribute

Parameters
[in]attrThe attribute (name)
[in]valThe attribute value
Returns
The OutputDevice for further processing

Definition at line 256 of file OutputDevice.h.

References getOStream(), myAmBinary, PlainXMLFormatter::writeAttr(), and BinaryFormatter::writeAttr().

Referenced by MSRoutingEngine::adaptEdgeEfforts(), AGActivityTripWriter::addTrip(), AGActivityTripWriter::AGActivityTripWriter(), MSPerson::MSPersonStage_Walking::beginEventOutput(), MSContainer::MSContainerStage_Tranship::beginEventOutput(), MSTransportable::Stage_Waiting::beginEventOutput(), MSTransportable::Stage_Driving::beginEventOutput(), computeRoutes(), MSRoute::dict_saveState(), MSPerson::MSPersonStage_Walking::endEventOutput(), MSContainer::MSContainerStage_Tranship::endEventOutput(), MSTransportable::Stage_Waiting::endEventOutput(), MSTransportable::Stage_Driving::endEventOutput(), MSVTypeProbe::execute(), MSDevice_SSM::flushGlobalMeasures(), MSDevice_Bluelight::generateOutput(), MSDevice_Example::generateOutput(), MSDevice_Tripinfo::generateOutput(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), MSBaseVehicle::getRNG(), MSAbstractLaneChangeModel::laneChangeOutput(), GUIDialog_ViewSettings::onCmdExportSetting(), GNEGenericParameterDialog::GenericParametersOptions::onCmdSaveGenericParameters(), GNETLSEditorFrame::TLSFile::onCmdSaveTLSProgram(), MSMeanData_Amitran::openInterval(), MSMeanData::openInterval(), RONet::openOutput(), GUIVisualizationTextSettings::print(), GUIVisualizationSizeSettings::print(), MSContainer::MSContainerStage_Driving::routeOutput(), MSPerson::MSPersonStage_Walking::routeOutput(), MSContainer::MSContainerStage_Tranship::routeOutput(), MSContainer::routeOutput(), MSPerson::MSPersonStage_Driving::routeOutput(), MSPerson::routeOutput(), MSTransportable::Stage_Waiting::routeOutput(), RODFRouteCont::save(), GUIPropertyScheme< T >::save(), RODFDetectorCon::save(), GUIVisualizationSettings::save(), RODFDetectorCon::saveAsPOIs(), ROVehicle::saveAsXML(), ROPerson::Ride::saveAsXML(), ROPerson::Walk::saveAsXML(), ROPerson::PersonTrip::saveAsXML(), GUIDialog_ViewSettings::saveDecals(), MSStateHandler::saveRNGs(), MSStateHandler::saveState(), MSTransportableDevice_Routing::saveState(), MSVehicleTransfer::saveState(), MSDevice_Routing::saveState(), MSDevice_Vehroutes::saveState(), MSDevice_Tripinfo::saveState(), MSInsertionControl::saveState(), MESegment::saveState(), MEVehicle::saveState(), MSBaseVehicle::saveState(), MSVehicleControl::saveState(), MSLane::saveState(), MSVehicle::saveState(), MSStopOut::stopEnded(), MSContainer::MSContainerStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Walking::tripInfoOutput(), MSContainer::MSContainerStage_Tranship::tripInfoOutput(), MSContainer::tripInfoOutput(), MSPerson::MSPersonStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Access::tripInfoOutput(), MSPerson::tripInfoOutput(), MSTransportable::Stage_Waiting::tripInfoOutput(), NBParking::write(), NBPTLine::write(), MSQueueExport::write(), MSEmissionExport::write(), MSBatteryExport::write(), MSFCDExport::write(), NBPTStop::write(), MSMeanData_Harmonoise::MSLaneMeanDataValues::write(), MSMeanData_Amitran::MSLaneMeanDataValues::write(), MSMeanData_Net::MSLaneMeanDataValues::write(), MSInstantInductLoop::write(), SUMOVTypeParameter::write(), ODMatrix::write(), SUMOVehicleParameter::write(), SUMOVehicleParameter::Stop::write(), MSVehicle::Stop::write(), GNEAdditional::writeAdditional(), MSLink::writeApproaching(), NBSign::writeAsPOI(), MSRailSignal::writeBlocks(), MSRailSignal::DriveWay::writeBlocks(), MSChargingStation::writeChargingStationOutput(), NWWriter_SUMO::writeConnection(), ODMatrix::writeDefaultAttrs(), GNERide::writeDemandElement(), GNEPersonTrip::writeDemandElement(), GNEWalk::writeDemandElement(), GNERoute::writeDemandElement(), GNEPerson::writeDemandElement(), GNEVehicle::writeDemandElement(), NWWriter_SUMO::writeDistrict(), MSFullExport::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), ODMatrix::writeFlows(), NWWriter_OpenDrive::writeGeomLines(), NWWriter_OpenDrive::writeGeomPP3(), RONet::writeIntermodal(), NWWriter_SUMO::writeInternalConnection(), NWWriter_OpenDrive::writeInternalEdge(), NWWriter_SUMO::writeInternalEdges(), NWWriter_SUMO::writeInternalNodes(), writeInterval(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeJunction(), MSQueueExport::writeLane(), MSFullExport::writeLane(), MSXMLRawOut::writeLane(), NWWriter_SUMO::writeLane(), GeoConvHelper::writeLocation(), NBRequest::writeLogic(), NWWriter_SUMO::writeNetwork(), IntermodalRouter< E, L, N, V >::writeNetwork(), NWWriter_XML::writeNodes(), writeNonEmptyAttr(), NWWriter_OpenDrive::writeNormalEdge(), MSDevice_SSM::writeOutConflict(), MSDevice_ToC::writeOutput(), MSNet::writeOutput(), MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(), Parameterised::writeParams(), writePermissions(), NWFrame::writePositionLong(), writePreferences(), MSMeanData_Amitran::writePrefix(), MSMeanData::writePrefix(), NWWriter_SUMO::writeProhibitions(), NWWriter_OpenDrive::writeRoadObjects(), NWWriter_SUMO::writeRoundabout(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_SUMO::writeStopOffsets(), MSFullExport::writeTLS(), NWWriter_SUMO::writeTrafficLights(), MSFCDExport::writeTransportable(), MSXMLRawOut::writeTransportable(), NBTypeCont::writeTypes(), RODFDetectorCon::writeValidationDetectors(), MSAmitranTrajectories::writeVehicle(), MSXMLRawOut::writeVehicle(), MSFullExport::writeVehicles(), IntermodalRouter< E, L, N, V >::writeWeights(), GUIDialog_EditViewport::writeXML(), PointOfInterest::writeXML(), SUMOPolygon::writeXML(), RORouteDef::writeXMLDefinition(), RORoute::writeXMLDefinition(), TrajectoriesHandler::writeXMLEmissions(), MEInductLoop::writeXMLOutput(), MSInductLoop::writeXMLOutput(), and MSDevice_Vehroutes::writeXMLRoute().

◆ writeAttr() [2/2]

template<typename T >
OutputDevice& OutputDevice::writeAttr ( const std::string &  attr,
const T &  val 
)
inline

writes an arbitrary attribute

Parameters
[in]attrThe attribute (name)
[in]valThe attribute value
Returns
The OutputDevice for further processing

Definition at line 273 of file OutputDevice.h.

References getOStream(), myAmBinary, PlainXMLFormatter::writeAttr(), and BinaryFormatter::writeAttr().

◆ writeHeader()

template<typename E >
bool OutputDevice::writeHeader ( const SumoXMLTag rootElement)
inline

Definition at line 188 of file OutputDevice.h.

References closeTag(), getOStream(), myAmBinary, myFormatter, and openTag().

Referenced by RONet::openOutput(), and MSStateHandler::saveState().

◆ writeNonEmptyAttr()

OutputDevice& OutputDevice::writeNonEmptyAttr ( const SumoXMLAttr  attr,
const std::string &  val 
)
inline

writes a string attribute only if it is not the empty string and not the string "default"

Parameters
[in]attrThe attribute (name)
[in]valThe attribute value
Returns
The OutputDevice for further processing

Definition at line 289 of file OutputDevice.h.

References writeAttr().

Referenced by SUMOVehicleParameter::write(), and RODFDetector::writeEmitterDefinition().

◆ writePadding()

OutputDevice& OutputDevice::writePadding ( const std::string &  val)
inline

writes padding (ignored for binary output)

Definition at line 308 of file OutputDevice.h.

References getOStream(), inform(), myFormatter, and OutputFormatter::writePadding().

Referenced by NBRequest::writeLogic(), and NWWriter_SUMO::writeTrafficLights().

◆ writePreformattedTag()

OutputDevice& OutputDevice::writePreformattedTag ( const std::string &  val)
inline

writes a preformatted tag to the device but ensures that any pending tags are closed

Parameters
[in]valThe preformatted data
Returns
The OutputDevice for further processing

Definition at line 302 of file OutputDevice.h.

References getOStream(), myFormatter, and OutputFormatter::writePreformattedTag().

Referenced by computeRoutes(), and RONet::saveAndRemoveRoutesUntil().

◆ writeXMLHeader()

bool OutputDevice::writeXMLHeader ( const std::string &  rootElement,
const std::string &  schemaFile,
std::map< SumoXMLAttr, std::string >  attrs = std::map<SumoXMLAttr, std::string>() 
)

Writes an XML header with optional configuration.

If something has been written (myXMLStack is not empty), nothing is written and false returned.

Parameters
[in]rootElementThe root element to use
[in]schemaFileThe basename of the schema file to use
[in]attrsAdditional attributes to save within the rootElement
Returns
Whether the header could be written (stack was empty)
Todo:
Describe what is saved

Definition at line 228 of file OutputDevice.cpp.

References getOStream(), myFormatter, SUMO_ATTR_SCHEMA_LOCATION, SUMO_ATTR_XMLNS, and OutputFormatter::writeXMLHeader().

Referenced by Command_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), createDeviceByOption(), NBRailwayTopologyAnalyzer::getBrokenRailNodes(), getPrecision(), NIImporter_OpenDrive::loadNetwork(), MSDevice_SSM::MSDevice_SSM(), MSVTypeProbe::MSVTypeProbe(), GNEGenericParameterDialog::GenericParametersOptions::onCmdSaveGenericParameters(), GNETLSEditorFrame::TLSFile::onCmdSaveTLSProgram(), PCPolyContainer::save(), RODFDetectorCon::save(), GNENet::saveAdditionalsConfirmed(), RODFDetectorCon::saveAsPOIs(), GNENet::saveDemandElementsConfirmed(), RODFDetectorCon::saveRoutes(), GNEAdditional::writeAdditional(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_XML::writeParkingAreas(), NWWriter_XML::writePTLines(), NWWriter_XML::writePTStops(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_XML::writeStreetSigns(), NWWriter_XML::writeTrafficLights(), NWWriter_XML::writeTypes(), RODFDetectorCon::writeValidationDetectors(), MEInductLoop::writeXMLDetectorProlog(), MSCalibrator::writeXMLDetectorProlog(), MSRouteProbe::writeXMLDetectorProlog(), MSInstantInductLoop::writeXMLDetectorProlog(), MSMeanData_Amitran::writeXMLDetectorProlog(), MSInductLoop::writeXMLDetectorProlog(), MSE3Collector::writeXMLDetectorProlog(), MSMeanData::writeXMLDetectorProlog(), and MSE2Collector::writeXMLDetectorProlog().

Field Documentation

◆ myAmBinary

const bool OutputDevice::myAmBinary
private

Definition at line 357 of file OutputDevice.h.

Referenced by isBinary(), lf(), writeAttr(), and writeHeader().

◆ myFilename

std::string OutputDevice::myFilename
protected

◆ myFormatter

OutputFormatter* OutputDevice::myFormatter
private

The formatter for XML.

Definition at line 355 of file OutputDevice.h.

Referenced by closeTag(), openTag(), OutputDevice(), writeHeader(), writePadding(), writePreformattedTag(), writeXMLHeader(), and ~OutputDevice().

◆ myOutputDevices

std::map< std::string, OutputDevice * > OutputDevice::myOutputDevices
staticprivate

map from names to output devices

Definition at line 350 of file OutputDevice.h.

Referenced by close(), closeAll(), getDevice(), and getDeviceByOption().


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