VTK
dox/Common/vtkObjectBase.h
Go to the documentation of this file.
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 =========================================================================*/
00048 #ifndef __vtkObjectBase_h
00049 #define __vtkObjectBase_h
00050 
00051 #include "vtkIndent.h"
00052 #include "vtkSystemIncludes.h"
00053 
00054 class vtkGarbageCollector;
00055 class vtkGarbageCollectorToObjectBaseFriendship;
00056 class vtkWeakPointerBase;
00057 class vtkWeakPointerBaseToObjectBaseFriendship;
00058 
00059 class VTK_COMMON_EXPORT vtkObjectBase
00060 {
00061   virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; }
00062 public:
00063 
00064 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00065   // Avoid windows name mangling.
00066 # define GetClassNameA GetClassName
00067 # define GetClassNameW GetClassName
00068 #endif
00069 
00073   const char* GetClassName() const;
00074 
00075 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
00076 # undef GetClassNameW
00077 # undef GetClassNameA
00078   //BTX
00079   // Define possible mangled names.
00080   const char* GetClassNameA() const;
00081   const char* GetClassNameW() const;
00082   //ETX
00083 #endif
00084 
00088   static int IsTypeOf(const char *name);
00089 
00093   virtual int IsA(const char *name);
00094 
00098   virtual void Delete();
00099 
00105   virtual void FastDelete();
00106 
00108 
00110   static vtkObjectBase *New() 
00111     {return new vtkObjectBase;}
00113   
00114 #ifdef _WIN32
00115   // avoid dll boundary problems
00116   void* operator new( size_t tSize );
00117   void operator delete( void* p );
00118 #endif 
00119   
00122   void Print(ostream& os);
00123 
00125 
00129   virtual void PrintSelf(ostream& os, vtkIndent indent);
00130   virtual void PrintHeader(ostream& os, vtkIndent indent);
00131   virtual void PrintTrailer(ostream& os, vtkIndent indent);
00133 
00135   virtual void Register(vtkObjectBase* o);
00136 
00140   virtual void UnRegister(vtkObjectBase* o);
00141 
00143 
00144   int  GetReferenceCount() 
00145     {return this->ReferenceCount;}
00147 
00149   void SetReferenceCount(int);
00150   
00157   void PrintRevisions(ostream& os);
00158   
00159 protected:
00160   vtkObjectBase(); 
00161   virtual ~vtkObjectBase(); 
00162 
00163   virtual void CollectRevisions(ostream& os);
00164   
00165   int ReferenceCount;
00166   vtkWeakPointerBase **WeakPointers;
00167 
00168   // Internal Register/UnRegister implementation that accounts for
00169   // possible garbage collection participation.  The second argument
00170   // indicates whether to participate in garbage collection.
00171   virtual void RegisterInternal(vtkObjectBase*, int check);
00172   virtual void UnRegisterInternal(vtkObjectBase*, int check);
00173 
00174   // See vtkGarbageCollector.h:
00175   virtual void ReportReferences(vtkGarbageCollector*);
00176 
00177 private:
00178   //BTX
00179   friend VTK_COMMON_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o);
00180   friend class vtkGarbageCollectorToObjectBaseFriendship;
00181   friend class vtkWeakPointerBaseToObjectBaseFriendship;
00182   //ETX
00183 protected:
00184 //BTX
00185   vtkObjectBase(const vtkObjectBase&) {}
00186   void operator=(const vtkObjectBase&) {}
00187 //ETX
00188 };
00189 
00190 #endif
00191