6#ifndef DUNE_DEBUGSTREAM_HH
7#define DUNE_DEBUGSTREAM_HH
129 template <DebugLevel current, DebugLevel threshold>
131 constexpr static bool value = (current >= threshold);
141 template <DebugLevel current, DebugLevel mask>
143 constexpr static bool value = ((current & mask) != 0);
205 _active = activator<thislevel,alevel>::value;
220 std::ostream& fallback = std::cerr)
227 _active = activator<thislevel,alevel>::value;
252 std::cerr <<
"DebugStream destructor is called while other streams are still tied to it. Terminating!" << std::endl;
269 if (activator<thislevel, dlevel>::value) {
291 if (activator<thislevel, dlevel>::value) {
306 if (activator<thislevel, dlevel>::value) {
321 if (activator<thislevel, dlevel>::value) {
337 if (activator<thislevel,alevel>::value) {
342 _actstack.push(
false);
350 if (_actstack.empty())
364 return activator<thislevel, dlevel>::value &&
_active;
430 std::stack<bool> _actstack;
A few common exception classes.
StreamWrap(std::ostream &_out)
Definition debugstream.hh:152
DebugStream(std::ostream &out=std::cerr)
Create a DebugStream and set initial output stream.
Definition debugstream.hh:199
void untie()
Untie stream.
Definition debugstream.hh:413
DebugStream & flush()
pass on flush to underlying output stream
Definition debugstream.hh:320
void attach(std::ostream &stream)
set output to a different stream.
Definition debugstream.hh:371
void detach()
detach current output stream and restore to previous stream
Definition debugstream.hh:383
static constexpr bool value
Definition debugstream.hh:143
std::ostream & out
Definition debugstream.hh:153
void pop()
restore previously set activation flag
Definition debugstream.hh:349
bool active() const
reports if this stream will produce output
Definition debugstream.hh:363
bool _active
flag to switch output during runtime
Definition debugstream.hh:165
unsigned int _tied_streams
how many streams are tied to this state
Definition debugstream.hh:171
void tie(DebugStreamState &to)
Tie a stream to this one.
Definition debugstream.hh:397
void push(bool b)
set activation flag and store old value
Definition debugstream.hh:335
unsigned int DebugLevel
Type for debug levels.
Definition debugstream.hh:118
bool _tied
are we tied to another DebugStream?
Definition debugstream.hh:168
StreamWrap * current
current output stream and link to possibly pushed old output streams
Definition debugstream.hh:162
DebugStream & operator<<(const T data)
Generic types are passed on to current output stream.
Definition debugstream.hh:267
static constexpr bool value
Definition debugstream.hh:131
~DebugStream()
Destroy stream.
Definition debugstream.hh:243
DebugStream(DebugStreamState &master, std::ostream &fallback=std::cerr)
Create a DebugStream and directly tie to another DebugStream.
Definition debugstream.hh:219
DebugStream & operator<<(const int data)
explicit specialization so that enums can be printed
Definition debugstream.hh:289
DebugStream & operator<<(std::ostream &(*f)(std::ostream &))
pass on manipulators to underlying output stream
Definition debugstream.hh:305
StreamWrap * next
Definition debugstream.hh:154
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
Dune namespace.
Definition alignedallocator.hh:13
Greater or equal template test.
Definition debugstream.hh:130
activate if current and mask have common bits switched on.
Definition debugstream.hh:142
standard exception for the debugstream
Definition debugstream.hh:148
Definition debugstream.hh:150
Intermediate class to implement tie-operation of DebugStream.
Definition debugstream.hh:158
Generic class to implement debug output streams.
Definition debugstream.hh:192
Default exception class for I/O errors.
Definition exceptions.hh:231