Merge branch 'master' into windows
[ardour.git] / libs / audiographer / audiographer / debug_utils.h
1 #ifndef AUDIOGRAPHER_DEBUG_UTILS_H
2 #define AUDIOGRAPHER_DEBUG_UTILS_H
3
4 #include "flag_field.h"
5
6 #include <cstdlib>
7 #include <string>
8
9 #ifdef __GNUC__
10 #include <cxxabi.h>
11 #include <cstdlib>
12 #endif
13
14 namespace AudioGrapher
15 {
16
17 /// Utilities for debugging
18 struct DebugUtils
19 {
20         /// Returns the demangled name of the object passed as the parameter
21         template<typename T>
22         static std::string demangled_name (T const & obj)
23         {
24 #ifdef __GNUC__
25                 int status;
26                 char * res = abi::__cxa_demangle (typeid(obj).name(), 0, 0, &status);
27                 if (status == 0) {
28                         std::string s(res);
29                         std::free (res);
30                         return s;
31                 }
32 #endif
33                 return typeid(obj).name();
34         }
35         
36         /// Returns name of ProcessContext::Flag
37         static std::string process_context_flag_name (FlagField::Flag flag);
38 };
39
40 } // namespace
41
42 #endif // AUDIOGRAPHER_DEBUG_UTILS_H