 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
19 #ifndef OutputDevice_h
20 #define OutputDevice_h
100 const std::string& rootElement =
"",
101 const std::string& schemaFile =
"");
121 static void closeAll(
bool keepErrorRetrievers =
false);
139 OutputDevice(
const bool binary =
false,
const int defaultIndentation = 0,
const std::string& filename =
"");
182 const std::string& schemaFile,
183 std::map<SumoXMLAttr, std::string> attrs = std::map<SumoXMLAttr, std::string>());
186 template <
typename E>
227 bool closeTag(
const std::string& comment =
"");
254 template <
typename T>
271 template <
typename T>
289 if (val !=
"" && val !=
"default") {
318 void inform(
const std::string& msg,
const char progress = 0);
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.
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
static void closeAll(bool keepErrorRetrievers=false)
Static storage of an output device and its base (abstract) implementation.
OutputFormatter * myFormatter
The formatter for XML.
OutputDevice & operator<<(const T &t)
Abstract output operator.
OutputDevice & writeAttr(const std::string &attr, const T &val)
writes an arbitrary attribute
bool isBinary() const
Returns whether we have a binary output.
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
virtual std::ostream & getOStream()=0
Returns the associated ostream.
OutputDevice(const bool binary=false, const int defaultIndentation=0, const std::string &filename="")
Constructor.
void close()
Closes the device and removes it from the dictionary.
SumoXMLTag
Numbers representing SUMO-XML - element names.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual void postWriteHook()
Called after every write access.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void inform(const std::string &msg, const char progress=0)
Retrieves a message to this device.
OutputDevice & writeNonEmptyAttr(const SumoXMLAttr attr, const std::string &val)
writes a string attribute only if it is not the empty string and not the string "default"
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
bool writeHeader(const SumoXMLTag &rootElement)
void lf()
writes a line feed if applicable
static std::map< std::string, OutputDevice * > myOutputDevices
map from names to output devices
static std::string realString(const double v, const int precision=gPrecision)
Helper method for string formatting.
int gPrecision
the precision for floating point outputs
virtual bool ok()
returns the information whether one can write into the device
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.
const std::string & getFilename()
get filename or suitable description of this device
OutputDevice & operator=(const OutputDevice &)
Invalidated assignment operator.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
virtual ~OutputDevice()
Destructor.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
int getPrecision()
Returns the precison of the underlying stream.
OutputDevice & writePadding(const std::string &val)
writes padding (ignored for binary output)