VTK
dox
Common
Core
vtkWeakPointerBase.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkWeakPointerBase.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
=========================================================================*/
25
#ifndef vtkWeakPointerBase_h
26
#define vtkWeakPointerBase_h
27
28
#include "vtkCommonCoreModule.h"
// For export macro
29
#include "
vtkObjectBase.h
"
30
31
class
vtkObjectBaseToWeakPointerBaseFriendship;
32
33
class
VTKCOMMONCORE_EXPORT
vtkWeakPointerBase
34
{
35
public
:
39
vtkWeakPointerBase
() : Object(nullptr) {}
40
44
vtkWeakPointerBase
(
vtkObjectBase
* r);
45
49
vtkWeakPointerBase
(
const
vtkWeakPointerBase
& r);
50
54
~
vtkWeakPointerBase
();
55
57
61
vtkWeakPointerBase
& operator=(
vtkObjectBase
* r);
62
vtkWeakPointerBase
& operator=(
const
vtkWeakPointerBase
& 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
75
private
:
76
friend
class
vtkObjectBaseToWeakPointerBaseFriendship;
77
78
protected
:
79
80
// Initialize weak pointer to given object.
81
class
NoReference
{};
82
vtkWeakPointerBase
(
vtkObjectBase
* r,
const
NoReference
&);
83
84
// Pointer to the actual object.
85
vtkObjectBase
*
Object
;
86
};
87
88
//----------------------------------------------------------------------------
89
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op) \
90
inline bool \
91
operator op (const vtkWeakPointerBase& l, const vtkWeakPointerBase& r) \
92
{ \
93
return (static_cast<void*>(l.GetPointer()) op \
94
static_cast<void*>(r.GetPointer())); \
95
} \
96
inline bool \
97
operator op (vtkObjectBase* l, const vtkWeakPointerBase& r) \
98
{ \
99
return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
100
} \
101
inline bool \
102
operator op (const vtkWeakPointerBase& l, vtkObjectBase* r) \
103
{ \
104
return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
105
}
106
109
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(==)
110
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(!=)
111
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(<)
112
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(<=)
113
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(>)
114
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(>=)
115
116
#undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
117
121
VTKCOMMONCORE_EXPORT ostream&
operator <<
(ostream& os,
122
const
vtkWeakPointerBase
& p);
123
124
#endif
125
// VTK-HeaderTest-Exclude: vtkWeakPointerBase.h
vtkWeakPointerBase::Object
vtkObjectBase * Object
Definition:
vtkWeakPointerBase.h:85
operator<<
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkWeakPointerBase &p)
Compare smart pointer values.
vtkObjectBase.h
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op)
Definition:
vtkWeakPointerBase.h:89
vtkWeakPointerBase::GetPointer
vtkObjectBase * GetPointer() const
Get the contained pointer.
Definition:
vtkWeakPointerBase.h:68
vtkObjectBase
abstract base class for most VTK objects
Definition:
vtkObjectBase.h:65
vtkWeakPointerBase
Non-templated superclass for vtkWeakPointer.
Definition:
vtkWeakPointerBase.h:33
vtkWeakPointerBase::vtkWeakPointerBase
vtkWeakPointerBase()
Initialize smart pointer to nullptr.
Definition:
vtkWeakPointerBase.h:39
vtkWeakPointerBase::NoReference
Definition:
vtkWeakPointerBase.h:81
Generated by
1.8.16