MAIA bb96820c
Multiphysics at AIA
|
Customized string buffer to prepend cout/cerr with the domain id. More...
#include <infoout.h>
Public Member Functions | |
InfoOut_streamBuffer () | |
Default constructor does basically nothing. More... | |
InfoOut_streamBuffer (std::ostream *os, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool printDomainId=true) | |
Constructor passes the parameters to initialize(). More... | |
void | initialize (std::ostream *os, MPI_Comm mpiComm=MPI_COMM_WORLD, MBool printDomainId=true) |
Initializes the buffer to make it ready for use. More... | |
Public Member Functions inherited from InfoOut_buffer | |
InfoOut_buffer () | |
Generic constructor is used when no information is provided during declaration. More... | |
virtual MBool | setRootOnly (MBool rootOnly=true) |
Sets interal state of whether only the root domain (rank 0) should write to file. More... | |
virtual MInt | setMinFlushSize (MInt minFlushSize) |
Sets the minimum buffer length that has to be reached before the buffer is flushed. More... | |
Protected Member Functions | |
virtual MInt | sync () |
Flushes the buffer by writing the contents to the asssociated output stream. More... | |
virtual void | flushBuffer () |
This function does nothing for this class, since as of now there is no intermediate buffering. More... | |
virtual MString | addPrefix (const MString &str) |
Protected Member Functions inherited from InfoOut_buffer | |
virtual MString | encodeXml (const std::string &str) |
Parses the string input and returns the string with XML entities escaped. More... | |
virtual MString | getXmlHeader () |
Return an XML header that should written at the beginning of each log file. More... | |
virtual MString | getXmlFooter () |
Return an XML footer that should written at the end of each log file. More... | |
virtual void | createPrefixMessage () |
Creates an XML prefix using the domain id that is prepended to each message. More... | |
virtual void | createSuffixMessage () |
Creates an XML suffix that is appended to each message. More... | |
virtual void | flushBuffer ()=0 |
Private Attributes | |
MBool | m_isInitialized |
Stores whether a stream was already associated with this buffer. More... | |
MBool | m_printDomainId |
Stores whether the domain id should be prepended to each output. More... | |
std::ostream * | m_output |
Stores the output stream (usually cout or cerr) that will be modified. More... | |
MPI_Comm | m_mpiComm |
MPI communicator group. More... | |
MBool | m_isDisabled |
Stores wether output in streamBuffer should be written. More... | |
Additional Inherited Members | |
Protected Attributes inherited from InfoOut_buffer | |
MBool | m_rootOnly |
Stores whether only the root domain writes a log file. More... | |
MInt | m_domainId |
Contains the MPI rank (= domain id) of this process. More... | |
MInt | m_noDomains |
Contains the MPI rank count (= number of domains) More... | |
MInt | m_minFlushSize |
Minimum length of the internal buffer before flushing. More... | |
MString | m_prefixMessage |
Stores the prefix that is prepended to each output. More... | |
MString | m_suffixMessage |
Stores the suffix that is apended to each output. More... | |
std::ostringstream | m_tmpBuffer |
Temporary buffer to hold string until flushing. More... | |
MString | m_projectName |
Name of the current Project. More... | |
std::vector< std::pair< MString, MString > > | m_prefixAttributes |
Static Protected Attributes inherited from InfoOut_buffer | |
static const MInt | m_fileFormatVersion = 1 |
This class takes an exisiting output stream such as cout or cerr and adds an additonal layer of buffering. For cerr this effectively means that cerr is now thread-safe, i.e. multiple processors writing to cerr at once should not result in mixed up strings anymore. Furthermore, each message is prepended with a prefix consisting of the rank of the specified MPI communicator. This behavior is optional and may be changed at runtime by subsequent calls to initialize().
InfoOut_streamBuffer::InfoOut_streamBuffer | ( | ) |
Definition at line 789 of file infoout.cpp.
InfoOut_streamBuffer::InfoOut_streamBuffer | ( | std::ostream * | os, |
MPI_Comm | mpiComm = MPI_COMM_WORLD , |
||
MBool | printDomainId = true |
||
) |
After an object is instantiated using this constructor, the buffer is ready to use. For detailed information on what is done, please refer to initialize().
[in] | os | Output stream that should be used for output. |
[in] | mpiComm | MPI communicator for which the domain information should be gathered. |
[in] | printDomainId | Determines whether the domain id should be prepended to each message. |
Definition at line 803 of file infoout.cpp.
\Writes the domain_Id in front of every line. \If
is written in the middle of a stream it will be replaced with the domain_Id \and written in the following line so you have the expected output.
Definition at line 867 of file infoout.cpp.
|
inlineprotectedvirtual |
Implements InfoOut_buffer.
Definition at line 919 of file infoout.cpp.
void InfoOut_streamBuffer::initialize | ( | std::ostream * | os, |
MPI_Comm | mpiComm = MPI_COMM_WORLD , |
||
MBool | printDomainId = true |
||
) |
The output stream that will be written to is assigned and the domain id determined. If specified, a prefix is generated containing the domain id. This method may be called multiple times to change the desired behavior of this buffer.
[in] | os | Output stream that should be used for output. |
[in] | mpiComm | MPI communicator for which the domain information should be gathered. |
[in] | printDomainId | Determines whether the domain id should be prepended to each message. |
Definition at line 820 of file infoout.cpp.
|
protectedvirtual |
Sync is called automatically when an "endl" is sent to the stream. It preprends each message with the optional message prefix and writes the contents of the buffer to the output stream, which is then flushed itself. Finally, all internal buffers are reset.
Definition at line 894 of file infoout.cpp.