VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkObjectBase.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 =========================================================================*/ 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 00054 class VTK_COMMON_EXPORT vtkObjectBase 00055 { 00056 virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; } 00057 public: 00058 00059 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00060 // Avoid windows name mangling. 00061 # define GetClassNameA GetClassName 00062 # define GetClassNameW GetClassName 00063 #endif 00064 00068 const char* GetClassName() const; 00069 00070 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE 00071 # undef GetClassNameW 00072 # undef GetClassNameA 00073 //BTX 00074 // Define possible mangled names. 00075 const char* GetClassNameA() const; 00076 const char* GetClassNameW() const; 00077 //ETX 00078 #endif 00079 00083 static int IsTypeOf(const char *name); 00084 00088 virtual int IsA(const char *name); 00089 00093 virtual void Delete(); 00094 00100 virtual void FastDelete(); 00101 00103 00105 static vtkObjectBase *New() 00106 {return new vtkObjectBase;} 00108 00109 #ifdef _WIN32 00110 // avoid dll boundary problems 00111 void* operator new( size_t tSize ); 00112 void operator delete( void* p ); 00113 #endif 00114 00117 void Print(ostream& os); 00118 00120 00124 virtual void PrintSelf(ostream& os, vtkIndent indent); 00125 virtual void PrintHeader(ostream& os, vtkIndent indent); 00126 virtual void PrintTrailer(ostream& os, vtkIndent indent); 00128 00130 virtual void Register(vtkObjectBase* o); 00131 00135 virtual void UnRegister(vtkObjectBase* o); 00136 00138 00139 int GetReferenceCount() 00140 {return this->ReferenceCount;} 00142 00144 void SetReferenceCount(int); 00145 00152 void PrintRevisions(ostream& os); 00153 00154 protected: 00155 vtkObjectBase(); 00156 virtual ~vtkObjectBase(); 00157 00158 virtual void CollectRevisions(ostream& os); 00159 00160 int ReferenceCount; // Number of uses of this object by other objects 00161 00162 // Internal Register/UnRegister implementation that accounts for 00163 // possible garbage collection participation. The second argument 00164 // indicates whether to participate in garbage collection. 00165 virtual void RegisterInternal(vtkObjectBase*, int check); 00166 virtual void UnRegisterInternal(vtkObjectBase*, int check); 00167 00168 // See vtkGarbageCollector.h: 00169 virtual void ReportReferences(vtkGarbageCollector*); 00170 private: 00171 //BTX 00172 friend VTK_COMMON_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o); 00173 friend class vtkGarbageCollectorToObjectBaseFriendship; 00174 //ETX 00175 protected: 00176 //BTX 00177 vtkObjectBase(const vtkObjectBase&) {} 00178 void operator=(const vtkObjectBase&) {} 00179 //ETX 00180 }; 00181 00182 #endif 00183