Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
deal.II
base
conditional_ostream.h
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
23
DEAL_II_NAMESPACE_OPEN
24
25
81
class
ConditionalOStream
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
141
bool
active_flag
;
142
};
143
144
145
// --------------------------- inline and template functions -----------
146
147
template
<
class
T>
148
inline
const
ConditionalOStream
&
149
ConditionalOStream::operator<<
(
const
T &t)
const
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 &
169
ConditionalOStream::get_stream
()
const
170
{
171
return
output_stream
;
172
}
173
174
175
DEAL_II_NAMESPACE_CLOSE
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
ConditionalOStream::set_condition
void set_condition(const bool active)
Definition:
conditional_ostream.cc:28
ConditionalOStream
Definition:
conditional_ostream.h:81
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
ConditionalOStream::is_active
bool is_active() const
Definition:
conditional_ostream.cc:35
Generated by
1.8.16