vtk-dicom  0.8.14
vtkObjectBase.h
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkObjectBase.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
43 #ifndef vtkObjectBase_h
44 #define vtkObjectBase_h
45 
46 // Semantics around vtkDebugLeaks usage has changed. Now just call
47 // vtkObjectBase::InitializeObjectBase() after creating an object with New().
48 // The object factory methods take care of this automatically.
49 #define VTK_HAS_INITIALIZE_OBJECT_BASE
50 
51 #include "vtkCommonCoreModule.h" // For export macro
52 #include "vtkIndent.h"
53 #include "vtkSystemIncludes.h"
54 #include "vtkAtomicTypes.h" // needs to be included after vtkSystemIncludes.h
55  // for warning suppressions to work on Visual Studio
56 
57 class vtkGarbageCollector;
58 class vtkGarbageCollectorToObjectBaseFriendship;
59 class vtkWeakPointerBase;
60 class vtkWeakPointerBaseToObjectBaseFriendship;
61 
62 class VTKCOMMONCORE_EXPORT vtkObjectBase
63 {
69  virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; }
70 public:
71 
72 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
73  // Avoid windows name mangling.
74 # define GetClassNameA GetClassName
75 # define GetClassNameW GetClassName
76 #endif
77 
81  const char* GetClassName() const;
82 
83 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
84 # undef GetClassNameW
85 # undef GetClassNameA
86 
87  // Define possible mangled names.
88  const char* GetClassNameA() const;
89  const char* GetClassNameW() const;
90 
91 #endif
92 
98  static vtkTypeBool IsTypeOf(const char *name);
99 
105  virtual vtkTypeBool IsA(const char *name);
106 
112  virtual void Delete();
113 
121  virtual void FastDelete();
122 
127  static vtkObjectBase *New()
128  {
129  vtkObjectBase *o = new vtkObjectBase;
130  o->InitializeObjectBase();
131  return o;
132  }
133 
134  // Called by implementations of vtkObject::New(). Centralized location for
135  // vtkDebugLeaks registration:
136  void InitializeObjectBase();
137 
138 #ifdef _WIN32
139  // avoid dll boundary problems
140  void* operator new( size_t tSize );
141  void operator delete( void* p );
142 #endif
143 
148  void Print(ostream& os);
149 
151 
157  virtual void PrintSelf(ostream& os, vtkIndent indent);
158  virtual void PrintHeader(ostream& os, vtkIndent indent);
159  virtual void PrintTrailer(ostream& os, vtkIndent indent);
161 
165  virtual void Register(vtkObjectBase* o);
166 
172  virtual void UnRegister(vtkObjectBase* o);
173 
178  {
179  return this->ReferenceCount;
180  }
181 
185  void SetReferenceCount(int);
186 
190 #ifndef VTK_LEGACY_REMOVE
191  void PrintRevisions(ostream&) {}
192 #endif
193 
194 protected:
195  vtkObjectBase();
196  virtual ~vtkObjectBase();
197 
198 #ifndef VTK_LEGACY_REMOVE
199  virtual void CollectRevisions(ostream&) {} // Legacy; do not use!
200 #endif
201 
202  vtkAtomicInt32 ReferenceCount;
203  vtkWeakPointerBase **WeakPointers;
204 
205  // Internal Register/UnRegister implementation that accounts for
206  // possible garbage collection participation. The second argument
207  // indicates whether to participate in garbage collection.
208  virtual void RegisterInternal(vtkObjectBase*, vtkTypeBool check);
209  virtual void UnRegisterInternal(vtkObjectBase*, vtkTypeBool check);
210 
211  // See vtkGarbageCollector.h:
212  virtual void ReportReferences(vtkGarbageCollector*);
213 
214 private:
215 
216  friend VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o);
217  friend class vtkGarbageCollectorToObjectBaseFriendship;
218  friend class vtkWeakPointerBaseToObjectBaseFriendship;
219 
220 protected:
221 
222  vtkObjectBase(const vtkObjectBase&) {}
223  void operator=(const vtkObjectBase&) {}
224 
225 };
226 
227 #endif
228 
229 // VTK-HeaderTest-Exclude: vtkObjectBase.h
abstract base class for most VTK objects
Definition: vtkObjectBase.h:63
const char * GetClassName() const
virtual void PrintSelf(ostream &os, vtkIndent indent)
static vtkObjectBase * New()
Definition: vtkObjectBase.h:127
void PrintRevisions(ostream &)
Definition: vtkObjectBase.h:191
virtual void UnRegister(vtkObjectBase *o)
virtual vtkTypeBool IsA(const char *name)
void SetReferenceCount(int)
int GetReferenceCount()
Definition: vtkObjectBase.h:177
virtual void Register(vtkObjectBase *o)
virtual void Delete()
static vtkTypeBool IsTypeOf(const char *name)
virtual void FastDelete()
void Print(ostream &os)