https://mooseframework.inl.gov
ConsoleStream.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 // Moose includes
11 #include "ConsoleStream.h"
12 #include "MooseUtils.h"
13 #include "OutputWarehouse.h"
14 
16 
18  : _output_warehouse(output_warehouse), _oss(std::make_shared<std::ostringstream>())
19 {
20 }
21 
22 const ConsoleStream &
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 }
36 
37 void
38 ConsoleStream::unsetf(std::ios_base::fmtflags mask) const
39 {
40  _oss->unsetf(mask);
41 }
42 
43 std::streamsize
45 {
46  return _oss->precision();
47 }
48 
49 std::streamsize
50 ConsoleStream::precision(std::streamsize new_precision) const
51 {
52  return _oss->precision(new_precision);
53 }
54 
55 std::ios_base::fmtflags
57 {
58  return _oss->flags();
59 }
60 
61 std::ios_base::fmtflags
62 ConsoleStream::flags(std::ios_base::fmtflags new_flags) const
63 {
64  return _oss->flags(new_flags);
65 }
66 
67 unsigned long long int
69 {
71 }
A helper class for re-directing output streams to Console output objects form MooseObjects.
Definition: ConsoleStream.h:30
unsigned long long int numPrinted() const
The number of times something has been printed.
std::ios_base::fmtflags flags() const
Return the current flags.
Definition: ConsoleStream.C:56
CoutType &(* StandardEndLine)(CoutType &)
Definition: ConsoleStream.h:25
OutputWarehouse & _output_warehouse
Reference to the OutputWarhouse that contains the Console output objects.
Definition: ConsoleStream.h:92
void unsetf(std::ios_base::fmtflags mask) const
Unset format flags.
Definition: ConsoleStream.C:38
unsigned long long int numPrinted() const
The number of times something has been printed.
Definition: ConsoleStream.C:68
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
Class for storing and utilizing output objects.
std::streamsize precision() const
Return the current precision.
Definition: ConsoleStream.C:44
static std::mutex _stream_mutex
Mutex to prevent concurrent read/writes, write/writes.
const ConsoleStream & operator<<(const StreamType &s) const
The output stream operator.
void mooseConsole()
Send current output buffer to Console output objects.
ConsoleStream(OutputWarehouse &output_warehouse)
Constructor.
Definition: ConsoleStream.C:17