SUMO - Simulation of Urban MObility
|
An output device that encapsulates cout. More...
#include <OutputDevice_COUT.h>
Public Member Functions | |||
OutputDevice member methods | |||
virtual bool | ok () | ||
returns the information whether one can write into the device | |||
void | close () | ||
Closes the device and removes it from the dictionary. | |||
void | setPrecision (unsigned int precision=OUTPUT_ACCURACY) | ||
Sets the precison or resets it to default. | |||
bool | writeXMLHeader (const std::string &rootElement, const std::string xmlParams="", const std::string &attrs="", const std::string &comment="") | ||
Writes an XML header with optional configuration. | |||
OutputDevice & | openTag (const std::string &xmlElement) | ||
Opens an XML tag. | |||
OutputDevice & | openTag (const SumoXMLTag &xmlElement) | ||
Opens an XML tag. | |||
void | closeOpener () | ||
Ends the most recently opened element start. | |||
bool | closeTag (bool abbreviated=false) | ||
Closes the most recently opened tag. | |||
OutputDevice & | writeAttr (std::string attr, std::string val) | ||
writes an arbitrary attribute | |||
template<typename T > | |||
OutputDevice & | writeAttr (const SumoXMLAttr attr, const T &val) | ||
writes a named attribute | |||
void | lf () | ||
writes a line feed if applicable | |||
bool | isBinary () const | ||
Returns whether we have a binary output. | |||
void | inform (const std::string &msg, const char progress=0) | ||
Retrieves a message to this device. | |||
template<class T > | |||
OutputDevice & | operator<< (const T &t) | ||
Abstract output operator. | |||
Static Public Member Functions | |||
static OutputDevice * | getDevice () | ||
Returns the single cout instance. | |||
static std::string | realString (const SUMOReal v, const int precision=OUTPUT_ACCURACY) | ||
Helper method for string formatting. | |||
static access methods to OutputDevices | |||
static OutputDevice & | getDevice (const std::string &name, const std::string &base="") | ||
Returns the described OutputDevice. | |||
static bool | createDeviceByOption (const std::string &optionName, const std::string &rootElement="") | ||
Creates the device using the output definition stored in the named option. | |||
static OutputDevice & | getDeviceByOption (const std::string &name) throw (IOError, InvalidArgument) | ||
Returns the device described by the option. | |||
static void | closeAll () | ||
Protected Member Functions | |||
Methods that override/implement OutputDevice-methods | |||
std::ostream & | getOStream () | ||
Returns the associated ostream. | |||
virtual void | postWriteHook () | ||
Called after every write access. | |||
Private Member Functions | |||
OutputDevice_COUT () | |||
Constructor
| |||
~OutputDevice_COUT () | |||
Destructor. | |||
Static Private Attributes | |||
static OutputDevice * | myInstance = 0 | ||
my singular instance |
An output device that encapsulates cout.
Definition at line 44 of file OutputDevice_COUT.h.
OutputDevice_COUT::OutputDevice_COUT | ( | ) | [private] |
Constructor
IOError | Should not be thrown by this implementation. |
Definition at line 62 of file OutputDevice_COUT.cpp.
Referenced by getDevice().
OutputDevice_COUT::~OutputDevice_COUT | ( | ) | [private] |
void OutputDevice::close | ( | ) | [inherited] |
Closes the device and removes it from the dictionary.
Definition at line 178 of file OutputDevice.cpp.
References OutputDevice::closeTag(), and OutputDevice::myOutputDevices.
Referenced by RONet::closeOutput(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_Breakpoints::onCmdSave(), GUIParameterTracker::onCmdSave(), PCPolyContainer::save(), RODFDetectorCon::save(), GUISelectedStorage::save(), RODFDetectorCon::saveAsPOIs(), GUIDialog_ViewSettings::saveDecals(), RODFDetectorCon::saveRoutes(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_XML::writeJoinedJunctions(), NWFrame::writeNetwork(), NWWriter_SUMO::writeNetwork(), NWWriter_XML::writeNodes(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_XML::writeTrafficLights(), and RODFDetectorCon::writeValidationDetectors().
void OutputDevice::closeAll | ( | ) | [static, inherited] |
Closes all registered devices
Definition at line 127 of file OutputDevice.cpp.
References OutputDevice::myOutputDevices.
Referenced by GUIRunThread::deleteSim(), and main().
void OutputDevice::closeOpener | ( | ) | [inherited] |
Ends the most recently opened element start.
Writes more or less nothing but ">" and a line feed.
Definition at line 218 of file OutputDevice.cpp.
References OutputFormatter::closeOpener(), OutputDevice::getOStream(), and OutputDevice::myFormatter.
Referenced by MSDevice_Vehroutes::generateOutput(), SUMOVehicleParameter::writeAs(), NWWriter_SUMO::writeDistrict(), NWWriter_SUMO::writeEdge(), NWWriter_SUMO::writeInternalEdge(), NWWriter_SUMO::writeJunction(), NWWriter_SUMO::writeTrafficLights(), RORouteDef_Complete::writeXMLDefinition(), RORouteDef_Alternatives::writeXMLDefinition(), and RORoute::writeXMLDefinition().
bool OutputDevice::closeTag | ( | bool | abbreviated = false | ) | [inherited] |
Closes the most recently opened tag.
The topmost xml-element from the stack is written into the stream as a closing element ("</" + element + ">") and is then removed from the stack. If abbreviated closing is requested, only "/>" is the output.
[in] | name | whether abbreviated closing is performed |
Definition at line 224 of file OutputDevice.cpp.
References OutputFormatter::closeTag(), OutputDevice::getOStream(), OutputDevice::myFormatter, and OutputDevice::postWriteHook().
Referenced by OutputDevice::close(), MSPersonControl::erase(), PCPolyContainer::save(), ROVehicle::saveAllAsXML(), MSVehicleControl::scheduleVehicleRemoval(), MSXMLRawOut::write(), SUMOVTypeParameter::write(), MSMeanData_HBEFA::MSLaneMeanDataValues::write(), MSMeanData_Harmonoise::MSLaneMeanDataValues::write(), ODMatrix::write(), MSMeanData_Net::MSLaneMeanDataValues::write(), MSInstantInductLoop::write(), NWWriter_SUMO::writeConnection(), NWWriter_SUMO::writeDistrict(), MSXMLRawOut::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), NWWriter_SUMO::writeInternalConnection(), NWWriter_SUMO::writeInternalEdge(), NWWriter_SUMO::writeInternalNodes(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeJunction(), MSXMLRawOut::writeLane(), NWWriter_SUMO::writeLane(), NBRequest::writeLaneResponse(), NWWriter_SUMO::writeLocation(), NWWriter_XML::writeNodes(), NWWriter_SUMO::writeProhibitions(), NWWriter_SUMO::writeRoundabout(), NWWriter_SUMO::writeTrafficLights(), MSXMLRawOut::writeVehicle(), RORouteDef_Complete::writeXMLDefinition(), RORouteDef_Alternatives::writeXMLDefinition(), RORoute::writeXMLDefinition(), MSRouteProbe::writeXMLOutput(), and MSMeanData::writeXMLOutput().
bool OutputDevice::createDeviceByOption | ( | const std::string & | optionName, |
const std::string & | rootElement = "" |
||
) | [static, inherited] |
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.
[in] | optionName | The name of the option to use for retrieving the output definition |
[in] | rootElement | The root element to use (XML-output) |
IOError | If the output could not be built for any reason (error message is supplied) |
Definition at line 103 of file OutputDevice.cpp.
References OutputDevice::getDevice(), OptionsCont::getOptions(), and OutputDevice::writeXMLHeader().
Referenced by MSFrame::buildStreams(), MSDevice_Vehroutes::init(), and main().
OutputDevice * OutputDevice_COUT::getDevice | ( | ) | [static] |
Returns the single cout instance.
Creates and returns the cout device.
Definition at line 50 of file OutputDevice_COUT.cpp.
References myInstance, and OutputDevice_COUT().
OutputDevice & OutputDevice::getDevice | ( | const std::string & | name, |
const std::string & | base = "" |
||
) | [static, inherited] |
Returns the described OutputDevice.
Creates and returns the named device. "stdout" and "-" refer to standard out, "hostname:port" initiates socket connection. Otherwise a filename is assumed and the second parameter may be used to give a base directory. If there already is a device with the same name this one is returned.
[in] | name | The description of the output name/port/whatever |
[in] | base | The base path the application is run within |
IOError | If the output could not be built for any reason (error message is supplied) |
Definition at line 66 of file OutputDevice.cpp.
References FileHelpers::checkForRelativity(), OutputDevice::getOStream(), FileHelpers::isSocket(), OutputDevice::myOutputDevices, and OutputDevice::setPrecision().
Referenced by NLHandler::addE1Detector(), NLHandler::addE2Detector(), NLHandler::addEdgeLaneMeanData(), NLHandler::addInstantE1Detector(), NLHandler::addRouteProbeDetector(), NLHandler::addVTypeProbeDetector(), NLHandler::beginE3Detector(), NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), OutputDevice::createDeviceByOption(), OutputDevice::getDeviceByOption(), MsgHandler::initOutputOptions(), MsgHandler::MsgHandler(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_Breakpoints::onCmdSave(), GUIDialog_EditViewport::onCmdSave(), GUIParameterTracker::onCmdSave(), RONet::openOutput(), GUILoadThread::run(), PCPolyContainer::save(), RODFDetectorCon::save(), GUISelectedStorage::save(), RODFDetectorCon::saveAsPOIs(), GUIDialog_ViewSettings::saveDecals(), RODFDetectorCon::saveRoutes(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_XML::writeJoinedJunctions(), NWWriter_OpenDrive::writeNetwork(), NWFrame::writeNetwork(), NWWriter_MATSim::writeNetwork(), NWWriter_SUMO::writeNetwork(), NWWriter_XML::writeNodes(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_XML::writeTrafficLights(), and RODFDetectorCon::writeValidationDetectors().
OutputDevice & OutputDevice::getDeviceByOption | ( | const std::string & | name | ) | throw (IOError, InvalidArgument) [static, inherited] |
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.
[in] | name | The name of the option to use for retrieving the output definition |
IOError | If the output could not be built for any reason (error message is supplied) |
InvalidArgument | If the option with the given name does not exist |
Definition at line 117 of file OutputDevice.cpp.
References OutputDevice::getDevice(), OptionsCont::getOptions(), and OptionsCont::getString().
Referenced by MSPersonControl::erase(), MSDevice_HBEFA::generateOutput(), MSDevice_Vehroutes::generateOutput(), MSDevice_Tripinfo::generateOutput(), main(), MSVehicleControl::scheduleVehicleRemoval(), and MSNet::writeOutput().
std::ostream & OutputDevice_COUT::getOStream | ( | ) | [protected, virtual] |
Returns the associated ostream.
Implements OutputDevice.
Definition at line 71 of file OutputDevice_COUT.cpp.
void OutputDevice::inform | ( | const std::string & | msg, |
const char | progress = 0 |
||
) | [inherited] |
Retrieves a message to this device.
Implementation of the MessageRetriever interface. Writes the given message to the output device.
[in] | msg | The msg to write to the device |
Definition at line 238 of file OutputDevice.cpp.
References OutputDevice::getOStream(), and OutputDevice::postWriteHook().
bool OutputDevice::isBinary | ( | ) | const [inline, inherited] |
Returns whether we have a binary output.
Definition at line 250 of file OutputDevice.h.
References OutputDevice::myAmBinary.
Referenced by MSDevice_Vehroutes::generateOutput().
void OutputDevice::lf | ( | ) | [inline, inherited] |
writes a line feed if applicable
Definition at line 240 of file OutputDevice.h.
References OutputDevice::getOStream(), and OutputDevice::myAmBinary.
Referenced by NWWriter_SUMO::writeLocation(), NWWriter_SUMO::writeNetwork(), and NWWriter_SUMO::writeTrafficLights().
bool OutputDevice::ok | ( | ) | [virtual, inherited] |
returns the information whether one can write into the device
Definition at line 172 of file OutputDevice.cpp.
References OutputDevice::getOStream().
OutputDevice & OutputDevice::openTag | ( | const std::string & | xmlElement | ) | [inherited] |
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.
[in] | xmlElement | Name of element to open |
Definition at line 204 of file OutputDevice.cpp.
References OutputDevice::getOStream(), OutputDevice::myFormatter, and OutputFormatter::openTag().
Referenced by MSPersonControl::erase(), MSDevice_Vehroutes::generateOutput(), MSDevice_HBEFA::generateOutput(), MSDevice_Tripinfo::generateOutput(), PCPolyContainer::save(), MSPerson::MSPersonStage_Walking::tripInfoOutput(), MSPerson::MSPersonStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Waiting::tripInfoOutput(), MSXMLRawOut::write(), SUMOVTypeParameter::write(), ODMatrix::write(), MSInstantInductLoop::write(), SUMOVehicleParameter::writeAs(), NWWriter_SUMO::writeConnection(), NWWriter_SUMO::writeDistrict(), MSXMLRawOut::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), NWWriter_SUMO::writeInternalConnection(), NWWriter_SUMO::writeInternalEdge(), NWWriter_SUMO::writeInternalNodes(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeJunction(), MSXMLRawOut::writeLane(), NWWriter_SUMO::writeLane(), NBRequest::writeLaneResponse(), NWWriter_SUMO::writeLocation(), NWWriter_XML::writeNodes(), MSMeanData::writePrefix(), NWWriter_SUMO::writeProhibitions(), NWWriter_SUMO::writeRoundabout(), NWWriter_SUMO::writeTrafficLights(), MSXMLRawOut::writeVehicle(), RORouteDef_Complete::writeXMLDefinition(), RORouteDef_Alternatives::writeXMLDefinition(), RORoute::writeXMLDefinition(), MSRouteProbe::writeXMLOutput(), MSMeanData::writeXMLOutput(), and MSDevice_Vehroutes::writeXMLRoute().
OutputDevice & OutputDevice::openTag | ( | const SumoXMLTag & | xmlElement | ) | [inherited] |
Opens an XML tag.
Helper method which finds the correct string before calling openTag.
[in] | xmlElement | Id of the element to open |
Definition at line 211 of file OutputDevice.cpp.
References OutputDevice::getOStream(), OutputDevice::myFormatter, and OutputFormatter::openTag().
OutputDevice& OutputDevice::operator<< | ( | const T & | t | ) | [inline, inherited] |
Abstract output operator.
Definition at line 285 of file OutputDevice.h.
References OutputDevice::getOStream(), and OutputDevice::postWriteHook().
void OutputDevice_COUT::postWriteHook | ( | ) | [protected, virtual] |
Called after every write access.
Calls flush on stdout.
Reimplemented from OutputDevice.
Definition at line 77 of file OutputDevice_COUT.cpp.
std::string OutputDevice::realString | ( | const SUMOReal | v, |
const int | precision = OUTPUT_ACCURACY |
||
) | [static, inherited] |
Helper method for string formatting.
[in] | v | The floating point value to be formatted |
[in] | precision | the precision to achieve |
Definition at line 136 of file OutputDevice.cpp.
Referenced by MSDevice_HBEFA::generateOutput(), and MSMeanData_HBEFA::MSLaneMeanDataValues::write().
void OutputDevice::setPrecision | ( | unsigned int | precision = OUTPUT_ACCURACY | ) | [inherited] |
Sets the precison or resets it to default.
[in] | precision | The accuracy (number of digits behind '.') to set |
Definition at line 191 of file OutputDevice.cpp.
References OutputDevice::getOStream().
Referenced by MSVTypeProbe::execute(), OutputDevice::getDevice(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_SUMO::writeLocation(), NWWriter_XML::writeNodes(), RORouteDef_Alternatives::writeXMLDefinition(), and RORoute::writeXMLDefinition().
OutputDevice & OutputDevice::writeAttr | ( | std::string | attr, |
std::string | val | ||
) | [inherited] |
writes an arbitrary attribute
[in] | attr | The attribute (name) |
[in] | val | The attribute value |
Definition at line 249 of file OutputDevice.cpp.
References OutputDevice::getOStream(), OutputDevice::myFormatter, and OutputFormatter::writeAttr().
Referenced by MSDevice_Vehroutes::generateOutput(), SUMOVTypeParameter::write(), MSInstantInductLoop::write(), SUMOVehicleParameter::writeAs(), OutputDevice::writeAttr(), NWWriter_SUMO::writeConnection(), NWWriter_SUMO::writeDistrict(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_SUMO::writeInternalConnection(), NWWriter_SUMO::writeInternalEdge(), NWWriter_SUMO::writeInternalNodes(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeJunction(), NWWriter_SUMO::writeLane(), NBRequest::writeLaneResponse(), NWWriter_SUMO::writeLocation(), NWWriter_XML::writeNodes(), NWWriter_SUMO::writePermissions(), NWFrame::writePositionLong(), NWWriter_SUMO::writePreferences(), MSMeanData::writePrefix(), NWWriter_SUMO::writeProhibitions(), NWWriter_SUMO::writeRoundabout(), NWWriter_SUMO::writeTrafficLights(), RORouteDef_Complete::writeXMLDefinition(), RORouteDef_Alternatives::writeXMLDefinition(), and RORoute::writeXMLDefinition().
OutputDevice& OutputDevice::writeAttr | ( | const SumoXMLAttr | attr, |
const T & | val | ||
) | [inline, inherited] |
writes a named attribute
[in] | attr | The attribute (name) |
[in] | val | The attribute value |
Definition at line 262 of file OutputDevice.h.
References OutputDevice::getOStream(), OutputDevice::myAmBinary, and OutputDevice::writeAttr().
bool OutputDevice::writeXMLHeader | ( | const std::string & | rootElement, |
const std::string | xmlParams = "" , |
||
const std::string & | attrs = "" , |
||
const std::string & | comment = "" |
||
) | [inherited] |
Writes an XML header with optional configuration.
If something has been written (myXMLStack is not empty), nothing is written and false returned.
[in] | rootElement | The root element to use |
[in] | xmlParams | Additional parameters (such as encoding) to include in the <?xml> declaration |
[in] | attrs | Additional attributes to save within the rootElement |
[in] | comment | Additional comment (saved in front the rootElement) |
Check which parameter is used herein
Describe what is saved
Definition at line 197 of file OutputDevice.cpp.
References OutputDevice::getOStream(), OutputDevice::myFormatter, and OutputFormatter::writeXMLHeader().
Referenced by Command_SaveTLSState::Command_SaveTLSState(), Command_SaveTLSSwitches::Command_SaveTLSSwitches(), Command_SaveTLSSwitchStates::Command_SaveTLSSwitchStates(), OutputDevice::createDeviceByOption(), MSVTypeProbe::MSVTypeProbe(), RONet::openOutput(), PCPolyContainer::save(), RODFDetectorCon::save(), RODFDetectorCon::saveAsPOIs(), RODFDetectorCon::saveRoutes(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), NWWriter_XML::writeJoinedJunctions(), NWWriter_SUMO::writeNetwork(), NWWriter_XML::writeNodes(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), NWWriter_XML::writeTrafficLights(), RODFDetectorCon::writeValidationDetectors(), MSRouteProbe::writeXMLDetectorProlog(), MS_E2_ZS_CollectorOverLanes::writeXMLDetectorProlog(), MSInstantInductLoop::writeXMLDetectorProlog(), MSE2Collector::writeXMLDetectorProlog(), MSInductLoop::writeXMLDetectorProlog(), MSE3Collector::writeXMLDetectorProlog(), and MSMeanData::writeXMLDetectorProlog().
OutputDevice * OutputDevice_COUT::myInstance = 0 [static, private] |
my singular instance
Definition at line 84 of file OutputDevice_COUT.h.
Referenced by getDevice(), and ~OutputDevice_COUT().