www.mooseframework.org
ConsoleStream.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
15 std::mutex _stream_mutex;
16 
18  : _output_warehouse(output_warehouse), _oss(std::make_shared<std::ostringstream>())
19 {
20 }
21 
22 static std::mutex manip_mutex;
23 
24 const ConsoleStream &
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 }
38 
39 void
40 ConsoleStream::unsetf(std::ios_base::fmtflags mask) const
41 {
42  _oss->unsetf(mask);
43 }
44 
45 std::streamsize
47 {
48  return _oss->precision();
49 }
50 
51 std::streamsize
52 ConsoleStream::precision(std::streamsize new_precision) const
53 {
54  return _oss->precision(new_precision);
55 }
56 
57 std::ios_base::fmtflags
59 {
60  return _oss->flags();
61 }
62 
63 std::ios_base::fmtflags
64 ConsoleStream::flags(std::ios_base::fmtflags new_flags) const
65 {
66  return _oss->flags(new_flags);
67 }
68 
69 unsigned long long int
71 {
73 }
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:58
static std::mutex manip_mutex
Definition: ConsoleStream.C:22
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:40
unsigned long long int numPrinted() const
The number of times something has been printed.
Definition: ConsoleStream.C:70
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
std::mutex _stream_mutex
Definition: ConsoleStream.C:15
Class for storing and utilizing output objects.
std::streamsize precision() const
Return the current precision.
Definition: ConsoleStream.C:46
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