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 =========================================================================*/
49 #ifndef vtkObjectBase_h
50 #define vtkObjectBase_h
51 
52 // Semantics around vtkDebugLeaks usage has changed. Now just call
53 // vtkObjectBase::InitializeObjectBase() after creating an object with New().
54 // The object factory methods take care of this automatically.
55 #define VTK_HAS_INITIALIZE_OBJECT_BASE
56 
57 #include "vtkCommonCoreModule.h" // For export macro
58 #include "vtkIndent.h"
59 #include "vtkSystemIncludes.h"
60 #include "vtkAtomicTypes.h" // needs to be included after vtkSystemIncludes.h
61  // for warning suppressions to work on Visual Studio
62 
64 class vtkGarbageCollectorToObjectBaseFriendship;
65 class vtkWeakPointerBase;
66 class vtkWeakPointerBaseToObjectBaseFriendship;
67 
68 class VTKCOMMONCORE_EXPORT vtkObjectBase
69 {
75  virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; }
76 public:
77 
78 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
79  // Avoid windows name mangling.
80 # define GetClassNameA GetClassName
81 # define GetClassNameW GetClassName
82 #endif
83 
87  const char* GetClassName() const;
88 
89 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
90 # undef GetClassNameW
91 # undef GetClassNameA
92 
93  // Define possible mangled names.
94  const char* GetClassNameA() const;
95  const char* GetClassNameW() const;
96 
97 #endif
98 
104  static vtkTypeBool IsTypeOf(const char *name);
105 
111  virtual vtkTypeBool IsA(const char *name);
112 
118  virtual void Delete();
119 
127  virtual void FastDelete();
128 
133  static vtkObjectBase *New()
134  {
135  vtkObjectBase *o = new vtkObjectBase;
137  return o;
138  }
139 
140  // Called by implementations of vtkObject::New(). Centralized location for
141  // vtkDebugLeaks registration:
142  void InitializeObjectBase();
143 
144 #ifdef _WIN32
145  // avoid dll boundary problems
146  void* operator new( size_t tSize );
147  void operator delete( void* p );
148 #endif
149 
154  void Print(ostream& os);
155 
157 
163  virtual void PrintSelf(ostream& os, vtkIndent indent);
164  virtual void PrintHeader(ostream& os, vtkIndent indent);
165  virtual void PrintTrailer(ostream& os, vtkIndent indent);
167 
171  virtual void Register(vtkObjectBase* o);
172 
178  virtual void UnRegister(vtkObjectBase* o);
179 
184  {
185  return this->ReferenceCount;
186  }
187 
191  void SetReferenceCount(int);
192 
196 #ifndef VTK_LEGACY_REMOVE
197  void PrintRevisions(ostream&) {}
198 #endif
199 
200 protected:
201  vtkObjectBase();
202  virtual ~vtkObjectBase();
203 
204 #ifndef VTK_LEGACY_REMOVE
205  virtual void CollectRevisions(ostream&) {} // Legacy; do not use!
206 #endif
207 
210 
211  // Internal Register/UnRegister implementation that accounts for
212  // possible garbage collection participation. The second argument
213  // indicates whether to participate in garbage collection.
214  virtual void RegisterInternal(vtkObjectBase*, vtkTypeBool check);
215  virtual void UnRegisterInternal(vtkObjectBase*, vtkTypeBool check);
216 
217  // See vtkGarbageCollector.h:
218  virtual void ReportReferences(vtkGarbageCollector*);
219 
220 private:
221 
222  friend VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o);
223  friend class vtkGarbageCollectorToObjectBaseFriendship;
224  friend class vtkWeakPointerBaseToObjectBaseFriendship;
225 
226 protected:
227 
229  void operator=(const vtkObjectBase&) {}
230 
231 };
232 
233 #endif
234 
235 // VTK-HeaderTest-Exclude: vtkObjectBase.h
void InitializeObjectBase()
static vtkObjectBase * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkAtomic< vtkTypeInt32 > vtkAtomicInt32
vtkObjectBase(const vtkObjectBase &)
void PrintRevisions(ostream &)
Legacy.
int GetReferenceCount()
Return the current reference count of this object.
Detect and break reference loops.
vtkAtomicInt32 ReferenceCount
int vtkTypeBool
Definition: vtkABI.h:69
a simple class to control print indentation
Definition: vtkIndent.h:39
Non-templated superclass for vtkWeakPointer.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:68
virtual void CollectRevisions(ostream &)
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
vtkWeakPointerBase ** WeakPointers
void operator=(const vtkObjectBase &)