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 "vtkCommonCoreModule.h" // For export macro
35 #include "vtkObject.h"
36 
37 #include "vtkToolkits.h" // Needed for VTK_DEBUG_LEAKS macro setting.
38 #include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
39 
40 class vtkDebugLeaksHashTable;
43 
45 {
46 public:
47  static vtkDebugLeaks *New();
48  vtkTypeMacro(vtkDebugLeaks,vtkObject);
49 
51  static void ConstructClass(const char* classname);
52 
54  static void DestructClass(const char* classname);
55 
58  static int PrintCurrentLeaks();
59 
61 
63  static int GetExitError();
64  static void SetExitError(int);
65  //BTX
66  static void SetDebugLeaksObserver(vtkDebugLeaksObserver* observer);
67  static vtkDebugLeaksObserver* GetDebugLeaksObserver();
68  //ETX
70 
71 protected:
73  virtual ~vtkDebugLeaks(){}
74 
75  static int DisplayMessageBox(const char*);
76 
77  static void ClassInitialize();
78  static void ClassFinalize();
79 
80  static void ConstructingObject(vtkObjectBase* object);
81  static void DestructingObject(vtkObjectBase* object);
82 
83  //BTX
84  friend class vtkDebugLeaksManager;
85  friend class vtkObjectBase;
86  //ETX
87 
88 private:
89  static vtkDebugLeaksHashTable* MemoryTable;
90  static vtkSimpleCriticalSection* CriticalSection;
91  static vtkDebugLeaksObserver* Observer;
92  static int ExitError;
93 
94  vtkDebugLeaks(const vtkDebugLeaks&); // Not implemented.
95  void operator=(const vtkDebugLeaks&); // Not implemented.
96 };
97 
98 //BTX
99 // This class defines callbacks for debugging tools. The callbacks are not for general use.
100 // The objects passed as arguments to the callbacks are in partially constructed or destructed
101 // state and accessing them may cause undefined behavior.
103 public:
105  virtual void ConstructingObject(vtkObjectBase*) = 0;
106  virtual void DestructingObject(vtkObjectBase*) = 0;
107 };
108 //ETX
109 
110 #endif // vtkDebugLeaks_h
111 // VTK-HeaderTest-Exclude: vtkDebugLeaks.h
abstract base class for most VTK objects
Definition: vtkObject.h:61
#define VTKCOMMONCORE_EXPORT
virtual ~vtkDebugLeaksObserver()
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
identify memory leaks at program termination
Definition: vtkDebugLeaks.h:44
Critical section locking class.
static vtkObject * New()
virtual ~vtkDebugLeaks()
Definition: vtkDebugLeaks.h:73
void operator=(const vtkObjectBase &)
Manages the vtkDebugLeaks singleton.