https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
ConsoleStream Class Reference

A helper class for re-directing output streams to Console output objects form MooseObjects. More...

#include <ConsoleStream.h>

Public Member Functions

 ConsoleStream (OutputWarehouse &output_warehouse)
 Constructor.
 
template<typename StreamType >
const ConsoleStreamoperator<< (const StreamType &s) const
 The output stream operator.
 
const ConsoleStreamoperator<< (const StandardEndLine &manip) const
 This overload is here to handle the the std::endl manipulator.
 
void unsetf (std::ios_base::fmtflags mask) const
 Unset format flags.
 
std::streampos tellp () const
 
std::streamsize precision () const
 Return the current precision.
 
std::streamsize precision (std::streamsize new_precision) const
 Set the precision and return the old precision.
 
std::ios_base::fmtflags flags () const
 Return the current flags.
 
std::ios_base::fmtflags flags (std::ios_base::fmtflags new_flags) const
 Set the flags and return the old flags.
 
unsigned long long int numPrinted () const
 The number of times something has been printed.
 

Private Attributes

OutputWarehouse_output_warehouse
 Reference to the OutputWarhouse that contains the Console output objects.
 
std::shared_ptr< std::ostringstream > _oss
 The stream for buffering the message This stupidly has to be a shared pointer because of something in AutomaticMortarGeneration that requires this to be trivially copyable.
 

Static Private Attributes

static std::mutex _stream_mutex
 Mutex to prevent concurrent read/writes, write/writes.
 

Detailed Description

A helper class for re-directing output streams to Console output objects form MooseObjects.

Definition at line 30 of file ConsoleStream.h.

Constructor & Destructor Documentation

◆ ConsoleStream()

ConsoleStream::ConsoleStream ( OutputWarehouse output_warehouse)

Constructor.

Parameters
output_warehouseA reference to the OutputWarehouse containing the Console outputs

ConsoleStreamInterface contains an instance of this object, which allows message streams to be transferred to Console output objects. This class simply provides an operator<< method that passes the stream to the Console objects.

Definition at line 17 of file ConsoleStream.C.

18 : _output_warehouse(output_warehouse), _oss(std::make_shared<std::ostringstream>())
19{
20}
OutputWarehouse & _output_warehouse
Reference to the OutputWarhouse that contains the Console output objects.
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...

Member Function Documentation

◆ flags() [1/2]

std::ios_base::fmtflags ConsoleStream::flags ( ) const

Return the current flags.

Definition at line 56 of file ConsoleStream.C.

57{
58 return _oss->flags();
59}

Referenced by SystemBase::applyScalingFactors(), and NEML2Action::printSummary().

◆ flags() [2/2]

std::ios_base::fmtflags ConsoleStream::flags ( std::ios_base::fmtflags  new_flags) const

Set the flags and return the old flags.

Definition at line 62 of file ConsoleStream.C.

63{
64 return _oss->flags(new_flags);
65}

◆ numPrinted()

unsigned long long int ConsoleStream::numPrinted ( ) const

The number of times something has been printed.

Definition at line 68 of file ConsoleStream.C.

69{
71}
unsigned long long int numPrinted() const
The number of times something has been printed.

Referenced by PerfGraph::addToExecutionList(), PerfGraphLivePrint::printLiveMessage(), PerfGraphLivePrint::printStats(), and PerfGraphLivePrint::start().

◆ operator<<() [1/2]

const ConsoleStream & ConsoleStream::operator<< ( const StandardEndLine manip) const

This overload is here to handle the the std::endl manipulator.

Definition at line 22 of file ConsoleStream.C.

24{
25 const std::lock_guard<std::mutex> lock(_stream_mutex);
26
27 if (manip == (std::basic_ostream<char> & (*)(std::basic_ostream<char> &)) & std::endl)
28 (*_oss) << '\n';
29 else
30 (*_oss) << manip;
31
33
34 return *this;
35}
static std::mutex _stream_mutex
Mutex to prevent concurrent read/writes, write/writes.
void mooseConsole()
Send current output buffer to Console output objects.

◆ operator<<() [2/2]

template<typename StreamType >
const ConsoleStream & ConsoleStream::operator<< ( const StreamType &  s) const

The output stream operator.

Parameters
sThe data to be output to the Console objects

This allows any object to uses _console to write to the Console: _console << "The combination to the air lock is " << 12345 << std::endl;

Definition at line 105 of file ConsoleStream.h.

107{
108 std::lock_guard<std::mutex> lock(_stream_mutex);
109
110 (*_oss) << s;
111 return *this;
112}

◆ precision() [1/2]

std::streamsize ConsoleStream::precision ( ) const

Return the current precision.

Definition at line 44 of file ConsoleStream.C.

45{
46 return _oss->precision();
47}

Referenced by SystemBase::applyScalingFactors().

◆ precision() [2/2]

std::streamsize ConsoleStream::precision ( std::streamsize  new_precision) const

Set the precision and return the old precision.

Definition at line 50 of file ConsoleStream.C.

51{
52 return _oss->precision(new_precision);
53}

◆ tellp()

std::streampos ConsoleStream::tellp ( ) const
inline

Definition at line 63 of file ConsoleStream.h.

63{ return _oss->tellp(); }

Referenced by MaterialPropertyDebugOutput::printMaterialProperties().

◆ unsetf()

void ConsoleStream::unsetf ( std::ios_base::fmtflags  mask) const

Unset format flags.

Definition at line 38 of file ConsoleStream.C.

39{
40 _oss->unsetf(mask);
41}

Referenced by SystemBase::applyScalingFactors().

Member Data Documentation

◆ _oss

std::shared_ptr<std::ostringstream> ConsoleStream::_oss
mutableprivate

The stream for buffering the message This stupidly has to be a shared pointer because of something in AutomaticMortarGeneration that requires this to be trivially copyable.

Definition at line 98 of file ConsoleStream.h.

Referenced by flags(), flags(), operator<<(), precision(), precision(), tellp(), and unsetf().

◆ _output_warehouse

OutputWarehouse& ConsoleStream::_output_warehouse
private

Reference to the OutputWarhouse that contains the Console output objects.

Definition at line 92 of file ConsoleStream.h.

Referenced by numPrinted(), and operator<<().

◆ _stream_mutex

std::mutex ConsoleStream::_stream_mutex
staticprivate

Mutex to prevent concurrent read/writes, write/writes.

Definition at line 101 of file ConsoleStream.h.

Referenced by operator<<(), and operator<<().


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