deal.II version GIT relicensing-2165-gc91f007519 2024-11-20 01:40:00+00:00
\(\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// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2004 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_conditional_ostream_h
16#define dealii_conditional_ostream_h
17
18#include <deal.II/base/config.h>
19
20#include <ostream>
21
23
24
80{
81public:
87 explicit ConditionalOStream(std::ostream &stream, const bool active = true);
88
94 void
95 set_condition(const bool active);
96
100 bool
101 is_active() const;
102
106 std::ostream &
107 get_stream() const;
108
114 template <typename T>
115 const ConditionalOStream &
116 operator<<(const T &t) const;
117
127 const ConditionalOStream &
128 operator<<(std::ostream &(*p)(std::ostream &)) const;
129
130private:
134 std::ostream &output_stream;
135
140};
141
142
143// --------------------------- inline and template functions -----------
144
145template <class T>
146inline const ConditionalOStream &
147ConditionalOStream::operator<<(const T &t) const
148{
149 if (active_flag == true)
150 output_stream << t;
151
152 return *this;
153}
154
155
156inline const ConditionalOStream &
157ConditionalOStream::operator<<(std::ostream &(*p)(std::ostream &)) const
158{
159 if (active_flag == true)
160 output_stream << p;
161
162 return *this;
163}
164
165
166inline std::ostream &
168{
169 return output_stream;
170}
171
172
174
175#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:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499