1 #ifndef AUDIOGRAPHER_DEBUGGABLE_H
2 #define AUDIOGRAPHER_DEBUGGABLE_H
4 #ifndef DEFAULT_DEBUG_LEVEL
5 #define DEFAULT_DEBUG_LEVEL DebugNone
10 #include "audiographer/visibility.h"
12 namespace AudioGrapher
15 /// Compile time defined debug level
16 enum LIBAUDIOGRAPHER_API DebugLevel
18 DebugNone, ///< Disabled
19 DebugObject, ///< Object level stuff, ctors, initalizers etc.
20 DebugFlags, ///< Debug ProcessContext flags only on process cycle level
21 DebugProcess, ///< Process cycle level stuff
22 DebugVerbose, ///< Lots of output, not on sample level
23 DebugSample ///< Sample level stuff
26 /** Class that allows optimizing out debugging code during compile time.
27 * Usage: to take all advantage of this class you should wrap all
28 * debugging statemets like this:
30 * if (debug_level (SomeDebugLevel) && other_optional_conditionals) {
31 * debug_stream() << "Debug output" << std::endl;
35 * The order of the conditionals in the if-clause is important.
36 * The checks specified in \a other_optional_conditionals are only
37 * optimized out if \a debug_level() is placed before it with a
38 * logical and (short-circuiting).
40 template<DebugLevel L = DEFAULT_DEBUG_LEVEL>
41 class /*LIBAUDIOGRAPHER_API*/ Debuggable
44 Debuggable(std::ostream & debug_stream = std::cerr)
45 : stream (debug_stream) {}
47 bool debug_level (DebugLevel level) {
49 (void) level; /* stop pedantic gcc complaints about unused parameter */
55 std::ostream & debug_stream() { return stream; }
58 std::ostream & stream;
64 #endif // AUDIOGRAPHER_DEBUGGABLE_H