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