00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00036 #ifndef OW_FUNC_NAME_PRINTER_HPP
00037 #define OW_FUNC_NAME_PRINTER_HPP
00038 #include "OW_config.h"
00039 #include "OW_Format.hpp"
00040 #include <stdio.h>
00041 #include <unistd.h>
00042
00043
00044
00045
00046
00047 #ifdef OW_PRINT_FUNC_DEBUG
00048 #define PRINT_FUNC_NAME OW_FuncNamePrinter fnp##__LINE__ (__PRETTY_FUNCTION__)
00049
00050 #define PRINT_FUNC_NAME_ARGS1(a) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a)
00051 #define PRINT_FUNC_NAME_ARGS2(a, b) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b)
00052 #define PRINT_FUNC_NAME_ARGS3(a, b, c) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c)
00053 #define PRINT_FUNC_NAME_ARGS4(a, b, c, d) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d)
00054 #define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e)
00055 #define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f)
00056 #define PRINT_FUNC_NAME_ARGS7(a, b, c, d, e, f, g) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g)
00057 #define PRINT_FUNC_NAME_ARGS8(a, b, c, d, e, f, g, h) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h)
00058 #define PRINT_FUNC_NAME_ARGS9(a, b, c, d, e, f, g, h, i) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h, i)
00059 #define PRINT_FUNC_NAME_ARGS10(a, b, c, d, e, f, g, h, i, j) OW_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h, i, j)
00060 #else
00061 #define PRINT_FUNC_NAME_ARGS1(a)
00062 #define PRINT_FUNC_NAME_ARGS2(a, b)
00063 #define PRINT_FUNC_NAME_ARGS3(a, b, c)
00064 #define PRINT_FUNC_NAME_ARGS4(a, b, c, d)
00065 #define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e)
00066 #define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f)
00067 #define PRINT_FUNC_NAME_ARGS7(a, b, c, d, e, f, g)
00068 #define PRINT_FUNC_NAME_ARGS8(a, b, c, d, e, f, g, h)
00069 #define PRINT_FUNC_NAME_ARGS9(a, b, c, d, e, f, g, h, i)
00070 #define PRINT_FUNC_NAME_ARGS10(a, b, c, d, e, f, g, h, i, j)
00071 #define PRINT_FUNC_NAME
00072 #endif
00073
00074 namespace OW_NAMESPACE
00075 {
00076
00077 class FuncNamePrinter
00078 {
00079 private:
00080 const char* m_funcName;
00081 public:
00082
00083 FuncNamePrinter(const char* funcName) : m_funcName(funcName)
00084 {
00085 fprintf(stderr, "%d Entering: %s\n", getpid(), funcName);
00086 }
00087 template<typename A>
00088 FuncNamePrinter(const char* funcName, const A& a) : m_funcName(funcName)
00089 {
00090 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00091 Format("(%1)", a).c_str());
00092 }
00093 template<typename A, typename B>
00094 FuncNamePrinter(const char* funcName, const A& a, const B& b) : m_funcName(funcName)
00095 {
00096 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00097 Format("(%1, %2)", a, b).c_str());
00098 }
00099 template<typename A, typename B, typename C>
00100 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c) : m_funcName(funcName)
00101 {
00102 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00103 Format("(%1, %2, %3)", a, b, c).c_str());
00104 }
00105 template<typename A, typename B, typename C, typename D>
00106 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d) : m_funcName(funcName)
00107 {
00108 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00109 Format("(%1, %2, %3, %4)", a, b, c, d).c_str());
00110 }
00111 template<typename A, typename B, typename C, typename D, typename E>
00112 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e) : m_funcName(funcName)
00113 {
00114 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00115 Format("(%1, %2, %3, %4, %5)", a, b, c, d, e).c_str());
00116 }
00117 template<typename A, typename B, typename C, typename D, typename E, typename F>
00118 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f) : m_funcName(funcName)
00119 {
00120 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00121 Format("(%1, %2, %3, %4, %5, %6)", a, b, c, d, e, f).c_str());
00122 }
00123 template<typename A, typename B, typename C, typename D, typename E, typename F,
00124 typename G>
00125 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g) : m_funcName(funcName)
00126 {
00127 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00128 Format("(%1, %2, %3, %4, %5, %6, %7)", a, b, c, d, e, f, g).c_str());
00129 }
00130 template<typename A, typename B, typename C, typename D, typename E, typename F,
00131 typename G, typename H>
00132 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h) : m_funcName(funcName)
00133 {
00134 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00135 Format("(%1, %2, %3, %4, %5, %6, %7, %8)", a, b, c, d, e, f, g, h).c_str());
00136 }
00137 template<typename A, typename B, typename C, typename D, typename E, typename F,
00138 typename G, typename H, typename I>
00139 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i) : m_funcName(funcName)
00140 {
00141 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00142 Format("(%1, %2, %3, %4, %5, %6, %7, %8, %9)", a, b, c, d, e, f, g, h, i).c_str());
00143 }
00144 template<typename A, typename B, typename C, typename D, typename E, typename F,
00145 typename G, typename H, typename I, typename J>
00146 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j) : m_funcName(funcName)
00147 {
00148 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00149 Format("(%1, %2, %3, %4, %5, %6, %7, %8, %9)", a, b, c, d, e, f, g, h, Format("%1, %2", i, j)).c_str());
00150 }
00151 ~FuncNamePrinter()
00152 { fprintf(stderr, "%d Leaving: %s\n", getpid(), m_funcName); }
00153 };
00154
00155 }
00156
00157 #endif //#define OW_FUNC_NAME_PRINTER_HPP