VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkObjectBase.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 =========================================================================*/ 00045 #ifndef __vtkObjectBase_h 00046 #define __vtkObjectBase_h 00047 00048 #include "vtkIndent.h" 00049 #include "vtkSystemIncludes.h" 00050 00051 class vtkGarbageCollector; 00052 class vtkGarbageCollectorToObjectBaseFriendship; 00053 class vtkWeakPointerBase; 00054 class vtkWeakPointerBaseToObjectBaseFriendship; 00055 00056 class VTK_COMMON_EXPORT vtkObjectBase 00057 { 00058 virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; } 00059 public: 00060 00061 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00062 // Avoid windows name mangling. 00063 # define GetClassNameA GetClassName 00064 # define GetClassNameW GetClassName 00065 #endif 00066 00070 const char* GetClassName() const; 00071 00072 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00073 # undef GetClassNameW 00074 # undef GetClassNameA 00075 //BTX 00076 // Define possible mangled names. 00077 const char* GetClassNameA() const; 00078 const char* GetClassNameW() const; 00079 //ETX 00080 #endif 00081 00085 static int IsTypeOf(const char *name); 00086 00090 virtual int IsA(const char *name); 00091 00095 virtual void Delete(); 00096 00102 virtual void FastDelete(); 00103 00105 00107 static vtkObjectBase *New() 00108 {return new vtkObjectBase;} 00110 00111 #ifdef _WIN32 00112 // avoid dll boundary problems 00113 void* operator new( size_t tSize ); 00114 void operator delete( void* p ); 00115 #endif 00116 00119 void Print(ostream& os); 00120 00122 00126 virtual void PrintSelf(ostream& os, vtkIndent indent); 00127 virtual void PrintHeader(ostream& os, vtkIndent indent); 00128 virtual void PrintTrailer(ostream& os, vtkIndent indent); 00130 00132 virtual void Register(vtkObjectBase* o); 00133 00137 virtual void UnRegister(vtkObjectBase* o); 00138 00140 00141 int GetReferenceCount() 00142 {return this->ReferenceCount;} 00144 00146 void SetReferenceCount(int); 00147 00154 void PrintRevisions(ostream& os); 00155 00156 protected: 00157 vtkObjectBase(); 00158 virtual ~vtkObjectBase(); 00159 00160 virtual void CollectRevisions(ostream& os); 00161 00162 int ReferenceCount; 00163 vtkWeakPointerBase **WeakPointers; 00164 00165 // Internal Register/UnRegister implementation that accounts for 00166 // possible garbage collection participation. The second argument 00167 // indicates whether to participate in garbage collection. 00168 virtual void RegisterInternal(vtkObjectBase*, int check); 00169 virtual void UnRegisterInternal(vtkObjectBase*, int check); 00170 00171 // See vtkGarbageCollector.h: 00172 virtual void ReportReferences(vtkGarbageCollector*); 00173 00174 private: 00175 //BTX 00176 friend VTK_COMMON_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o); 00177 friend class vtkGarbageCollectorToObjectBaseFriendship; 00178 friend class vtkWeakPointerBaseToObjectBaseFriendship; 00179 //ETX 00180 protected: 00181 //BTX 00182 vtkObjectBase(const vtkObjectBase&) {} 00183 void operator=(const vtkObjectBase&) {} 00184 //ETX 00185 }; 00186 00187 #endif 00188