VTK
9.0.1
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
() noexcept;
39
43
vtkSmartPointerBase
(
vtkObjectBase
* r);
44
49
vtkSmartPointerBase
(
const
vtkSmartPointerBase
& r);
50
54
vtkSmartPointerBase
(
vtkSmartPointerBase
&& r) noexcept : Object(r.
Object
) { r.
Object
=
nullptr
; }
55
59
~
vtkSmartPointerBase
();
60
62
66
vtkSmartPointerBase
& operator=(
vtkObjectBase
* r);
67
vtkSmartPointerBase
& operator=(
const
vtkSmartPointerBase
& r);
69
73
vtkObjectBase
*
GetPointer
() const noexcept
74
{
75
// Inline implementation so smart pointer comparisons can be fully
76
// inlined.
77
return
this->Object;
78
}
79
83
void
Report(
vtkGarbageCollector
* collector,
const
char
* desc);
84
85
protected
:
86
// Initialize smart pointer to given object, but do not increment
87
// reference count. The destructor will still decrement the count.
88
// This effectively makes it an auto-ptr.
89
class
NoReference
90
{
91
};
92
vtkSmartPointerBase
(
vtkObjectBase
* r,
const
NoReference
&);
93
94
// Pointer to the actual object.
95
vtkObjectBase
*
Object
;
96
97
private
:
98
// Internal utility methods.
99
void
Swap(
vtkSmartPointerBase
& r) noexcept;
100
void
Register();
101
};
102
103
//----------------------------------------------------------------------------
104
#define VTK_SMART_POINTER_BASE_DEFINE_OPERATOR(op) \
105
inline bool operator op(const vtkSmartPointerBase& l, const vtkSmartPointerBase& r) \
106
{ \
107
return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r.GetPointer())); \
108
} \
109
inline bool operator op(vtkObjectBase* l, const vtkSmartPointerBase& r) \
110
{ \
111
return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
112
} \
113
inline bool operator op(const vtkSmartPointerBase& l, vtkObjectBase* r) \
114
{ \
115
return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
116
}
117
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
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(>)
125
VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
(>=)
126
127
#undef VTK_SMART_POINTER_BASE_DEFINE_OPERATOR
128
132
VTKCOMMONCORE_EXPORT ostream&
operator<<
(ostream& os,
const
vtkSmartPointerBase
& p);
133
134
#endif
135
// VTK-HeaderTest-Exclude: vtkSmartPointerBase.h
vtkObjectBase.h
vtkSmartPointerBase
Non-templated superclass for vtkSmartPointer.
Definition:
vtkSmartPointerBase.h:32
vtkSmartPointerBase::GetPointer
vtkObjectBase * GetPointer() const noexcept
Get the contained pointer.
Definition:
vtkSmartPointerBase.h:73
vtkObjectBase
abstract base class for most VTK objects
Definition:
vtkObjectBase.h:63
vtkSmartPointerBase::vtkSmartPointerBase
vtkSmartPointerBase(vtkSmartPointerBase &&r) noexcept
Move the pointee from r into this and reset @ r.
Definition:
vtkSmartPointerBase.h:54
vtkGarbageCollector
Detect and break reference loops.
Definition:
vtkGarbageCollector.h:94
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:104
vtkSmartPointerBase::Object
vtkObjectBase * Object
Definition:
vtkSmartPointerBase.h:95
vtkSmartPointerBase::NoReference
Definition:
vtkSmartPointerBase.h:89
Generated on Thu Jun 24 2021 15:17:26 for VTK by
1.8.17