VTK
vtkGarbageCollector.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGarbageCollector.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 =========================================================================*/
81 #ifndef vtkGarbageCollector_h
82 #define vtkGarbageCollector_h
83 
84 #include "vtkCommonCoreModule.h" // For export macro
85 #include "vtkObject.h"
86 #include "vtkGarbageCollectorManager.h" // Needed for singleton initialization.
87 
88 // This function is a friend of the collector so that it can call the
89 // internal report method.
92  vtkObjectBase*, void*,
93  const char*);
94 
95 // This allows vtkObjectBase to get at the methods it needs.
96 class vtkObjectBaseToGarbageCollectorFriendship;
97 
99 {
100 public:
102  void PrintSelf(ostream& os, vtkIndent indent);
104 
114  static void Collect();
115 
124  static void Collect(vtkObjectBase* root);
125 
127 
131  static void DeferredCollectionPush();
132  static void DeferredCollectionPop();
134 
136 
138  static void SetGlobalDebugFlag(bool flag);
139  static bool GetGlobalDebugFlag();
141 
142 protected:
145 
146 private:
147 
155  static int GiveReference(vtkObjectBase* obj);
156 
162  static int TakeReference(vtkObjectBase* obj);
163 
164  // Singleton management functions.
165  static void ClassInitialize();
166  static void ClassFinalize();
167 
168  //BTX
170  friend class vtkObjectBaseToGarbageCollectorFriendship;
171  //ETX
172 
173  // Internal report callback and friend function that calls it.
174  virtual void Report(vtkObjectBase* obj, void* ptr, const char* desc);
175  friend void VTKCOMMONCORE_EXPORT
177  vtkObjectBase*, void*,
178  const char*);
179 
180 private:
181  vtkGarbageCollector(const vtkGarbageCollector&); // Not implemented.
182  void operator=(const vtkGarbageCollector&); // Not implemented.
183 };
184 
185 //BTX
186 class vtkSmartPointerBase;
187 
189 
192  vtkSmartPointerBase& ptr,
193  const char* desc);
195 
197 
198 template <class T>
200  const char* desc)
201 {
202  vtkGarbageCollectorReportInternal(collector, ptr, &ptr, desc);
203 }
204 //ETX
206 
207 #endif
208 // VTK-HeaderTest-Exclude: vtkGarbageCollector.h
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkgl::obj
GLsizei GLsizei GLuint * obj
Definition: vtkgl.h:11994
vtkGarbageCollector::New
static vtkGarbageCollector * New()
vtkGarbageCollectorReport
void VTKCOMMONCORE_EXPORT vtkGarbageCollectorReport(vtkGarbageCollector *collector, vtkSmartPointerBase &ptr, const char *desc)
vtkSmartPointerBase
Non-templated superclass for vtkSmartPointer.
Definition: vtkSmartPointerBase.h:32
vtkGarbageCollector::Collect
static void Collect()
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkGarbageCollector::SetGlobalDebugFlag
static void SetGlobalDebugFlag(bool flag)
vtkGarbageCollector::DeferredCollectionPop
static void DeferredCollectionPop()
vtkGarbageCollector::DeferredCollectionPush
static void DeferredCollectionPush()
vtkCommonCoreModule.h
vtkGarbageCollector::vtkGarbageCollector
vtkGarbageCollector()
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:60
vtkGarbageCollectorReportInternal
void VTKCOMMONCORE_EXPORT vtkGarbageCollectorReportInternal(vtkGarbageCollector *, vtkObjectBase *, void *, const char *)
vtkGarbageCollectorManager.h
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkGarbageCollector::GetGlobalDebugFlag
static bool GetGlobalDebugFlag()
vtkGarbageCollector::vtkGarbageCollectorReportInternal
friend void VTKCOMMONCORE_EXPORT vtkGarbageCollectorReportInternal(vtkGarbageCollector *, vtkObjectBase *, void *, const char *)
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:99
vtkObject.h
vtkGarbageCollector::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkGarbageCollectorManager
Manages the vtkGarbageCollector singleton.
Definition: vtkGarbageCollectorManager.h:34
vtkGarbageCollector::Collect
static void Collect(vtkObjectBase *root)
vtkGarbageCollector::~vtkGarbageCollector
~vtkGarbageCollector()