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 =========================================================================*/
45 #ifndef vtkObjectBase_h
46 #define vtkObjectBase_h
47 
48 #include "vtkCommonCoreModule.h" // For export macro
49 #include "vtkIndent.h"
50 #include "vtkSystemIncludes.h"
51 #include "vtkAtomicTypes.h" // needs to be included after vtkSystemIncludes.h
52  // for warning suppressions to work on Visual Studio
53 
55 class vtkGarbageCollectorToObjectBaseFriendship;
56 class vtkWeakPointerBase;
57 class vtkWeakPointerBaseToObjectBaseFriendship;
58 
60 {
62 
65  virtual const char* GetClassNameInternal() const { return "vtkObjectBase"; }
66 public:
68 
69 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
70  // Avoid windows name mangling.
71 # define GetClassNameA GetClassName
72 # define GetClassNameW GetClassName
73 #endif
74 
76  const char* GetClassName() const;
77 
78 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE
79 # undef GetClassNameW
80 # undef GetClassNameA
81  //BTX
82  // Define possible mangled names.
83  const char* GetClassNameA() const;
84  const char* GetClassNameW() const;
85  //ETX
86 #endif
87 
91  static int IsTypeOf(const char *name);
92 
96  virtual int IsA(const char *name);
97 
101  virtual void Delete();
102 
108  virtual void FastDelete();
109 
111 
113  static vtkObjectBase *New()
114  {return new vtkObjectBase;}
116 
117 #ifdef _WIN32
118  // avoid dll boundary problems
119  void* operator new( size_t tSize );
120  void operator delete( void* p );
121 #endif
122 
125  void Print(ostream& os);
126 
128 
132  virtual void PrintSelf(ostream& os, vtkIndent indent);
133  virtual void PrintHeader(ostream& os, vtkIndent indent);
134  virtual void PrintTrailer(ostream& os, vtkIndent indent);
136 
138  virtual void Register(vtkObjectBase* o);
139 
143  virtual void UnRegister(vtkObjectBase* o);
144 
146 
148  {
149  return this->ReferenceCount;
150  }
152 
154  void SetReferenceCount(int);
155 
157  void PrintRevisions(ostream&) {}
158 
159 protected:
160  vtkObjectBase();
161  virtual ~vtkObjectBase();
162 
163  virtual void CollectRevisions(ostream&) {} // Legacy; do not use!
164 
167 
168  // Internal Register/UnRegister implementation that accounts for
169  // possible garbage collection participation. The second argument
170  // indicates whether to participate in garbage collection.
171  virtual void RegisterInternal(vtkObjectBase*, int check);
172  virtual void UnRegisterInternal(vtkObjectBase*, int check);
173 
174  // See vtkGarbageCollector.h:
175  virtual void ReportReferences(vtkGarbageCollector*);
176 
177 private:
178  //BTX
179  friend VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, vtkObjectBase& o);
180  friend class vtkGarbageCollectorToObjectBaseFriendship;
181  friend class vtkWeakPointerBaseToObjectBaseFriendship;
182  //ETX
183 protected:
184 //BTX
186  void operator=(const vtkObjectBase&) {}
187 //ETX
188 };
189 
190 #endif
191 
192 // VTK-HeaderTest-Exclude: vtkObjectBase.h
static vtkObjectBase * New()
#define VTKCOMMONCORE_EXPORT
vtkObjectBase(const vtkObjectBase &)
void PrintRevisions(ostream &)
int GetReferenceCount()
Detect and break reference loops.
vtkAtomicInt32 ReferenceCount
a simple class to control print indentation
Definition: vtkIndent.h:38
Non-templated superclass for vtkWeakPointer.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
virtual void CollectRevisions(ostream &)
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
vtkWeakPointerBase ** WeakPointers
void operator=(const vtkObjectBase &)