1 #ifndef AUDIOGRAPHER_FLAG_DEBUGGABLE_H
2 #define AUDIOGRAPHER_FLAG_DEBUGGABLE_H
4 #include "audiographer/visibility.h"
5 #include "debuggable.h"
6 #include "debug_utils.h"
7 #include "process_context.h"
10 #include <boost/format.hpp>
12 namespace AudioGrapher
15 /// A debugging class for nodes that support a certain set of flags.
16 template<DebugLevel L = DEFAULT_DEBUG_LEVEL>
17 class LIBAUDIOGRAPHER_API FlagDebuggable : public Debuggable<L>
20 typedef FlagField::Flag Flag;
24 /// Adds a flag to the set of flags supported
25 void add_supported_flag (Flag flag)
30 /// Prints debug output if \a context contains flags that are not supported by this class
31 template<typename SelfType, typename ContextType>
32 void check_flags (SelfType & self, ProcessContext<ContextType> context)
34 if (!Debuggable<L>::debug_level (DebugFlags)) { return; }
35 FlagField unsupported = flags.unsupported_flags_of (context.flags());
37 for (FlagField::iterator it = unsupported.begin(); it != unsupported.end(); ++it) {
38 Debuggable<L>::debug_stream() << boost::str (boost::format
39 ("%1% does not support flag %2%")
40 % DebugUtils::demangled_name (self) % DebugUtils::process_context_flag_name (*it)
52 #endif // AUDIOGRAPHER_FLAG_DEBUGGABLE_H