VTK
vtkDebugLeaks.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDebugLeaks.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
31 #ifndef __vtkDebugLeaks_h
32 #define __vtkDebugLeaks_h
33 
34 #include "vtkObject.h"
35 
36 #include "vtkToolkits.h" // Needed for VTK_DEBUG_LEAKS macro setting.
37 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
38 
39 class vtkDebugLeaksHashTable;
42 
44 {
45 public:
46  static vtkDebugLeaks *New();
47  vtkTypeMacro(vtkDebugLeaks,vtkObject);
48 
50  static void ConstructClass(const char* classname);
51 
53  static void DestructClass(const char* classname);
54 
57  static int PrintCurrentLeaks();
58 
60 
62  VTK_LEGACY(static void PromptUserOn());
63  VTK_LEGACY(static void PromptUserOff());
65 
67 
69  static int GetExitError();
70  static void SetExitError(int);
71  //BTX
72  static void SetDebugLeaksObserver(vtkDebugLeaksObserver* observer);
73  static vtkDebugLeaksObserver* GetDebugLeaksObserver();
74  //ETX
76 
77 protected:
79  virtual ~vtkDebugLeaks(){};
80 
81  static int DisplayMessageBox(const char*);
82 
83  static void ClassInitialize();
84  static void ClassFinalize();
85 
86  static void ConstructingObject(vtkObjectBase* object);
87  static void DestructingObject(vtkObjectBase* object);
88 
89  //BTX
90  friend class vtkDebugLeaksManager;
91  friend class vtkObjectBase;
92  //ETX
93 
94 private:
95  static vtkDebugLeaksHashTable* MemoryTable;
96  static vtkSimpleCriticalSection* CriticalSection;
97  static vtkDebugLeaksObserver* Observer;
98  static int ExitError;
99 
100  vtkDebugLeaks(const vtkDebugLeaks&); // Not implemented.
101  void operator=(const vtkDebugLeaks&); // Not implemented.
102 };
103 
104 //BTX
105 // This class defines callbacks for debugging tools. The callbacks are not for general use.
106 // The objects passed as arguments to the callbacks are in partially constructed or destructed
107 // state and accessing them may cause undefined behavior.
109 public:
111  virtual void ConstructingObject(vtkObjectBase*) = 0;
112  virtual void DestructingObject(vtkObjectBase*) = 0;
113 };
114 //ETX
115 
116 #endif // __vtkDebugLeaks_h