X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Faudiographer%2Faudiographer%2Fdebuggable.h;h=6ca544a87e46d888ae314df8df848a9479fca703;hb=c1bd70d8b085acf3895303459cbe50d7dcdd95fe;hp=4126327b86954d78beb662d99ad8ff0b505583fa;hpb=8da27200d18fe4c471a759dde8e10d85ff29d277;p=ardour.git diff --git a/libs/audiographer/audiographer/debuggable.h b/libs/audiographer/audiographer/debuggable.h index 4126327b86..6ca544a87e 100644 --- a/libs/audiographer/audiographer/debuggable.h +++ b/libs/audiographer/audiographer/debuggable.h @@ -7,32 +7,50 @@ #include +#include "audiographer/visibility.h" + namespace AudioGrapher { -enum DebugLevel +/// Compile time defined debug level +enum LIBAUDIOGRAPHER_API DebugLevel { - DebugNone, //< Disabled - DebugObject, //< Object level stuff, ctors, initalizers etc. - DebugProcess, //< Process cycle level stuff - DebugVerbose, //< Lots of output, not on sample level - DebugSample //< Sample level stuff + DebugNone, ///< Disabled + DebugObject, ///< Object level stuff, ctors, initalizers etc. + DebugFlags, ///< Debug ProcessContext flags only on process cycle level + DebugProcess, ///< Process cycle level stuff + DebugVerbose, ///< Lots of output, not on sample level + DebugSample ///< Sample level stuff }; -/// Class that allows optimizing out debugging code during compile time +/** Class that allows optimizing out debugging code during compile time. + * Usage: to take all advantage of this class you should wrap all + * debugging statemets like this: + * \code + * if (debug_level (SomeDebugLevel) && other_optional_conditionals) { + * debug_stream() << "Debug output" << std::endl; + * } + * \endcode + * + * The order of the conditionals in the if-clause is important. + * The checks specified in \a other_optional_conditionals are only + * optimized out if \a debug_level() is placed before it with a + * logical and (short-circuiting). + */ template -class Debuggable +class /*LIBAUDIOGRAPHER_API*/ Debuggable { protected: Debuggable(std::ostream & debug_stream = std::cerr) : stream (debug_stream) {} bool debug_level (DebugLevel level) { - #ifdef NDEBUG +#ifndef NDEBUG + (void) level; /* stop pedantic gcc complaints about unused parameter */ return false; - #else +#else return L >= level; - #endif +#endif } std::ostream & debug_stream() { return stream; }