Reference documentation for deal.II version 9.4.1
\(\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\}}\)
Loading...
Searching...
No Matches
conditional_ostream.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2004 - 2020 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
81{
82public:
88 ConditionalOStream(std::ostream &stream, const bool active = true);
89
95 void
96 set_condition(const bool active);
97
101 bool
102 is_active() const;
103
107 std::ostream &
108 get_stream() const;
109
115 template <typename T>
116 const ConditionalOStream &
117 operator<<(const T &t) const;
118
128 const ConditionalOStream &
129 operator<<(std::ostream &(*p)(std::ostream &)) const;
130
131private:
135 std::ostream &output_stream;
136
141};
142
143
144// --------------------------- inline and template functions -----------
145
146template <class T>
147inline const ConditionalOStream &
148ConditionalOStream::operator<<(const T &t) const
149{
150 if (active_flag == true)
151 output_stream << t;
152
153 return *this;
154}
155
156
157inline const ConditionalOStream &
158ConditionalOStream::operator<<(std::ostream &(*p)(std::ostream &)) const
159{
160 if (active_flag == true)
161 output_stream << p;
162
163 return *this;
164}
165
166
167inline std::ostream &
169{
170 return output_stream;
171}
172
173
175
176#endif
std::ostream & get_stream() const
void set_condition(const bool active)
std::ostream & output_stream
const ConditionalOStream & operator<<(const T &t) const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443