VTK
vtkObjectBase.h
Go to the documentation of this file.
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 
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;
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 
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 
223  void operator=(const vtkObjectBase&) {}
224 
225 };
226 
227 #endif
228 
229 // VTK-HeaderTest-Exclude: vtkObjectBase.h
vtkObjectBase::WeakPointers
vtkWeakPointerBase ** WeakPointers
Definition: vtkObjectBase.h:203
vtkObjectBase::PrintRevisions
void PrintRevisions(ostream &)
Legacy.
Definition: vtkObjectBase.h:191
vtkObjectBase::operator=
void operator=(const vtkObjectBase &)
Definition: vtkObjectBase.h:223
vtkObjectBase::New
static vtkObjectBase * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
Definition: vtkObjectBase.h:127
vtkObjectBase::CollectRevisions
virtual void CollectRevisions(ostream &)
Definition: vtkObjectBase.h:199
vtkObjectBase::InitializeObjectBase
void InitializeObjectBase()
vtkObjectBase::GetReferenceCount
int GetReferenceCount()
Return the current reference count of this object.
Definition: vtkObjectBase.h:177
vtkObjectBase::vtkObjectBase
vtkObjectBase(const vtkObjectBase &)
Definition: vtkObjectBase.h:222
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:62
vtkWeakPointerBase
Non-templated superclass for vtkWeakPointer.
Definition: vtkWeakPointerBase.h:33
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkAtomicInt32
vtkAtomic< vtkTypeInt32 > vtkAtomicInt32
Definition: vtkAtomicTypes.h:21
operator<<
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
vtkX3D::name
Definition: vtkX3D.h:219
vtkGarbageCollector
Detect and break reference loops.
Definition: vtkGarbageCollector.h:96
vtkIndent.h
vtkObjectBase::ReferenceCount
vtkAtomicInt32 ReferenceCount
Definition: vtkObjectBase.h:202
vtkAtomicTypes.h
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkSystemIncludes.h