Provides an interface to print based on whether a certain condition is met or not. Typical use cases include: (a) printing based on different verbosity level (b) printing only from a certain processor while running in parallel.
More...
#include <ConditionalOStream.h>
Provides an interface to print based on whether a certain condition is met or not. Typical use cases include: (a) printing based on different verbosity level (b) printing only from a certain processor while running in parallel.
◆ ConditionalOStream()
dftefe::utils::ConditionalOStream::ConditionalOStream |
( |
std::ostream & |
stream, |
|
|
const bool |
active = true |
|
) |
| |
Constructor.
- Parameters
-
[in] | stream | Reference to the ostream object onto which the output is to be written (e.g., std::cout, a file) |
[in] | active | Boolean to define whether printing to ostream be allowed or not |
◆ getOStream()
std::ostream & dftefe::utils::ConditionalOStream::getOStream |
( |
| ) |
const |
|
inline |
Function that returns the underlying ostream object associated with this object.
- Returns
- ostream object associated with this object
◆ isActive()
bool dftefe::utils::ConditionalOStream::isActive |
( |
| ) |
const |
Function that returns true if printing to the output stream associated with this object is allowed.
- Returns
- True if printing to the output stream associated with this object is allowed, else returns false
◆ operator<<() [1/2]
template<class T >
const ConditionalOStream & dftefe::utils::ConditionalOStream::operator<< |
( |
const T & |
t | ) |
const |
|
inline |
Overload the insertion or << operator.
- Template Parameters
-
T | Template parameter which can be any of the C++ standard datatypes (e.g., bool, int, double, char, string, ...) |
- Parameters
-
◆ operator<<() [2/2]
const ConditionalOStream & dftefe::utils::ConditionalOStream::operator<< |
( |
std::ostream &(*)(std::ostream &) |
p | ) |
const |
|
inline |
Overload the insertion or << operator which takes an input function pointer to a manipulator (e.g., std::endl, std::ends, std::flush, etc). See https://cplusplus.com/reference/ostream/ostream/operator%3C%3C/ for a list of manipulators.
- Parameters
-
[in] | p | Pointer to a function that takes and returns a stream object. It generally is a manipulator function. |
◆ setCondition()
void dftefe::utils::ConditionalOStream::setCondition |
( |
const bool |
active | ) |
|
Function to set the condition for printing to the output stream associated with this object.
- Parameters
-
[in] | active | Booleam to define whether printing to ostream be allowed or not |
◆ d_activeFlag
bool dftefe::utils::ConditionalOStream::d_activeFlag |
|
private |
◆ d_outputStream
std::ostream& dftefe::utils::ConditionalOStream::d_outputStream |
|
private |
The documentation for this class was generated from the following files: