VTK
dox
Common
Core
vtkSmartPointerBase.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkSmartPointerBase.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
=========================================================================*/
26
#ifndef vtkSmartPointerBase_h
27
#define vtkSmartPointerBase_h
28
29
#include "vtkCommonCoreModule.h"
// For export macro
30
#include "
vtkObjectBase.h
"
31
32
class
VTKCOMMONCORE_EXPORT
vtkSmartPointerBase
33
{
34
public
:
38
vtkSmartPointerBase
();
39
43
vtkSmartPointerBase
(
vtkObjectBase
* r);
44
49
vtkSmartPointerBase
(
const
vtkSmartPointerBase
& r);
50
54
~
vtkSmartPointerBase
();
55
57
61
vtkSmartPointerBase
& operator=(
vtkObjectBase
* r);
62
vtkSmartPointerBase
& operator=(
const
vtkSmartPointerBase
& r);
64
68
vtkObjectBase
*
GetPointer
()
const
69
{
70
// Inline implementation so smart pointer comparisons can be fully
71
// inlined.
72
return
this->Object;
73
}
74
78
void
Report(
vtkGarbageCollector
* collector,
const
char
* desc);
79
80
protected
:
81
82
// Initialize smart pointer to given object, but do not increment
83
// reference count. The destructor will still decrement the count.
84
// This effectively makes it an auto-ptr.
85
class
NoReference
{};
86
vtkSmartPointerBase
(
vtkObjectBase
* r,
const
NoReference
&);
87
88
// Pointer to the actual object.
89
vtkObjectBase
*
Object
;
90
91
private
:
92
// Internal utility methods.
93
void
Swap(
vtkSmartPointerBase
& r);
94
void
Register();
95
};
96
97
//----------------------------------------------------------------------------
98
#define VTK_SMART_POINTER_BASE_DEFINE_OPERATOR(op) \
99
inline bool \
100
operator op (const vtkSmartPointerBase& l, const vtkSmartPointerBase& r) \
101
{ \
102
return (static_cast<void*>(l.GetPointer()) op \
103
static_cast<void*>(r.GetPointer())); \
104
} \
105
inline bool \
106
operator op (vtkObjectBase* l, const vtkSmartPointerBase& r) \
107
{ \
108
return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
109
} \
110
inline bool \
111
operator op (const vtkSmartPointerBase& l, vtkObjectBase* r) \
112
{ \
113
return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
114
}
115
118
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(==)
119
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(!=)
120
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(<)
121
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(<=)
122
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(>)
123
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(>=)
124
125
#undef VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
126
130
VTKCOMMONCORE_EXPORT ostream&
operator <<
(ostream& os,
131
const
vtkSmartPointerBase
& p);
132
133
#endif
134
// VTK-HeaderTest-Exclude: vtkSmartPointerBase.h
vtkObjectBase.h
vtkSmartPointerBase::GetPointer
vtkObjectBase * GetPointer() const
Get the contained pointer.
Definition:
vtkSmartPointerBase.h:68
vtkSmartPointerBase
Non-templated superclass for vtkSmartPointer.
Definition:
vtkSmartPointerBase.h:32
vtkObjectBase
abstract base class for most VTK objects
Definition:
vtkObjectBase.h:65
vtkGarbageCollector
Detect and break reference loops.
Definition:
vtkGarbageCollector.h:99
operator<<
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkSmartPointerBase &p)
Compare smart pointer values.
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
#define VTK_SMART_POINTER_BASE_DEFINE_OPERATOR(op)
Definition:
vtkSmartPointerBase.h:98
vtkSmartPointerBase::Object
vtkObjectBase * Object
Definition:
vtkSmartPointerBase.h:89
vtkSmartPointerBase::NoReference
Definition:
vtkSmartPointerBase.h:85
Generated by
1.8.16