www.mooseframework.org
Public Member Functions | 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. More...
 
template<typename StreamType >
const ConsoleStreamoperator<< (const StreamType &s) const
 The output stream operator. More...
 
const ConsoleStreamoperator<< (const StandardEndLine &manip) const
 This overload is here to handle the the std::endl manipulator. More...
 
void unsetf (std::ios_base::fmtflags mask) const
 Unset format flags. More...
 
std::streampos tellp () const
 
std::streamsize precision () const
 Return the current precision. More...
 
std::streamsize precision (std::streamsize new_precision) const
 Set the precision and return the old precision. More...
 
std::ios_base::fmtflags flags () const
 Return the current flags. More...
 
std::ios_base::fmtflags flags (std::ios_base::fmtflags new_flags) const
 Set the flags and return the old flags. More...
 
unsigned long long int numPrinted () const
 The number of times something has been printed. More...
 

Private Attributes

OutputWarehouse_output_warehouse
 Reference to the OutputWarhouse that contains the Console output objects. More...
 
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. More...
 

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.
Definition: ConsoleStream.h:92
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98

Member Function Documentation

◆ flags() [1/2]

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

Return the current flags.

Definition at line 58 of file ConsoleStream.C.

Referenced by SystemBase::applyScalingFactors().

59 {
60  return _oss->flags();
61 }
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98

◆ 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 64 of file ConsoleStream.C.

65 {
66  return _oss->flags(new_flags);
67 }
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98

◆ numPrinted()

unsigned long long int ConsoleStream::numPrinted ( ) const

The number of times something has been printed.

Definition at line 70 of file ConsoleStream.C.

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

71 {
73 }
unsigned long long int numPrinted() const
The number of times something has been printed.
OutputWarehouse & _output_warehouse
Reference to the OutputWarhouse that contains the Console output objects.
Definition: ConsoleStream.h:92

◆ operator<<() [1/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.

106 {
107  std::lock_guard<std::mutex> lock(_stream_mutex);
108 
109  (*_oss) << s;
110  return *this;
111 }
std::mutex _stream_mutex
Definition: ConsoleStream.C:15

◆ operator<<() [2/2]

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

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

Definition at line 25 of file ConsoleStream.C.

26 {
27  const std::lock_guard<std::mutex> lock(manip_mutex);
28 
29  if (manip == (std::basic_ostream<char> & (*)(std::basic_ostream<char> &)) & std::endl)
30  (*_oss) << '\n';
31  else
32  (*_oss) << manip;
33 
35 
36  return *this;
37 }
static std::mutex manip_mutex
Definition: ConsoleStream.C:22
OutputWarehouse & _output_warehouse
Reference to the OutputWarhouse that contains the Console output objects.
Definition: ConsoleStream.h:92
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98
void mooseConsole()
Send current output buffer to Console output objects.

◆ precision() [1/2]

std::streamsize ConsoleStream::precision ( ) const

Return the current precision.

Definition at line 46 of file ConsoleStream.C.

Referenced by SystemBase::applyScalingFactors().

47 {
48  return _oss->precision();
49 }
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98

◆ precision() [2/2]

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

Set the precision and return the old precision.

Definition at line 52 of file ConsoleStream.C.

53 {
54  return _oss->precision(new_precision);
55 }
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98

◆ tellp()

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

Definition at line 63 of file ConsoleStream.h.

63 { return _oss->tellp(); }
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98

◆ unsetf()

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

Unset format flags.

Definition at line 40 of file ConsoleStream.C.

Referenced by SystemBase::applyScalingFactors().

41 {
42  _oss->unsetf(mask);
43 }
std::shared_ptr< std::ostringstream > _oss
The stream for buffering the message This stupidly has to be a shared pointer because of something in...
Definition: ConsoleStream.h:98

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(), operator<<(), 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<<().


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