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 #ifndef _BASE_DEBUGTOOLS_
00026 #define _BASE_DEBUGTOOLS_
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 enum DebugID {
00053 _Debug_All = 0xffffffff,
00054 _Debug_None = 0,
00055 _Debug_Tmp = 1,
00056 _Debug_DJ = 1 << 1,
00057 _Debug_KF = 1 << 2,
00058 _Debug_LL = 1 << 3,
00059 _Debug_Ser = 1 << 4,
00060 _Debug_Base = 1 << 5,
00061 _Debug_Gfx = 1 << 6,
00062 _Debug_Physics = 1 << 7,
00063 _Debug_Robot = 1 << 8,
00064 _Debug_RobotSim = 1 << 9,
00065 _Debug_RobotControl = 1 << 10,
00066 _Debug_FSP = 1 << 11,
00067 _Debug_IKOR = 1 << 12,
00068 _Debug_JFKE = 1 << 13
00069 };
00070
00071
00072 #ifdef DEBUG
00073 extern base::Int _debugID;
00074 #define setDebugOutputID(id) { _debugID = _Debug_##id; }
00075 #define addDebugOutputID(id) { _debugID |= _Debug_##id; }
00076 #else
00077 #define setDebugOutputID(id) {}
00078 #define addDebugOutputID(id) {}
00079 #endif
00080
00081
00082 #ifdef DEBUG
00083 #undef Debug
00084
00085 #ifdef DEBUG_INCLUDE_CALLER_NAME
00086
00087 #ifndef __GNUC__
00088 #define _DEBUG_CALLER_NAME base::className(typeid(*this)) << "::" << std::string(__func__)+" -- "
00089 #else
00090
00091 #define _DEBUG_CALLER_NAME std::string(__PRETTY_FUNCTION__)+" -- "
00092 #endif
00093 #else
00094 #define _DEBUG_CALLER_NAME ""
00095 #endif
00096
00097
00098 #define UDebug(o) { base::_Debug << _DEBUG_CALLER_NAME << o; }
00099 #define UDebugln(o) { base::_Debug << _DEBUG_CALLER_NAME << o << std::endl; }
00100 #define Debug(id,o) { if (_Debug_##id & _debugID) UDebug(o); }
00101 #define Debugln(id,o) { if (_Debug_##id & _debugID) UDebugln(o); }
00102
00103
00104 #define UDebugf(o) { base::_Debug << std::string(__func__)+" -- " << o; }
00105 #define UDebugfln(o) { base::_Debug << std::string(__func__)+" -- " << o << std::endl; }
00106 #define Debugf(id,o) { if (_Debug_##id & _debugID) UDebugf(o); }
00107 #define Debugfln(id,o) { if (_Debug_##id & _debugID) UDebugfln(o); }
00108
00109 #define Debugc(id,o) { if (_Debug_##id & _debugID) { base::_Debug << o; } }
00110 #define Debugcln(id,o) { if (_Debug_##id & _debugID) { base::_Debug << o << std::endl; } }
00111
00112 #define Unimplemented { Logln("unimplemented"); throw std::runtime_error(Exception("unimplemented")); }
00113
00114 #else
00115
00116 #define UDebug(o) {}
00117 #define UDebugln(o) {}
00118 #define UDebugf(o) {}
00119 #define UDebugfln(o) {}
00120 #define Debug(id,o) {}
00121 #define Debugln(id,o) {}
00122 #define Debugf(id,o) {}
00123 #define Debugfln(id,o) {}
00124 #define Debugc(id,o) {}
00125 #define Debugcln(id,o) {}
00126
00127 #define Unimplemented { throw std::runtime_error(Exception("The program attempted to perform a function that has not yet been implemented by the developers. Please file a bug report. Sorry for the inconvenience.")); }
00128
00129 #endif
00130
00131
00132 #endif