deal.II version 9.7.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
// 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
22
DEAL_II_NAMESPACE_OPEN
23
24
79
class
ConditionalOStream
80
{
81
public
:
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
130
private
:
134
std::ostream &
output_stream
;
135
139
bool
active_flag
;
140
};
141
142
143
// --------------------------- inline and template functions -----------
144
145
template
<
class
T>
146
inline
const
ConditionalOStream
&
147
ConditionalOStream::operator<<(
const
T &t)
const
148
{
149
if
(
active_flag
==
true
)
150
output_stream
<< t;
151
152
return
*
this
;
153
}
154
155
156
inline
const
ConditionalOStream
&
157
ConditionalOStream::operator<<(std::ostream &(*p)(std::ostream &))
const
158
{
159
if
(
active_flag
==
true
)
160
output_stream
<< p;
161
162
return
*
this
;
163
}
164
165
166
inline
std::ostream &
167
ConditionalOStream::get_stream()
const
168
{
169
return
output_stream
;
170
}
171
172
173
DEAL_II_NAMESPACE_CLOSE
174
175
#endif
set_condition
void set_condition(const bool active)
Definition
conditional_ostream.cc:30
active_flag
bool active_flag
Definition
conditional_ostream.h:139
get_stream
std::ostream & get_stream() const
operator<<
const ConditionalOStream & operator<<(const T &t) const
is_active
bool is_active() const
output_stream
std::ostream & output_stream
Definition
conditional_ostream.h:134
config.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition
config.h:40
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition
config.h:41
ConditionalOStream
ConditionalOStream(std::ostream &stream, const bool active=true)
Definition
conditional_ostream.cc:23
include
deal.II
base
conditional_ostream.h
Generated by
1.16.1