summaryrefslogtreecommitdiff
path: root/libs/audiographer/audiographer/debuggable.h
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2009-12-27 22:09:40 +0000
committerSakari Bergen <sakari.bergen@beatwaves.net>2009-12-27 22:09:40 +0000
commit8da27200d18fe4c471a759dde8e10d85ff29d277 (patch)
tree8a68123da7cb8539a9818704363e3fd98da4d385 /libs/audiographer/audiographer/debuggable.h
parentdde0848a984e06cbc1d4117d9cffa75c191f3b39 (diff)
- Fix process callbakc handling during export
- Fix filename handling when exporting multiple files - Some updates to audiographer git-svn-id: svn://localhost/ardour2/branches/3.0@6402 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/audiographer/audiographer/debuggable.h')
-rw-r--r--libs/audiographer/audiographer/debuggable.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/libs/audiographer/audiographer/debuggable.h b/libs/audiographer/audiographer/debuggable.h
new file mode 100644
index 0000000000..4126327b86
--- /dev/null
+++ b/libs/audiographer/audiographer/debuggable.h
@@ -0,0 +1,46 @@
+#ifndef AUDIOGRAPHER_DEBUGGABLE_H
+#define AUDIOGRAPHER_DEBUGGABLE_H
+
+#ifndef DEFAULT_DEBUG_LEVEL
+#define DEFAULT_DEBUG_LEVEL DebugNone
+#endif
+
+#include <iostream>
+
+namespace AudioGrapher
+{
+
+enum 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
+};
+
+/// Class that allows optimizing out debugging code during compile time
+template<DebugLevel L = DEFAULT_DEBUG_LEVEL>
+class Debuggable
+{
+ protected:
+ Debuggable(std::ostream & debug_stream = std::cerr)
+ : stream (debug_stream) {}
+
+ bool debug_level (DebugLevel level) {
+ #ifdef NDEBUG
+ return false;
+ #else
+ return L >= level;
+ #endif
+ }
+ std::ostream & debug_stream() { return stream; }
+
+ private:
+ std::ostream & stream;
+};
+
+
+} // namespace
+
+#endif // AUDIOGRAPHER_DEBUGGABLE_H