Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

debug.h

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__
00020 #define __CS_UTIL_DEBUG__
00021 
00022 // Enable the following define to have the DG_... macros.
00023 //#define CS_USE_GRAPHDEBUG
00024 
00025 struct iBase;
00026 struct iObjectRegistry;
00027 
00028 // The following versions of the defines are only available in
00029 // debug mode. In release mode they do nothing. They expect SetupGraph()
00030 // to be called with a valid object registry.
00031 #if defined(CS_DEBUG) && defined(CS_USE_GRAPHDEBUG)
00032 #define DG_ADD(obj,desc) \
00033   csDebuggingGraph::AddObject(NULL,(void*)(obj),false,__FILE__,__LINE__,desc)
00034 #define DG_ADDI(obj,desc) \
00035   csDebuggingGraph::AddObject(NULL,(void*)(obj),true,__FILE__,__LINE__,desc)
00036 #define DG_TYPE(obj,type) \
00037   csDebuggingGraph::AttachType(NULL,(void*)(obj),type)
00038 #define DG_DESCRIBE0(obj,desc) \
00039   csDebuggingGraph::AttachDescription(NULL,(void*)(obj),desc)
00040 #define DG_DESCRIBE1(obj,desc,a) \
00041   csDebuggingGraph::AttachDescription(NULL,(void*)(obj),desc,a)
00042 #define DG_DESCRIBE2(obj,desc,a,b) \
00043   csDebuggingGraph::AttachDescription(NULL,(void*)(obj),desc,a,b)
00044 #define DG_REM(obj) \
00045   csDebuggingGraph::RemoveObject(NULL,(void*)(obj),__FILE__,__LINE__)
00046 #define DG_ADDCHILD(parent,child) \
00047   csDebuggingGraph::AddChild(NULL,(void*)(parent),(void*)(child))
00048 #define DG_ADDPARENT(child,parent) \
00049   csDebuggingGraph::AddParent(NULL,(void*)(child),(void*)(parent))
00050 #define DG_REMCHILD(parent,child) \
00051   csDebuggingGraph::RemoveChild(NULL,(void*)(parent),(void*)(child))
00052 #define DG_REMPARENT(child,parent) \
00053   csDebuggingGraph::RemoveParent(NULL,(void*)(child),(void*)(parent))
00054 #define DG_LINK(parent,child) \
00055   csDebuggingGraph::AddChild(NULL,(void*)(parent),(void*)(child)); \
00056   csDebuggingGraph::AddParent(NULL,(void*)(child),(void*)(parent))
00057 #define DG_UNLINK(parent,child) \
00058   csDebuggingGraph::RemoveChild(NULL,(void*)(parent),(void*)(child)); \
00059   csDebuggingGraph::RemoveParent(NULL,(void*)(child),(void*)(parent))
00060 #else
00061 #define DG_ADD(obj,desc)
00062 #define DG_ADDI(obj,desc)
00063 #define DG_TYPE(obj,type)
00064 #define DG_DESCRIBE0(obj,desc)
00065 #define DG_DESCRIBE1(obj,desc,a)
00066 #define DG_DESCRIBE2(obj,desc,a,b)
00067 #define DG_REM(obj)
00068 #define DG_ADDCHILD(parent,child)
00069 #define DG_ADDPARENT(child,parent)
00070 #define DG_REMCHILD(parent,child)
00071 #define DG_REMPARENT(child,parent)
00072 #define DG_LINK(parent,child)
00073 #define DG_UNLINK(parent,child)
00074 #endif
00075 
00082 class csDebuggingGraph
00083 {
00084 public:
00092   static void SetupGraph (iObjectRegistry* object_reg);
00093 
00098   static void AddObject (iObjectRegistry* object_reg,
00099         void* object, bool scf, char* file, int linenr,
00100         char* description, ...);
00101 
00105   static void AttachDescription (iObjectRegistry* object_reg,
00106         void* object, char* description, ...) CS_GNUC_PRINTF (3, 4);
00107 
00111   static void AttachType (iObjectRegistry* object_reg,
00112         void* object, char* type);
00113 
00117   static void RemoveObject (iObjectRegistry* object_reg,
00118         void* object, char* file, int linenr);
00119 
00123   static void AddChild (iObjectRegistry* object_reg,
00124         void* parent, void* child);
00125 
00129   static void AddParent (iObjectRegistry* object_reg,
00130         void* child, void* parent);
00131 
00135   static void RemoveChild (iObjectRegistry* object_reg,
00136         void* parent, void* child);
00137 
00141   static void RemoveParent (iObjectRegistry* object_reg,
00142         void* child, void* parent);
00143 
00147   static void Clear (iObjectRegistry* object_reg);
00148 
00152   static void Dump (iObjectRegistry* object_reg);
00153 
00158   static void Dump (iObjectRegistry* object_reg, void* object,
00159         bool reset_mark = true);
00160 };
00161 
00162 #endif //__CS_UTIL_DEBUG__
00163 

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000