File output.hxx#
Defines
-
__OUTPUT_H__#
Functions
-
template<typename T>
DummyOutput &operator<<(DummyOutput &out, T const &t)# Catch stream outputs to DummyOutput objects. This is so that statements like output_debug << “debug message”; compile but have no effect if BOUT_USE_OUTPUT_DEBUG is false
-
template<typename T>
DummyOutput &operator<<(DummyOutput &out, const T *t)#
-
inline DummyOutput &operator<<(DummyOutput &out, stream_manipulator pf)#
-
inline ConditionalOutput &operator<<(ConditionalOutput &out, stream_manipulator pf)#
-
template<typename T>
ConditionalOutput &operator<<(ConditionalOutput &out, T const &t)#
-
template<typename T>
ConditionalOutput &operator<<(ConditionalOutput &out, const T *t)#
Variables
-
ConditionalOutput output_debug
To allow statements like “output.write(…)” or “output << …” Output for debugging
-
ConditionalOutput output_warn
warnings
-
ConditionalOutput output_progress
progress
-
ConditionalOutput output_info
information
-
ConditionalOutput output_error
errors
-
ConditionalOutput output_verbose#
less interesting messages
-
ConditionalOutput output
Generic output, given the same level as output_progress.
-
class Output : private multioutbuf_init<char, std::char_traits<char>>, public std::basic_ostream<char, std::char_traits<char>>#
- #include <output.hxx>
Class for text output to stdout and/or log file.
This class can be used to output either in fmt format:
output.write(“A string {:s} and number {:d}\n”, str, i);
or as a C++ stream buffer:
output << “A string “ << str << “ and number “ << i << endl;
If a file has been opened (i.e. the processor’s log file) then the string will be written to the file. In addition, output to stdout can be enabled and disabled.
Subclassed by ConditionalOutput, DummyOutput
Public Functions
-
inline Output()#
-
inline ~Output() override#
-
virtual void enable()#
Enables writing to stdout (default)
-
virtual void disable()#
Disables stdout.
-
void close()#
Close the log file.
Private Types
-
using multioutbuf_init = ::multioutbuf_init<char, _Tr>#
Private Members
-
bool enabled#
Whether output to stdout is enabled.
Friends
- friend class ConditionalOutput
-
inline Output()#
-
class DummyOutput : public Output#
- #include <output.hxx>
Class which behaves like Output, but has no effect. This is to allow debug outputs to be disabled at compile time
-
class ConditionalOutput : public Output#
- #include <output.hxx>
Layer on top of Output which passes through calls to write, print etc if it is enabled, but discards messages otherwise. This is used to provide different levels of output (info, prog, warn, error) which can be enabled and disabled at run time.
Public Functions
-
inline ConditionalOutput(Output *base, bool enabled = true)#
- Parameters:
base – [in] The Output object which will be written to if enabled
enabled – [in] Should this be enabled by default?
-
inline ConditionalOutput(ConditionalOutput *base)#
Constuctor taking ConditionalOutput. This allows several layers of conditions
- Parameters:
base – [in] A ConditionalOutput which will be written to if enabled
-
virtual void write(const std::string &message) override#
If enabled, writes a string using fmt formatting by calling base->write This string is then sent to log file and stdout (on processor 0)
-
virtual void print(const std::string &message) override#
If enabled, print a string to stdout using fmt formatting note: unlike write, this is not also sent to log files
-
inline virtual Output *getBase() override#
Get the lowest-level Output object which is the base of this ConditionalOutput.
-
inline void enable(bool enable_)#
Set whether this ConditionalOutput is enabled If set to false (disabled), then all print and write calls do nothing
-
inline virtual void enable() override#
Turn on outputs through calls to print and write.
-
inline virtual void disable() override#
Turn off outputs through calls to print and write This includes log files and stdout
-
inline virtual bool isEnabled() override#
Check if output is enabled.
Protected Attributes
-
bool enabled#
Does this instance output anything?
Friends
- friend class WithQuietOutput
-
inline ConditionalOutput(Output *base, bool enabled = true)#
-
class WithQuietOutput#
- #include <output.hxx>
Disable a ConditionalOutput during a scope; reenable it on exit. You must give the variable a name!
{ WithQuietOutput quiet{output}; // output disabled during this scope } // output now enabled
Public Functions
-
inline explicit WithQuietOutput(ConditionalOutput &output_in)#
-
inline ~WithQuietOutput()#
-
inline explicit WithQuietOutput(ConditionalOutput &output_in)#