Skip to content
Snippets Groups Projects
Commit f7c01419 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

Merge branch 'feature/debugstream-destructor-exception' into 'master'

Feature/debugstream destructor exception



See merge request !35
parents 0c7bad85 b8fa8c21
Branches
Tags
No related merge requests found
......@@ -147,7 +147,7 @@ namespace Dune {
class StreamWrap {
public:
StreamWrap(std::ostream& _out) : out(_out) { };
StreamWrap(std::ostream& _out) : out(_out) { }
std::ostream& out;
StreamWrap *next;
};
......@@ -207,7 +207,7 @@ namespace Dune {
// no child streams yet
_tied_streams = 0;
};
}
/*! \brief Create a DebugStream and directly tie to another DebugStream
......@@ -229,7 +229,7 @@ namespace Dune {
_tied = true;
tiedstate = &master;
tiedstate->_tied_streams++;
};
}
/*! \brief Destroy stream.
......@@ -237,7 +237,8 @@ namespace Dune {
thrown. Otherwise the child streams would certainly break on the
next output
*/
~DebugStream() {
~DebugStream() noexcept(false)
{
// untie
if (_tied)
tiedstate->_tied_streams--;
......@@ -246,15 +247,15 @@ namespace Dune {
if (_tied_streams != 0)
DUNE_THROW(DebugStreamError,
"There are streams still tied to this stream!");
};
}
// remove ostream-stack
while (current != 0) {
StreamWrap *s = current;
current = current->next;
delete s;
};
};
}
}
//! \brief Generic types are passed on to current output stream
template <class T>
......@@ -267,8 +268,8 @@ namespace Dune {
} else {
if (_active && tiedstate->_active)
tiedstate->current->out << data;
};
};
}
}
return *this;
}
......@@ -289,8 +290,8 @@ namespace Dune {
} else {
if (_active && tiedstate->_active)
tiedstate->current->out << data;
};
};
}
}
return *this;
}
......@@ -304,11 +305,11 @@ namespace Dune {
} else {
if (_active && tiedstate->_active)
f(tiedstate->current->out);
};
}
}
return *this;
};
}
//! \brief pass on flush to underlying output stream
DebugStream& flush() {
......@@ -319,11 +320,11 @@ namespace Dune {
} else {
if (_active && tiedstate->_active)
tiedstate->current->out.flush();
};
}
}
return *this;
};
}
//! \brief set activation flag and store old value
void push(bool b) {
......@@ -334,8 +335,8 @@ namespace Dune {
} else {
// stay off
_actstack.push(false);
};
};
}
}
//! \brief restore previously set activation flag
void pop() throw(DebugStreamError) {
......@@ -344,7 +345,7 @@ namespace Dune {
_active = _actstack.top();
_actstack.pop();
};
}
/*! \brief reports if this stream will produce output
......@@ -354,7 +355,7 @@ namespace Dune {
*/
bool active() const {
return activator<thislevel, dlevel>::value && _active;
};
}
/*! \brief set output to a different stream.
......@@ -367,7 +368,7 @@ namespace Dune {
StreamWrap* newcurr = new StreamWrap(stream);
newcurr->next = current;
current = newcurr;
};
}
//! \brief detach current output stream and restore to previous stream
void detach() throw(DebugStreamError) {
......@@ -379,7 +380,7 @@ namespace Dune {
StreamWrap* old = current;
current = current->next;
delete old;
};
}
// \brief Tie a stream to this one.
void tie(DebugStreamState& to) throw(DebugStreamError) {
......@@ -393,7 +394,7 @@ namespace Dune {
// tell master class
tiedstate->_tied_streams++;
};
}
//! \brief Untie stream
void untie() throw(DebugStreamError) {
......@@ -403,7 +404,7 @@ namespace Dune {
tiedstate->_tied_streams--;
_tied = false;
tiedstate = 0;
};
}
private:
//! \brief pointer to data of stream we're tied to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment