VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkDebugLeaks.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00031 #ifndef __vtkDebugLeaks_h 00032 #define __vtkDebugLeaks_h 00033 00034 #include "vtkCommonCoreModule.h" // For export macro 00035 #include "vtkObject.h" 00036 00037 #include "vtkToolkits.h" // Needed for VTK_DEBUG_LEAKS macro setting. 00038 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization 00039 00040 class vtkDebugLeaksHashTable; 00041 class vtkSimpleCriticalSection; 00042 class vtkDebugLeaksObserver; 00043 00044 class VTKCOMMONCORE_EXPORT vtkDebugLeaks : public vtkObject 00045 { 00046 public: 00047 static vtkDebugLeaks *New(); 00048 vtkTypeMacro(vtkDebugLeaks,vtkObject); 00049 00051 static void ConstructClass(const char* classname); 00052 00054 static void DestructClass(const char* classname); 00055 00058 static int PrintCurrentLeaks(); 00059 00061 00063 static int GetExitError(); 00064 static void SetExitError(int); 00065 //BTX 00066 static void SetDebugLeaksObserver(vtkDebugLeaksObserver* observer); 00067 static vtkDebugLeaksObserver* GetDebugLeaksObserver(); 00068 //ETX 00070 00071 protected: 00072 vtkDebugLeaks(){}; 00073 virtual ~vtkDebugLeaks(){}; 00074 00075 static int DisplayMessageBox(const char*); 00076 00077 static void ClassInitialize(); 00078 static void ClassFinalize(); 00079 00080 static void ConstructingObject(vtkObjectBase* object); 00081 static void DestructingObject(vtkObjectBase* object); 00082 00083 //BTX 00084 friend class vtkDebugLeaksManager; 00085 friend class vtkObjectBase; 00086 //ETX 00087 00088 private: 00089 static vtkDebugLeaksHashTable* MemoryTable; 00090 static vtkSimpleCriticalSection* CriticalSection; 00091 static vtkDebugLeaksObserver* Observer; 00092 static int ExitError; 00093 00094 vtkDebugLeaks(const vtkDebugLeaks&); // Not implemented. 00095 void operator=(const vtkDebugLeaks&); // Not implemented. 00096 }; 00097 00098 //BTX 00099 // This class defines callbacks for debugging tools. The callbacks are not for general use. 00100 // The objects passed as arguments to the callbacks are in partially constructed or destructed 00101 // state and accessing them may cause undefined behavior. 00102 class VTKCOMMONCORE_EXPORT vtkDebugLeaksObserver { 00103 public: 00104 virtual ~vtkDebugLeaksObserver() {}; 00105 virtual void ConstructingObject(vtkObjectBase*) = 0; 00106 virtual void DestructingObject(vtkObjectBase*) = 0; 00107 }; 00108 //ETX 00109 00110 #endif // __vtkDebugLeaks_h 00111 // VTK-HeaderTest-Exclude: vtkDebugLeaks.h