Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
conditional_ostream.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_conditional_ostream_h
17 #define dealii_conditional_ostream_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <ostream>
22 
24 
25 
82 {
83 public:
89  ConditionalOStream(std::ostream &stream, const bool active = true);
90 
96  void
97  set_condition(const bool active);
98 
102  bool
103  is_active() const;
104 
108  std::ostream &
109  get_stream() const;
110 
116  template <typename T>
117  const ConditionalOStream &
118  operator<<(const T &t) const;
119 
129  const ConditionalOStream &
130  operator<<(std::ostream &(*p)(std::ostream &)) const;
131 
132 private:
136  std::ostream &output_stream;
137 
142 };
143 
144 
145 // --------------------------- inline and template functions -----------
146 
147 template <class T>
148 inline const ConditionalOStream &
150 {
151  if (active_flag == true)
152  output_stream << t;
153 
154  return *this;
155 }
156 
157 
158 inline const ConditionalOStream &
159 ConditionalOStream::operator<<(std::ostream &(*p)(std::ostream &)) const
160 {
161  if (active_flag == true)
162  output_stream << p;
163 
164  return *this;
165 }
166 
167 
168 inline std::ostream &
170 {
171  return output_stream;
172 }
173 
174 
176 
177 #endif
ConditionalOStream::operator<<
const ConditionalOStream & operator<<(const T &t) const
Definition: conditional_ostream.h:149
ConditionalOStream::get_stream
std::ostream & get_stream() const
Definition: conditional_ostream.h:169
ConditionalOStream::active_flag
bool active_flag
Definition: conditional_ostream.h:141
LAPACKSupport::T
static const char T
Definition: lapack_support.h:163
ConditionalOStream::set_condition
void set_condition(const bool active)
Definition: conditional_ostream.cc:28
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
ConditionalOStream
Definition: conditional_ostream.h:81
config.h
ConditionalOStream::output_stream
std::ostream & output_stream
Definition: conditional_ostream.h:136
ConditionalOStream::ConditionalOStream
ConditionalOStream(std::ostream &stream, const bool active=true)
Definition: conditional_ostream.cc:21
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
ConditionalOStream::is_active
bool is_active() const
Definition: conditional_ostream.cc:35