Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::utils::pcout_t Class Reference

Parallel-aware output stream. More...

#include <pcout.hpp>

Public Member Functions

 pcout_t (std::ostream &os=std::cout)
 Construct a pcout object.
pcout_t & level (LogLevel lvl)
 Set the log level for the next << only.
template<typename T>
pcout_t & operator<< (const T &value)
 Generic stream output operator.
pcout_t & operator<< (std::ostream &(*pf)(std::ostream &))
 Stream manipulators (e.g. std::endl, std::fixed).
pcout_t & operator<< (std::ios &(*pf)(std::ios &))
pcout_t & operator<< (std::ios_base &(*pf)(std::ios_base &))
void flush ()
 Explicitly flush the underlying stream.

Private Member Functions

bool shouldPrint () const
 Check whether the current message should be printed.
void resetMessageLevel ()
 Reset the message log level to INFO.

Static Private Member Functions

static constexpr LogLevel defaultLogLevel ()
 Default log level depending on build type.

Private Attributes

std::ostream * os_
LogLevel current_level_
LogLevel msg_level_

Detailed Description

Parallel-aware output stream.

pcout behaves like std::cout, but:

  • prints only on the MPI root rank (if MPI is initialized)
  • supports log levels (ERROR, INFO, DEBUG)
  • enables DEBUG output automatically in Debug builds

Constructor & Destructor Documentation

◆ pcout_t()

vulpes::utils::pcout_t::pcout_t ( std::ostream & os = std::cout)
inlineexplicit

Construct a pcout object.

Parameters
osOutput stream to wrap (std::cout by default).

Member Function Documentation

◆ defaultLogLevel()

constexpr LogLevel vulpes::utils::pcout_t::defaultLogLevel ( )
inlinestaticconstexprprivate

Default log level depending on build type.

DEBUG builds enable DEBUG logging, Release builds default to INFO.

◆ flush()

void vulpes::utils::pcout_t::flush ( )
inline

Explicitly flush the underlying stream.

◆ level()

pcout_t & vulpes::utils::pcout_t::level ( LogLevel lvl)
inline

Set the log level for the next << only.

Every << resets the level to INFO, so a message at another level must be passed in a single <<.

◆ operator<<() [1/4]

template<typename T>
pcout_t & vulpes::utils::pcout_t::operator<< ( const T & value)
inline

Generic stream output operator.

◆ operator<<() [2/4]

pcout_t & vulpes::utils::pcout_t::operator<< ( std::ios &(* pf )(std::ios &))
inline

◆ operator<<() [3/4]

pcout_t & vulpes::utils::pcout_t::operator<< ( std::ios_base &(* pf )(std::ios_base &))
inline

◆ operator<<() [4/4]

pcout_t & vulpes::utils::pcout_t::operator<< ( std::ostream &(* pf )(std::ostream &))
inline

Stream manipulators (e.g. std::endl, std::fixed).

◆ resetMessageLevel()

void vulpes::utils::pcout_t::resetMessageLevel ( )
inlineprivate

Reset the message log level to INFO.

Ensures that pcout << ... uses INFO by default.

◆ shouldPrint()

bool vulpes::utils::pcout_t::shouldPrint ( ) const
inlineprivate

Check whether the current message should be printed.

Member Data Documentation

◆ current_level_

LogLevel vulpes::utils::pcout_t::current_level_
private

◆ msg_level_

LogLevel vulpes::utils::pcout_t::msg_level_
private

◆ os_

std::ostream* vulpes::utils::pcout_t::os_
private

The documentation for this class was generated from the following file: