Fix export threading timeouts when disk operations take long. Might fix other timeout...
[ardour.git] / libs / audiographer / audiographer / flag_debuggable.h
1 #ifndef AUDIOGRAPHER_FLAG_DEBUGGABLE_H
2 #define AUDIOGRAPHER_FLAG_DEBUGGABLE_H
3
4 #include "debuggable.h"
5 #include "debug_utils.h"
6 #include "process_context.h"
7 #include "types.h"
8
9 #include <boost/format.hpp>
10
11 namespace AudioGrapher
12 {
13
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>
17 {
18   public:
19         typedef FlagField::Flag Flag;
20
21   protected:
22
23         /// Adds a flag to the set of flags supported
24         void add_supported_flag (Flag flag)
25         {
26                 flags.set (flag);
27         }
28         
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)
32         {
33                 if (!Debuggable<L>::debug_level (DebugFlags)) { return; }
34                 FlagField unsupported = flags.unsupported_flags_of (context.flags());
35                 
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)
40                                 ) << std::endl;
41                 }
42         }
43
44   private:
45         FlagField flags;
46 };
47
48
49 } // namespace
50
51 #endif // AUDIOGRAPHER_FLAG_DEBUGGABLE_H