SUMO - Simulation of Urban MObility
OutputDevice_Network Class Reference

An output device for TCP/IP network connections. More...

#include <OutputDevice_Network.h>

Inheritance diagram for OutputDevice_Network:
Inheritance graph
Collaboration diagram for OutputDevice_Network:
Collaboration graph

Public Member Functions

 OutputDevice_Network (const std::string &host, const int port)
 Constructor. More...
 
 ~OutputDevice_Network ()
 Destructor. More...
 
OutputDevice member methods
virtual bool ok ()
 returns the information whether one can write into the 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 ()
 Closes the most recently opened tag. 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...
 
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...
 

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 ()
 

Protected Member Functions

Methods that override/implement OutputDevice-methods
std::ostream & getOStream ()
 Returns the associated ostream. More...
 
virtual void postWriteHook ()
 Sends the data which was written to the string stream over the socket. More...
 

Private Attributes

std::ostringstream myMessage
 packet buffer More...
 
tcpip::SocketmySocket
 the socket to transfer the data More...
 

Detailed Description

An output device for TCP/IP network connections.

The implementation uses a portable socket implementation from the Shawn project (shawn.sf.net) located in src/foreign/tcpip/socket.h. It uses an internal storage for the messages, which is sent via the socket when "postWriteHook" is called.

See also
postWriteHook

Definition at line 56 of file OutputDevice_Network.h.

Constructor & Destructor Documentation

◆ OutputDevice_Network()

OutputDevice_Network::OutputDevice_Network ( const std::string &  host,
const int  port 
)

Constructor.

Parameters
[in]hostThe host to connect
[in]portThe port to connect
Exceptions
IOErrorIf the connection could not be established

Definition at line 48 of file OutputDevice_Network.cpp.

References tcpip::Socket::connect(), mySocket, toString(), and tcpip::SocketException::what().

◆ ~OutputDevice_Network()

OutputDevice_Network::~OutputDevice_Network ( )

Destructor.

Definition at line 76 of file OutputDevice_Network.cpp.

References tcpip::Socket::close(), and mySocket.

Member Function Documentation

◆ close()

void OutputDevice::close ( )
inherited

Closes the device and removes it from the dictionary.

Definition at line 205 of file OutputDevice.cpp.

References OutputDevice::closeTag(), and OutputDevice::myOutputDevices.

Referenced by RONet::cleanup(), AStarRouter< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_Breakpoints::onCmdSave(), GUIDialog_EditViewport::onCmdSave(), GUIParameterTracker::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), PCPolyContainer::save(), RODFDetectorCon::save(), GUISelectedStorage::save(), GNENet::saveAdditionals(), RODFDetectorCon::saveAsPOIs(), PCPolyContainer::saveDlrTDP(), RODFDetectorCon::saveRoutes(), GNENet::saveShapes(), MSStateHandler::saveState(), GNEVariableSpeedSign::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 ( )
staticinherited

Closes all registered devices

Definition at line 133 of file OutputDevice.cpp.

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

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

◆ closeTag()

bool OutputDevice::closeTag ( )
inherited

Closes the most recently opened tag.

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 250 of file OutputDevice.cpp.

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

Referenced by MSDevice_Routing::adaptEdgeEfforts(), RORouteHandler::addStop(), AGActivityTripWriter::addTrip(), AGActivityTripWriter::AGActivityTripWriter(), MSDevice_SSM::cleanup(), OutputDevice::close(), RORouteHandler::closeContainer(), computeRoutes(), MSRoute::dict_saveState(), MSVTypeProbe::execute(), MSDevice_Bluelight::generateOutput(), MSDevice_Example::generateOutput(), MSDevice_Tripinfo::generateOutputForUnfinished(), MSBaseVehicle::getSingularType(), MSAbstractLaneChangeModel::laneChangeOutput(), RORouteHandler::myStartElement(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_EditViewport::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), MSContainer::MSContainerStage_Driving::routeOutput(), MSPerson::MSPersonStage_Walking::routeOutput(), MSContainer::MSContainerStage_Tranship::routeOutput(), MSContainer::routeOutput(), MSPerson::MSPersonStage_Driving::routeOutput(), MSTransportable::Stage_Waiting::routeOutput(), MSPerson::routeOutput(), RODFRouteCont::save(), GUIPropertyScheme< T >::save(), RODFDetectorCon::save(), GUIVisualizationSettings::save(), ROVehicle::saveAsXML(), ROPerson::Ride::saveAsXML(), ROPerson::Walk::saveAsXML(), ROPerson::saveAsXML(), GUIDialog_ViewSettings::saveDecals(), MSVehicleTransfer::saveState(), MSDevice_Vehroutes::saveState(), MSDevice_Tripinfo::saveState(), MESegment::saveState(), MEVehicle::saveState(), MSVehicleControl::saveState(), MSLane::saveState(), MSVehicle::saveState(), MSVehicleControl::scheduleVehicleRemoval(), MSStopOut::stopEnded(), MSContainer::MSContainerStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Walking::tripInfoOutput(), MSContainer::MSContainerStage_Tranship::tripInfoOutput(), MSContainer::tripInfoOutput(), MSPerson::MSPersonStage_Driving::tripInfoOutput(), MSTransportable::Stage_Waiting::tripInfoOutput(), MSPerson::tripInfoOutput(), NBPTLine::write(), NBParking::write(), MSBatteryExport::write(), MSQueueExport::write(), MSEmissionExport::write(), MSFCDExport::write(), MSFullExport::write(), NBPTStop::write(), MSXMLRawOut::write(), MSMeanData_Emissions::MSLaneMeanDataValues::write(), MSMeanData_Harmonoise::MSLaneMeanDataValues::write(), SUMOVTypeParameter::write(), MSMeanData_Amitran::MSLaneMeanDataValues::write(), MSMeanData_Net::MSLaneMeanDataValues::write(), MSInstantInductLoop::write(), ODMatrix::write(), SUMOVehicleParameter::Stop::write(), MSVehicle::Stop::write(), GNEVaporizer::writeAdditional(), GNERouteProbe::writeAdditional(), GNEDetectorE3::writeAdditional(), GNEChargingStation::writeAdditional(), GNEDetectorE1::writeAdditional(), GNEDetectorEntry::writeAdditional(), GNEDetectorExit::writeAdditional(), GNEVariableSpeedSign::writeAdditional(), GNEDetectorE2::writeAdditional(), GNERerouter::writeAdditional(), GNEBusStop::writeAdditional(), GNEContainerStop::writeAdditional(), GNECalibrator::writeAdditional(), MSLink::writeApproaching(), NBSign::writeAsPOI(), MSChargingStation::writeChargingStationOutput(), GNEClosingLaneReroute::writeClosingLaneReroute(), GNEClosingReroute::writeClosingReroute(), NWWriter_SUMO::writeConnection(), NBRequest::writeCrossingResponse(), GNEDestProbReroute::writeDestProbReroute(), NWWriter_SUMO::writeDistrict(), MSQueueExport::writeEdge(), MSFullExport::writeEdge(), MSXMLRawOut::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitters(), GNECalibratorFlow::writeFlow(), ODMatrix::writeFlows(), NWWriter_OpenDrive::writeGeomLines(), NWWriter_OpenDrive::writeGeomPP3(), OutputDevice::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(), NBRequest::writeLaneResponse(), GeoConvHelper::writeLocation(), NWWriter_SUMO::writeNetwork(), IntermodalRouter< E, L, N, V >::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_OpenDrive::writeNormalEdge(), MSDevice_SSM::writeOutConflict(), MSNet::writeOutput(), MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(), Parameterised::writeParams(), NWWriter_SUMO::writeProhibitions(), GNERerouterInterval::writeRerouterInterval(), NWWriter_SUMO::writeRoundabout(), GNECalibratorRoute::writeRoute(), GNERouteProbReroute::writeRouteProbReroute(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), GNEVariableSpeedSignStep::writeStep(), MSFullExport::writeTLS(), NWWriter_SUMO::writeTrafficLights(), MSFCDExport::writeTransportable(), MSXMLRawOut::writeTransportable(), NBTypeCont::writeTypes(), RODFDetectorCon::writeValidationDetectors(), MSAmitranTrajectories::writeVehicle(), MSXMLRawOut::writeVehicle(), MSFullExport::writeVehicles(), GNECalibratorVehicleType::writeVehicleType(), IntermodalRouter< E, L, N, V >::writeWeights(), GUIDialog_EditViewport::writeXML(), SUMOPolygon::writeXML(), PointOfInterest::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 = "" 
)
staticinherited

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 108 of file OutputDevice.cpp.

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

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

◆ getDevice()

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

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 61 of file OutputDevice.cpp.

References TplConvert::_2int(), OutputDevice_COUT::getDevice(), OutputDevice_CERR::getDevice(), OptionsCont::getOptions(), OutputDevice::getOStream(), OptionsCont::getString(), FileHelpers::isSocket(), OutputDevice::myOutputDevices, FileHelpers::prependToLastPathComponent(), and OutputDevice::setPrecision().

Referenced by MSDetectorControl::add(), NLDetectorBuilder::buildE2Detector(), NLDiscreteEventBuilder::buildSaveTLStateCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchesCommand(), NLDiscreteEventBuilder::buildSaveTLSwitchStatesCommand(), NLDetectorBuilder::buildVTypeProbe(), MSDevice_SSM::cleanup(), AStarRouter< MSEdge, SUMOVehicle, prohibited_withPermissions< MSEdge, SUMOVehicle > >::compute(), OutputDevice::createDeviceByOption(), GUIDetectorBuilder::createInstantInductLoop(), NLDetectorBuilder::createInstantInductLoop(), OutputDevice::getDeviceByOption(), MsgHandler::initOutputOptions(), main(), MSCalibrator::MSCalibrator(), MSDevice_SSM::MSDevice_SSM(), MsgHandler::MsgHandler(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_Breakpoints::onCmdSave(), GUIDialog_EditViewport::onCmdSave(), GUIParameterTracker::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), RONet::openOutput(), GUILoadThread::run(), PCPolyContainer::save(), RODFDetectorCon::save(), GUISelectedStorage::save(), GNENet::saveAdditionals(), RODFDetectorCon::saveAsPOIs(), PCPolyContainer::saveDlrTDP(), RODFDetectorCon::saveRoutes(), GNENet::saveShapes(), MSStateHandler::saveState(), GNEVariableSpeedSign::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)
staticinherited

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 123 of file OutputDevice.cpp.

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

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

◆ getOStream()

std::ostream & OutputDevice_Network::getOStream ( )
protectedvirtual

Returns the associated ostream.

The stream is an ostringstream, actually, into which the message is written. It is sent when postWriteHook is called.

Returns
The used stream
See also
postWriteHook

Implements OutputDevice.

Definition at line 83 of file OutputDevice_Network.cpp.

References myMessage.

◆ getPrecision()

int OutputDevice::getPrecision ( )
inlineinherited

Returns the precison of the underlying stream.

Definition at line 171 of file OutputDevice.h.

References OutputDevice::getOStream(), and OutputDevice::writeXMLHeader().

◆ inform()

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.

Parameters
[in]msgThe msg to write to the device

Definition at line 264 of file OutputDevice.cpp.

References OutputDevice::getOStream(), and OutputDevice::postWriteHook().

Referenced by OutputDevice::writePreformattedTag().

◆ isBinary()

bool OutputDevice::isBinary ( ) const
inlineinherited

Returns whether we have a binary output.

Returns
whether we have a binary output

Definition at line 248 of file OutputDevice.h.

References OutputDevice::myAmBinary.

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

◆ lf()

◆ ok()

◆ openTag() [1/2]

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.

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

Definition at line 236 of file OutputDevice.cpp.

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

Referenced by MSDevice_Routing::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_Emissions::generateOutput(), MSDevice_Bluelight::generateOutput(), MSDevice_Example::generateOutput(), MSDevice_Tripinfo::generateOutput(), MSBaseVehicle::getSingularType(), MSAbstractLaneChangeModel::laneChangeOutput(), MSDevice_SSM::MSDevice_SSM(), RORouteHandler::myStartElement(), GUIDialog_ViewSettings::onCmdExportSetting(), GUIDialog_EditViewport::onCmdSave(), GUIDialog_ViewSettings::onCmdSaveDecals(), 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(), GNENet::saveAdditionals(), RODFDetectorCon::saveAsPOIs(), ROPerson::Ride::saveAsXML(), ROPerson::Walk::saveAsXML(), ROPerson::saveAsXML(), GUIDialog_ViewSettings::saveDecals(), GNENet::saveShapes(), MSVehicleTransfer::saveState(), MSDevice_Vehroutes::saveState(), MSDevice_Tripinfo::saveState(), MESegment::saveState(), MEVehicle::saveState(), MSVehicleControl::saveState(), MSLane::saveState(), MSStopOut::stopEnded(), MSContainer::MSContainerStage_Driving::tripInfoOutput(), MSPerson::MSPersonStage_Walking::tripInfoOutput(), MSContainer::MSContainerStage_Tranship::tripInfoOutput(), MSContainer::tripInfoOutput(), MSPerson::MSPersonStage_Driving::tripInfoOutput(), MSTransportable::Stage_Waiting::tripInfoOutput(), MSPerson::tripInfoOutput(), NBPTLine::write(), NBParking::write(), MSEmissionExport::write(), MSBatteryExport::write(), MSQueueExport::write(), MSFCDExport::write(), MSFullExport::write(), NBPTStop::write(), MSXMLRawOut::write(), SUMOVTypeParameter::write(), MSMeanData_Amitran::MSLaneMeanDataValues::write(), MSInstantInductLoop::write(), ODMatrix::write(), SUMOVehicleParameter::write(), SUMOVehicleParameter::Stop::write(), MSVehicle::Stop::write(), GNEVaporizer::writeAdditional(), GNERouteProbe::writeAdditional(), GNEDetectorE3::writeAdditional(), GNEChargingStation::writeAdditional(), GNEDetectorE1::writeAdditional(), GNEDetectorEntry::writeAdditional(), GNEDetectorExit::writeAdditional(), GNEVariableSpeedSign::writeAdditional(), GNEDetectorE2::writeAdditional(), GNERerouter::writeAdditional(), GNEBusStop::writeAdditional(), GNEContainerStop::writeAdditional(), GNECalibrator::writeAdditional(), MSLink::writeApproaching(), NBSign::writeAsPOI(), MSChargingStation::writeChargingStationOutput(), GNEClosingLaneReroute::writeClosingLaneReroute(), GNEClosingReroute::writeClosingReroute(), NWWriter_SUMO::writeConnection(), NBRequest::writeCrossingResponse(), GNEDestProbReroute::writeDestProbReroute(), 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(), GNECalibratorFlow::writeFlow(), ODMatrix::writeFlows(), NWWriter_OpenDrive::writeGeomLines(), NWWriter_OpenDrive::writeGeomPP3(), OutputDevice::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(), NBRequest::writeLaneResponse(), GeoConvHelper::writeLocation(), NWWriter_OpenDrive::writeNetwork(), NWWriter_SUMO::writeNetwork(), IntermodalRouter< E, L, N, V >::writeNetwork(), NWWriter_XML::writeNodes(), NWWriter_OpenDrive::writeNormalEdge(), MSDevice_SSM::writeOutConflict(), MSNet::writeOutput(), MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(), Parameterised::writeParams(), MSMeanData_Amitran::writePrefix(), MSMeanData::writePrefix(), NWWriter_SUMO::writeProhibitions(), GNERerouterInterval::writeRerouterInterval(), NWWriter_SUMO::writeRoundabout(), GNECalibratorRoute::writeRoute(), GNERouteProbReroute::writeRouteProbReroute(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), GNEVariableSpeedSignStep::writeStep(), MSFullExport::writeTLS(), NWWriter_SUMO::writeTrafficLights(), MSFCDExport::writeTransportable(), MSXMLRawOut::writeTransportable(), NBTypeCont::writeTypes(), RODFDetectorCon::writeValidationDetectors(), MSAmitranTrajectories::writeVehicle(), MSXMLRawOut::writeVehicle(), MSFullExport::writeVehicles(), GNECalibratorVehicleType::writeVehicleType(), IntermodalRouter< E, L, N, V >::writeWeights(), GUIDialog_EditViewport::writeXML(), SUMOPolygon::writeXML(), PointOfInterest::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)
inherited

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 243 of file OutputDevice.cpp.

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

◆ operator<<()

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

Abstract output operator.

Returns
The OutputDevice for further processing

Definition at line 325 of file OutputDevice.h.

References OutputDevice::getOStream(), and OutputDevice::postWriteHook().

◆ postWriteHook()

void OutputDevice_Network::postWriteHook ( )
protectedvirtual

Sends the data which was written to the string stream over the socket.

Converts the stored message into a vector of chars and sends them via to the socket implementation. Resets the message, afterwards.

Reimplemented from OutputDevice.

Definition at line 89 of file OutputDevice_Network.cpp.

References myMessage, mySocket, tcpip::Socket::send(), toString(), and tcpip::SocketException::what().

◆ realString()

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

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 163 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 
)
inlineinherited

writes a named attribute

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

Definition at line 260 of file OutputDevice.h.

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

Referenced by MSDevice_Routing::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_Bluelight::generateOutput(), MSDevice_Example::generateOutput(), MSDevice_Tripinfo::generateOutput(), MSBaseVehicle::getSingularType(), MSAbstractLaneChangeModel::laneChangeOutput(), GUIDialog_ViewSettings::onCmdExportSetting(), 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(), MSTransportable::Stage_Waiting::routeOutput(), MSPerson::routeOutput(), RODFRouteCont::save(), GUIPropertyScheme< T >::save(), RODFDetectorCon::save(), GUIVisualizationSettings::save(), RODFDetectorCon::saveAsPOIs(), ROPerson::Ride::saveAsXML(), ROPerson::Walk::saveAsXML(), ROPerson::saveAsXML(), GUIDialog_ViewSettings::saveDecals(), MSStateHandler::saveState(), MSVehicleTransfer::saveState(), MSDevice_Vehroutes::saveState(), MSDevice_Tripinfo::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(), MSTransportable::Stage_Waiting::tripInfoOutput(), MSPerson::tripInfoOutput(), NBPTLine::write(), NBParking::write(), MSQueueExport::write(), MSBatteryExport::write(), MSEmissionExport::write(), MSFCDExport::write(), NBPTStop::write(), MSMeanData_Harmonoise::MSLaneMeanDataValues::write(), SUMOVTypeParameter::write(), MSMeanData_Amitran::MSLaneMeanDataValues::write(), MSMeanData_Net::MSLaneMeanDataValues::write(), MSInstantInductLoop::write(), ODMatrix::write(), SUMOVehicleParameter::write(), SUMOVehicleParameter::Stop::write(), MSVehicle::Stop::write(), GNEVaporizer::writeAdditional(), GNERouteProbe::writeAdditional(), GNEDetectorE3::writeAdditional(), GNEChargingStation::writeAdditional(), GNEDetectorE1::writeAdditional(), GNEDetectorEntry::writeAdditional(), GNEDetectorExit::writeAdditional(), GNEVariableSpeedSign::writeAdditional(), GNEDetectorE2::writeAdditional(), GNERerouter::writeAdditional(), GNEBusStop::writeAdditional(), GNEContainerStop::writeAdditional(), GNECalibrator::writeAdditional(), MSLink::writeApproaching(), NBSign::writeAsPOI(), MSChargingStation::writeChargingStationOutput(), GNEClosingLaneReroute::writeClosingLaneReroute(), GNEClosingReroute::writeClosingReroute(), NWWriter_SUMO::writeConnection(), NBRequest::writeCrossingResponse(), ODMatrix::writeDefaultAttrs(), GNEDestProbReroute::writeDestProbReroute(), NWWriter_SUMO::writeDistrict(), MSFullExport::writeEdge(), NWWriter_SUMO::writeEdge(), MSMeanData::writeEdge(), NWWriter_XML::writeEdgesAndConnections(), RODFDetector::writeEmitterDefinition(), RODFDetectorCon::writeEmitterPOIs(), RODFDetectorCon::writeEmitters(), RODFDetectorCon::writeEndRerouterDetectors(), GNECalibratorFlow::writeFlow(), 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(), NWWriter_SUMO::writeLane(), NBRequest::writeLaneResponse(), GeoConvHelper::writeLocation(), NWWriter_SUMO::writeNetwork(), IntermodalRouter< E, L, N, V >::writeNetwork(), NWWriter_XML::writeNodes(), OutputDevice::writeNonEmptyAttr(), NWWriter_OpenDrive::writeNormalEdge(), MSDevice_SSM::writeOutConflict(), MSNet::writeOutput(), MSDevice_BTreceiver::BTreceiverUpdate::writeOutput(), Parameterised::writeParams(), writePermissions(), NWFrame::writePositionLong(), writePreferences(), MSMeanData_Amitran::writePrefix(), MSMeanData::writePrefix(), NWWriter_SUMO::writeProhibitions(), GNERerouterInterval::writeRerouterInterval(), NWWriter_SUMO::writeRoundabout(), GNECalibratorRoute::writeRoute(), GNERouteProbReroute::writeRouteProbReroute(), RODFDetector::writeSingleSpeedTrigger(), RODFDetectorCon::writeSpeedTrigger(), GNEVariableSpeedSignStep::writeStep(), MSFullExport::writeTLS(), NWWriter_SUMO::writeTrafficLights(), MSFCDExport::writeTransportable(), MSXMLRawOut::writeTransportable(), NBTypeCont::writeTypes(), RODFDetectorCon::writeValidationDetectors(), MSAmitranTrajectories::writeVehicle(), MSXMLRawOut::writeVehicle(), MSFullExport::writeVehicles(), GNECalibratorVehicleType::writeVehicleType(), IntermodalRouter< E, L, N, V >::writeWeights(), GUIDialog_EditViewport::writeXML(), SUMOPolygon::writeXML(), PointOfInterest::writeXML(), RORouteDef::writeXMLDefinition(), RORoute::writeXMLDefinition(), TrajectoriesHandler::writeXMLEmissions(), MEInductLoop::writeXMLOutput(), and MSInductLoop::writeXMLOutput().

◆ writeAttr() [2/2]

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

writes an arbitrary attribute

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

Definition at line 277 of file OutputDevice.h.

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

◆ writeHeader()

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

◆ writeNonEmptyAttr()

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

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 293 of file OutputDevice.h.

References OutputDevice::writeAttr().

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

◆ writePreformattedTag()

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

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 306 of file OutputDevice.h.

References OutputDevice::getOStream(), OutputDevice::inform(), OutputDevice::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>() 
)
inherited

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 224 of file OutputDevice.cpp.

References OutputDevice::getOStream(), OutputDevice::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(), OutputDevice::createDeviceByOption(), OutputDevice::getPrecision(), MSCalibrator::MSCalibrator(), MSVTypeProbe::MSVTypeProbe(), 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(), 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(), MSRouteProbe::writeXMLDetectorProlog(), MSInstantInductLoop::writeXMLDetectorProlog(), MSMeanData_Amitran::writeXMLDetectorProlog(), MSInductLoop::writeXMLDetectorProlog(), MSE3Collector::writeXMLDetectorProlog(), MSMeanData::writeXMLDetectorProlog(), and MSE2Collector::writeXMLDetectorProlog().

Field Documentation

◆ myMessage

std::ostringstream OutputDevice_Network::myMessage
private

packet buffer

Definition at line 97 of file OutputDevice_Network.h.

Referenced by getOStream(), and postWriteHook().

◆ mySocket

tcpip::Socket* OutputDevice_Network::mySocket
private

the socket to transfer the data

Definition at line 100 of file OutputDevice_Network.h.

Referenced by OutputDevice_Network(), postWriteHook(), and ~OutputDevice_Network().


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