00001 #ifndef ABUSEDEBUG_H 00002 #define ABUSEDEBUG_H 00003 00004 #ifdef _DEBUG 00005 00006 00007 template<class T> 00008 void DebugOut(T what); 00009 00010 template<> 00011 void DebugOut(const char* value); 00012 00013 class Tracker 00014 { 00015 public: 00016 Tracker(const std::string& _funcName):funcName(_funcName) 00017 { 00018 DebugOut(indent()+std::string("Entering ")+funcName); 00019 ++level; 00020 } 00021 virtual ~Tracker() 00022 { 00023 --level; 00024 DebugOut(indent()+std::string("Exiting ")+funcName); 00025 } 00026 private: 00027 std::string funcName; 00028 static int level; 00029 std::string indent() 00030 { 00031 std::string tmp=""; 00032 for(int i=0;i<level;++i) 00033 tmp+="--"; 00034 return tmp; 00035 } 00036 }; 00037 00038 00039 00040 #define Track(n) Tracker __tracker__(n) 00041 00042 #else //_!DEBUG 00043 #define DebugOut(n) 00044 #define Track 00045 #endif 00046 00047 #endif //ABUSEDEBUG