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 =========================================================================*/
46 #ifndef vtkObjectBase_h
47 #define vtkObjectBase_h
48 
49 // Semantics around vtkDebugLeaks usage has changed. Now just call
50 // vtkObjectBase::InitializeObjectBase() after creating an object with New().
51 // The object factory methods take care of this automatically.
52 #define VTK_HAS_INITIALIZE_OBJECT_BASE
53 
54 #include "vtkCommonCoreModule.h" // For export macro
55 #include "vtkIndent.h"
56 #include "vtkSystemIncludes.h"
57 #include "vtkAtomicTypes.h" // needs to be included after vtkSystemIncludes.h
58  // for warning suppressions to work on Visual Studio
59 
61 class vtkGarbageCollectorToObjectBaseFriendship;
62 class vtkWeakPointerBase;
63 class vtkWeakPointerBaseToObjectBaseFriendship;
64 
65 class VTKCOMMONCORE_EXPORT vtkObjectBase
66 {
72  virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; }
73 public:
74 
75 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
76  // Avoid windows name mangling.
77 # define GetClassNameA GetClassName
78 # define GetClassNameW GetClassName
79 #endif
80 
84  const char* GetClassName() const;
85 
86 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
87 # undef GetClassNameW
88 # undef GetClassNameA
89 
90  // Define possible mangled names.
91  const char* GetClassNameA() const;
92  const char* GetClassNameW() const;
93 
94 #endif
95 
101  static vtkTypeBool IsTypeOf(const char *name);
102 
108  virtual vtkTypeBool IsA(const char *name);
109 
115  virtual void Delete();
116 
124  virtual void FastDelete();
125 
130  static vtkObjectBase *New()
131  {
132  vtkObjectBase *o = new vtkObjectBase;
134  return o;
135  }
136 
137  // Called by implementations of vtkObject::New(). Centralized location for
138  // vtkDebugLeaks registration:
139  void InitializeObjectBase();
140 
141 #ifdef _WIN32
142  // avoid dll boundary problems
143  void* operator new( size_t tSize );
144  void operator delete( void* p );
145 #endif
146 
151  void Print(ostream& os);
152 
154 
160  virtual void PrintSelf(ostream& os, vtkIndent indent);
161  virtual void PrintHeader(ostream& os, vtkIndent indent);
162  virtual void PrintTrailer(ostream& os, vtkIndent indent);
164 
168  virtual void Register(vtkObjectBase* o);
169 
175  virtual void UnRegister(vtkObjectBase* o);
176 
181  {
182  return this->ReferenceCount;
183  }
184 
188  void SetReferenceCount(int);
189 
193 #ifndef VTK_LEGACY_REMOVE
194  void PrintRevisions(ostream&) {}
195 #endif
196 
197 protected:
198  vtkObjectBase();
199  virtual ~vtkObjectBase();
200 
201 #ifndef VTK_LEGACY_REMOVE
202  virtual void CollectRevisions(ostream&) {} // Legacy; do not use!
203 #endif
204 
207 
208  // Internal Register/UnRegister implementation that accounts for
209  // possible garbage collection participation. The second argument
210  // indicates whether to participate in garbage collection.
211  virtual void RegisterInternal(vtkObjectBase*, vtkTypeBool check);
212  virtual void UnRegisterInternal(vtkObjectBase*, vtkTypeBool check);
213 
214  // See vtkGarbageCollector.h:
215  virtual void ReportReferences(vtkGarbageCollector*);
216 
217 private:
218 
219  friend VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o);
220  friend class vtkGarbageCollectorToObjectBaseFriendship;
221  friend class vtkWeakPointerBaseToObjectBaseFriendship;
222 
223 protected:
224 
226  void operator=(const vtkObjectBase&) {}
227 
228 };
229 
230 #endif
231 
232 // VTK-HeaderTest-Exclude: vtkObjectBase.h
vtkObjectBase::WeakPointers
vtkWeakPointerBase ** WeakPointers
Definition: vtkObjectBase.h:206
vtkObjectBase::PrintRevisions
void PrintRevisions(ostream &)
Legacy.
Definition: vtkObjectBase.h:194
vtkObjectBase::operator=
void operator=(const vtkObjectBase &)
Definition: vtkObjectBase.h:226
vtkObjectBase::New
static vtkObjectBase * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
Definition: vtkObjectBase.h:130
vtkObjectBase::CollectRevisions
virtual void CollectRevisions(ostream &)
Definition: vtkObjectBase.h:202
vtkObjectBase::InitializeObjectBase
void InitializeObjectBase()
vtx::helper::Print
void Print(const std::vector< T > &input, const std::string &name)
Print a vector with an associated name.
vtkObjectBase::GetReferenceCount
int GetReferenceCount()
Return the current reference count of this object.
Definition: vtkObjectBase.h:180
vtkObjectBase::vtkObjectBase
vtkObjectBase(const vtkObjectBase &)
Definition: vtkObjectBase.h:225
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
vtkWeakPointerBase
Non-templated superclass for vtkWeakPointer.
Definition: vtkWeakPointerBase.h:33
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
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:99
vtkIndent.h
vtkObjectBase::ReferenceCount
vtkAtomicInt32 ReferenceCount
Definition: vtkObjectBase.h:205
vtkAtomicTypes.h
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkSystemIncludes.h