7b9e50124ae3454820162f794656683ada6a3cb1
[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 <string>
7
8 #ifdef __GNUC__
9 #include <cxxabi.h>
10 #include <cstdlib>
11 #endif
12
13 namespace AudioGrapher
14 {
15
16 /// Utilities for debugging
17 struct DebugUtils
18 {
19         /// Returns the demangled name of the object passed as the parameter
20         template<typename T>
21         static std::string demangled_name (T const & obj)
22         {
23 #ifdef __GNUC__
24                 int status;
25                 char * res = abi::__cxa_demangle (typeid(obj).name(), 0, 0, &status);
26                 if (status == 0) {
27                         std::string s(res);
28                         free (res);
29                         return s;
30                 }
31 #endif
32                 return typeid(obj).name();
33         }
34         
35         /// Returns name of ProcessContext::Flag
36         static std::string process_context_flag_name (FlagField::Flag flag);
37 };
38
39 } // namespace
40
41 #endif // AUDIOGRAPHER_DEBUG_UTILS_H