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 "vtkCommonCoreModule.h" // For export macro 00049 #include "vtkAtomicInt.h" 00050 #include "vtkIndent.h" 00051 #include "vtkSystemIncludes.h" 00052 00053 class vtkGarbageCollector; 00054 class vtkGarbageCollectorToObjectBaseFriendship; 00055 class vtkWeakPointerBase; 00056 class vtkWeakPointerBaseToObjectBaseFriendship; 00057 00058 class VTKCOMMONCORE_EXPORT vtkObjectBase 00059 { 00061 00064 virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; } 00065 public: 00067 00068 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00069 // Avoid windows name mangling. 00070 # define GetClassNameA GetClassName 00071 # define GetClassNameW GetClassName 00072 #endif 00073 00075 const char* GetClassName() const; 00076 00077 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00078 # undef GetClassNameW 00079 # undef GetClassNameA 00080 //BTX 00081 // Define possible mangled names. 00082 const char* GetClassNameA() const; 00083 const char* GetClassNameW() const; 00084 //ETX 00085 #endif 00086 00090 static int IsTypeOf(const char *name); 00091 00095 virtual int IsA(const char *name); 00096 00100 virtual void Delete(); 00101 00107 virtual void FastDelete(); 00108 00110 00112 static vtkObjectBase *New() 00113 {return new vtkObjectBase;} 00115 00116 #ifdef _WIN32 00117 // avoid dll boundary problems 00118 void* operator new( size_t tSize ); 00119 void operator delete( void* p ); 00120 #endif 00121 00124 void Print(ostream& os); 00125 00127 00131 virtual void PrintSelf(ostream& os, vtkIndent indent); 00132 virtual void PrintHeader(ostream& os, vtkIndent indent); 00133 virtual void PrintTrailer(ostream& os, vtkIndent indent); 00135 00137 virtual void Register(vtkObjectBase* o); 00138 00142 virtual void UnRegister(vtkObjectBase* o); 00143 00145 00146 int GetReferenceCount() 00147 { 00148 return this->ReferenceCount; 00149 } 00151 00153 void SetReferenceCount(int); 00154 00156 void PrintRevisions(ostream&) {} 00157 00158 protected: 00159 vtkObjectBase(); 00160 virtual ~vtkObjectBase(); 00161 00162 virtual void CollectRevisions(ostream&) {} // Legacy; do not use! 00163 00164 vtkAtomicInt<vtkTypeInt32> ReferenceCount; 00165 vtkWeakPointerBase **WeakPointers; 00166 00167 // Internal Register/UnRegister implementation that accounts for 00168 // possible garbage collection participation. The second argument 00169 // indicates whether to participate in garbage collection. 00170 virtual void RegisterInternal(vtkObjectBase*, int check); 00171 virtual void UnRegisterInternal(vtkObjectBase*, int check); 00172 00173 // See vtkGarbageCollector.h: 00174 virtual void ReportReferences(vtkGarbageCollector*); 00175 00176 private: 00177 //BTX 00178 friend VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o); 00179 friend class vtkGarbageCollectorToObjectBaseFriendship; 00180 friend class vtkWeakPointerBaseToObjectBaseFriendship; 00181 //ETX 00182 protected: 00183 //BTX 00184 vtkObjectBase(const vtkObjectBase&) {} 00185 void operator=(const vtkObjectBase&) {} 00186 //ETX 00187 }; 00188 00189 #endif 00190 00191 // VTK-HeaderTest-Exclude: vtkObjectBase.h