1 #ifndef AUDIOGRAPHER_DEBUGGABLE_H
2 #define AUDIOGRAPHER_DEBUGGABLE_H
4 #ifndef DEFAULT_DEBUG_LEVEL
5 #define DEFAULT_DEBUG_LEVEL DebugNone
10 namespace AudioGrapher
13 /// Compile time defined debug level
16 DebugNone, ///< Disabled
17 DebugObject, ///< Object level stuff, ctors, initalizers etc.
18 DebugFlags, ///< Debug ProcessContext flags only on process cycle level
19 DebugProcess, ///< Process cycle level stuff
20 DebugVerbose, ///< Lots of output, not on sample level
21 DebugSample ///< Sample level stuff
24 /** Class that allows optimizing out debugging code during compile time.
25 * Usage: to take all advantage of this class you should wrap all
26 * debugging statemets like this:
28 * if (debug_level (SomeDebugLevel) && other_optional_conditionals) {
29 * debug_stream() << "Debug output" << std::endl;
33 * The order of the conditionals in the if-clause is important.
34 * The checks specified in \a other_optional_conditionals are only
35 * optimized out if \a debug_level() is placed before it with a
36 * logical and (short-circuiting).
38 template<DebugLevel L = DEFAULT_DEBUG_LEVEL>
42 Debuggable(std::ostream & debug_stream = std::cerr)
43 : stream (debug_stream) {}
45 bool debug_level (DebugLevel level) {
52 std::ostream & debug_stream() { return stream; }
55 std::ostream & stream;
61 #endif // AUDIOGRAPHER_DEBUGGABLE_H