Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkGarbageCollector.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkGarbageCollector.h,v $
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 =========================================================================*/
00079 #ifndef __vtkGarbageCollector_h
00080 #define __vtkGarbageCollector_h
00081 
00082 #include "vtkObject.h"
00083 #include "vtkGarbageCollectorManager.h" // Needed for singleton initialization.
00084 
00085 // This function is a friend of the collector so that it can call the
00086 // internal report method.
00087 void VTK_COMMON_EXPORT
00088 vtkGarbageCollectorReportInternal(vtkGarbageCollector*,
00089                                   vtkObjectBase*, void*,
00090                                   const char*);
00091 
00092 // This allows vtkObjectBase to get at the methods it needs.
00093 class vtkObjectBaseToGarbageCollectorFriendship;
00094 
00095 class VTK_COMMON_EXPORT vtkGarbageCollector : public vtkObject
00096 {
00097 public:
00098   vtkTypeRevisionMacro(vtkGarbageCollector,vtkObject);
00099   void PrintSelf(ostream& os, vtkIndent indent);
00100   static vtkGarbageCollector* New();
00101 
00111   static void Collect();
00112 
00121   static void Collect(vtkObjectBase* root);
00122 
00124 
00128   static void DeferredCollectionPush();
00129   static void DeferredCollectionPop();
00131 
00133 
00135   static void SetGlobalDebugFlag(int flag);
00136   static int GetGlobalDebugFlag();
00138 
00139 protected:
00140   vtkGarbageCollector();
00141   ~vtkGarbageCollector();
00142 
00143 private:
00144 
00152   static int GiveReference(vtkObjectBase* obj);
00153 
00159   static int TakeReference(vtkObjectBase* obj);
00160 
00161   // Singleton management functions.
00162   static void ClassInitialize();
00163   static void ClassFinalize();
00164 
00165   //BTX
00166   friend class vtkGarbageCollectorManager;
00167   friend class vtkObjectBaseToGarbageCollectorFriendship;
00168   //ETX
00169 
00170   // Internal report callback and friend function that calls it.
00171   virtual void Report(vtkObjectBase* obj, void* ptr, const char* desc);
00172   friend void VTK_COMMON_EXPORT
00173   vtkGarbageCollectorReportInternal(vtkGarbageCollector*,
00174                                     vtkObjectBase*, void*,
00175                                     const char*);
00176 
00177 private:
00178   vtkGarbageCollector(const vtkGarbageCollector&);  // Not implemented.
00179   void operator=(const vtkGarbageCollector&);  // Not implemented.
00180 };
00181 
00182 //BTX
00183 class vtkSmartPointerBase;
00184 
00186 
00187 void VTK_COMMON_EXPORT
00188 vtkGarbageCollectorReport(vtkGarbageCollector* collector,
00189                           vtkSmartPointerBase& ptr,
00190                           const char* desc);
00192 
00194 
00195 template <class T>
00196 void vtkGarbageCollectorReport(vtkGarbageCollector* collector, T*& ptr,
00197                                const char* desc)
00199 {
00200   vtkGarbageCollectorReportInternal(collector, ptr, &ptr, desc);
00201 }
00202 //ETX
00203 
00204 #endif

Generated on Mon Jan 21 23:07:17 2008 for VTK by  doxygen 1.4.3-20050530