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
61class vtkGarbageCollectorToObjectBaseFriendship;
63class vtkWeakPointerBaseToObjectBaseFriendship;
64
65class VTKCOMMONCORE_EXPORT vtkObjectBase
66{
72 virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; }
73public:
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
131 {
134 return o;
135 }
136
137 // Called by implementations of vtkObject::New(). Centralized location for
138 // vtkDebugLeaks registration:
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
189
193#ifndef VTK_LEGACY_REMOVE
194 void PrintRevisions(ostream&) {}
195#endif
196
197protected:
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.
213
214 // See vtkGarbageCollector.h:
216
217private:
218
219 friend VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o);
220 friend class vtkGarbageCollectorToObjectBaseFriendship;
221 friend class vtkWeakPointerBaseToObjectBaseFriendship;
222
223protected:
224
226 void operator=(const vtkObjectBase&) {}
227
228};
229
230#endif
231
232// VTK-HeaderTest-Exclude: vtkObjectBase.h
Detect and break reference loops.
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObjectBase.h:66
virtual void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
void PrintRevisions(ostream &)
Legacy.
virtual void PrintTrailer(ostream &os, vtkIndent indent)
void operator=(const vtkObjectBase &)
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
virtual void CollectRevisions(ostream &)
virtual void UnRegisterInternal(vtkObjectBase *, vtkTypeBool check)
virtual vtkTypeBool IsA(const char *name)
Return 1 if this class is the same type of (or a subclass of) the named class.
static vtkObjectBase * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
virtual void RegisterInternal(vtkObjectBase *, vtkTypeBool check)
virtual void PrintHeader(ostream &os, vtkIndent indent)
void SetReferenceCount(int)
Sets the reference count.
int GetReferenceCount()
Return the current reference count of this object.
void InitializeObjectBase()
vtkAtomicInt32 ReferenceCount
virtual void Register(vtkObjectBase *o)
Increase the reference count (mark as used by another object).
vtkWeakPointerBase ** WeakPointers
friend VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, vtkObjectBase &o)
virtual void Delete()
Delete a VTK object.
virtual ~vtkObjectBase()
virtual void ReportReferences(vtkGarbageCollector *)
static vtkTypeBool IsTypeOf(const char *name)
Return 1 if this class type is the same type of (or a subclass of) the named class.
virtual void FastDelete()
Delete a reference to this object.
void Print(ostream &os)
Print an object to an ostream.
const char * GetClassName() const
Return the class name as a string.
vtkObjectBase(const vtkObjectBase &)
Non-templated superclass for vtkWeakPointer.
@ name
Definition: vtkX3D.h:219
int vtkTypeBool
Definition: vtkABI.h:69
vtkAtomic< vtkTypeInt32 > vtkAtomicInt32