1 #ifndef AUDIOGRAPHER_FLAG_DEBUGGABLE_H 2 #define AUDIOGRAPHER_FLAG_DEBUGGABLE_H 3 4 #include "audiographer/visibility.h" 5 #include "debuggable.h" 6 #include "debug_utils.h" 7 #include "process_context.h" 8 #include "types.h" 9 10 #include <boost/format.hpp> 11 12 namespace AudioGrapher 13 { 14 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> 18 { 19 public: 20 typedef FlagField::Flag Flag; 21 22 protected: 23 24 /// Adds a flag to the set of flags supported add_supported_flag(Flag flag)25 void add_supported_flag (Flag flag) 26 { 27 flags.set (flag); 28 } 29 30 /// Prints debug output if \a context contains flags that are not supported by this class 31 template<typename SelfType, typename ContextType> check_flags(SelfType & self,ProcessContext<ContextType> context)32 void check_flags (SelfType & self, ProcessContext<ContextType> context) 33 { 34 if (!Debuggable<L>::debug_level (DebugFlags)) { return; } 35 FlagField unsupported = flags.unsupported_flags_of (context.flags()); 36 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) 41 ) << std::endl; 42 } 43 } 44 45 private: 46 FlagField flags; 47 }; 48 49 50 } // namespace 51 52 #endif // AUDIOGRAPHER_FLAG_DEBUGGABLE_H 53