4 #ifndef DUNE_DEBUGSTREAM_HH
5 #define DUNE_DEBUGSTREAM_HH
127 template <DebugLevel current, DebugLevel threshold>
129 static const bool value = (current >= threshold);
139 template <DebugLevel current, DebugLevel mask>
141 enum {
value = ((current & mask)!=0) };
203 _active = activator<thislevel,alevel>::value;
218 std::ostream& fallback = std::cerr)
225 _active = activator<thislevel,alevel>::value;
241 #if HAVE_NOEXCEPT_SPECIFIER
252 "There are streams still tied to this stream!");
267 if (activator<thislevel, dlevel>::value) {
289 if (activator<thislevel, dlevel>::value) {
304 if (activator<thislevel, dlevel>::value) {
319 if (activator<thislevel, dlevel>::value) {
335 if (activator<thislevel,alevel>::value) {
340 _actstack.push(
false);
346 if (_actstack.empty())
347 DUNE_THROW(DebugStreamError,
"No previous activation setting!");
360 return activator<thislevel, dlevel>::value &&
_active;
379 DUNE_THROW(DebugStreamError,
"Cannot detach initial stream!");
381 DUNE_THROW(DebugStreamError,
"Cannot detach a tied stream!");
405 DUNE_THROW(DebugStreamError,
"Cannot untie, stream is not tied!");
420 std::stack<bool> _actstack;
Definition: debugstream.hh:148
void push(bool b)
set activation flag and store old value
Definition: debugstream.hh:333
bool active() const
reports if this stream will produce output
Definition: debugstream.hh:359
~DebugStream()
Destroy stream.
Definition: debugstream.hh:240
DebugStream & operator<<(const T data)
Generic types are passed on to current output stream.
Definition: debugstream.hh:265
StreamWrap * next
Definition: debugstream.hh:152
StreamWrap * current
current output stream and link to possibly pushed old output streams
Definition: debugstream.hh:160
Intermediate class to implement tie-operation of DebugStream.
Definition: debugstream.hh:156
void detach()
detach current output stream and restore to previous stream
Definition: debugstream.hh:377
A few common exception classes.
void untie()
Untie stream.
Definition: debugstream.hh:403
Default exception class for I/O errors.
Definition: exceptions.hh:256
DebugStream & flush()
pass on flush to underlying output stream
Definition: debugstream.hh:318
DebugStream & operator<<(const int data)
explicit specialization so that enums can be printed
Definition: debugstream.hh:287
standard exception for the debugstream
Definition: debugstream.hh:146
DebugStream(DebugStreamState &master, std::ostream &fallback=std::cerr)
Create a DebugStream and directly tie to another DebugStream.
Definition: debugstream.hh:217
StreamWrap(std::ostream &_out)
Definition: debugstream.hh:150
Greater or equal template test.
Definition: debugstream.hh:128
unsigned int DebugLevel
Type for debug levels.
Definition: debugstream.hh:116
Definition: debugstream.hh:141
void tie(DebugStreamState &to)
Definition: debugstream.hh:389
unsigned int _tied_streams
how many streams are tied to this state
Definition: debugstream.hh:169
activate if current and mask have common bits switched on.
Definition: debugstream.hh:140
std::ostream & out
Definition: debugstream.hh:150
Generic class to implement debug output streams.
Definition: debugstream.hh:190
DebugStream & operator<<(std::ostream &(*f)(std::ostream &))
pass on manipulators to underlying output stream
Definition: debugstream.hh:303
static const bool value
Definition: debugstream.hh:129
DebugStream(std::ostream &out=std::cerr)
Create a DebugStream and set initial output stream.
Definition: debugstream.hh:197
bool _active
flag to switch output during runtime
Definition: debugstream.hh:163
void attach(std::ostream &stream)
set output to a different stream.
Definition: debugstream.hh:367
void pop()
restore previously set activation flag
Definition: debugstream.hh:345
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
bool _tied
are we tied to another DebugStream?
Definition: debugstream.hh:166