50 #ifdef CHECK_MEMORY_LEAKS
52 #endif // CHECK_MEMORY_LEAKS
73 if (name ==
"stdout") {
75 }
else if (name ==
"stderr") {
82 throw IOError(
"Given port number '" + name.substr(name.find(
":") + 1) +
"' is not numeric.");
84 throw IOError(
"No port number given.");
87 const size_t len = name.length();
91 dev->
getOStream() << std::setiosflags(std::ios::fixed);
99 const std::string& rootElement,
100 const std::string& schemaFile) {
105 if (rootElement !=
"") {
106 if (schemaFile !=
"") {
107 dev.
writeXMLHeader(rootElement,
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/" + schemaFile +
"\"");
120 throw InvalidArgument(
"Device '" + devName +
"' has not been created.");
137 std::ostringstream oss;
141 if (v < pow(10., -precision)) {
142 oss.setf(std::ios::scientific, std::ios::floatfield);
144 oss.setf(std::ios::fixed , std::ios::floatfield);
145 oss.setf(std::ios::showpoint);
146 oss << std::setprecision(precision);
157 : myAmBinary(binary) {
181 if (i->second ==
this) {
198 const std::string& attrs,
const std::string& comment) {
void close()
Closes the device and removes it from the dictionary.
SumoXMLTag
Numbers representing SUMO-XML - element names.
static std::map< std::string, OutputDevice * > myOutputDevices
map from names to output devices
static bool isSocket(const std::string &name)
Returns the information whether the given name represents a socket.
OutputDevice(const bool binary=false, const unsigned int defaultIndentation=0)
Constructor.
An output device for TCP/IP network connections.
static OptionsCont & getOptions()
Retrieves the options.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
void inform(const std::string &msg, const char progress=0)
Retrieves a message to this device.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void setPrecision(unsigned int precision=OUTPUT_ACCURACY)
Sets the precison or resets it to default.
static OutputDevice * getDevice()
Returns the single cout instance.
An output device that encapsulates an ofstream.
virtual bool ok()
returns the information whether one can write into the device
static int _2int(const E *const data)
virtual ~OutputDevice()
Destructor.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
static std::string realString(const SUMOReal v, const int precision=OUTPUT_ACCURACY)
Helper method for string formatting.
OutputFormatter * myFormatter
The formatter for XML.
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.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
static OutputDevice * getDevice()
Returns the single cerr instance.
virtual std::ostream & getOStream()=0
Returns the associated ostream.
virtual void postWriteHook()
Called after every write access.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.