csutil/debug.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2001 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_UTIL_DEBUG_H__ 00020 #define __CS_UTIL_DEBUG_H__ 00021 00026 #include "csextern.h" 00027 00028 // Enable the following define to have the DG_... macros. 00029 //#define CS_USE_GRAPHDEBUG 00030 00031 struct iBase; 00032 struct iObjectRegistry; 00033 00034 // The following versions of the defines are only available in 00035 // debug mode. In release mode they do nothing. They expect SetupGraph() 00036 // to be called with a valid object registry. 00037 #if defined(CS_DEBUG) && defined(CS_USE_GRAPHDEBUG) 00038 #define DG_ADD(obj,desc) \ 00039 csDebuggingGraph::AddObject(0,(void*)(obj),false,__FILE__,__LINE__,desc) 00040 #define DG_ADDI(obj,desc) \ 00041 csDebuggingGraph::AddObject(0,(void*)(obj),true,__FILE__,__LINE__,desc) 00042 #define DG_TYPE(obj,type) \ 00043 csDebuggingGraph::AttachType(0,(void*)(obj),type) 00044 #define DG_DESCRIBE0(obj,desc) \ 00045 csDebuggingGraph::AttachDescription(0,(void*)(obj),desc) 00046 #define DG_DESCRIBE1(obj,desc,a) \ 00047 csDebuggingGraph::AttachDescription(0,(void*)(obj),desc,a) 00048 #define DG_DESCRIBE2(obj,desc,a,b) \ 00049 csDebuggingGraph::AttachDescription(0,(void*)(obj),desc,a,b) 00050 #define DG_REM(obj) \ 00051 csDebuggingGraph::RemoveObject(0,(void*)(obj),__FILE__,__LINE__) 00052 #define DG_ADDCHILD(parent,child) \ 00053 csDebuggingGraph::AddChild(0,(void*)(parent),(void*)(child)) 00054 #define DG_ADDPARENT(child,parent) \ 00055 csDebuggingGraph::AddParent(0,(void*)(child),(void*)(parent)) 00056 #define DG_REMCHILD(parent,child) \ 00057 csDebuggingGraph::RemoveChild(0,(void*)(parent),(void*)(child)) 00058 #define DG_REMPARENT(child,parent) \ 00059 csDebuggingGraph::RemoveParent(0,(void*)(child),(void*)(parent)) 00060 #define DG_LINK(parent,child) \ 00061 csDebuggingGraph::AddChild(0,(void*)(parent),(void*)(child)); \ 00062 csDebuggingGraph::AddParent(0,(void*)(child),(void*)(parent)) 00063 #define DG_UNLINK(parent,child) \ 00064 csDebuggingGraph::RemoveChild(0,(void*)(parent),(void*)(child)); \ 00065 csDebuggingGraph::RemoveParent(0,(void*)(child),(void*)(parent)) 00066 #else 00067 #define DG_ADD(obj,desc) 00068 #define DG_ADDI(obj,desc) 00069 #define DG_TYPE(obj,type) 00070 #define DG_DESCRIBE0(obj,desc) 00071 #define DG_DESCRIBE1(obj,desc,a) 00072 #define DG_DESCRIBE2(obj,desc,a,b) 00073 #define DG_REM(obj) 00074 #define DG_ADDCHILD(parent,child) 00075 #define DG_ADDPARENT(child,parent) 00076 #define DG_REMCHILD(parent,child) 00077 #define DG_REMPARENT(child,parent) 00078 #define DG_LINK(parent,child) 00079 #define DG_UNLINK(parent,child) 00080 #endif 00081 00088 class CS_CRYSTALSPACE_EXPORT csDebuggingGraph 00089 { 00090 public: 00098 static void SetupGraph (iObjectRegistry* object_reg); 00099 00105 static void AddObject (iObjectRegistry* object_reg, 00106 void* object, bool scf, char* file, int linenr, 00107 char* description, ...); 00108 00113 static void AttachDescription (iObjectRegistry* object_reg, 00114 void* object, char* description, ...) CS_GNUC_PRINTF (3, 4); 00115 00119 static void AttachType (iObjectRegistry* object_reg, 00120 void* object, char* type); 00121 00125 static void RemoveObject (iObjectRegistry* object_reg, 00126 void* object, char* file, int linenr); 00127 00131 static void AddChild (iObjectRegistry* object_reg, 00132 void* parent, void* child); 00133 00137 static void AddParent (iObjectRegistry* object_reg, 00138 void* child, void* parent); 00139 00143 static void RemoveChild (iObjectRegistry* object_reg, 00144 void* parent, void* child); 00145 00149 static void RemoveParent (iObjectRegistry* object_reg, 00150 void* child, void* parent); 00151 00155 static void Clear (iObjectRegistry* object_reg); 00156 00160 static void Dump (iObjectRegistry* object_reg); 00161 00166 static void Dump (iObjectRegistry* object_reg, void* object, 00167 bool reset_mark = true); 00168 }; 00169 00170 #endif //__CS_UTIL_DEBUG_H__ 00171
Generated for Crystal Space by doxygen 1.4.7