VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Common
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
=========================================================================*/
24
#ifndef __vtkWeakPointerBase_h
25
#define __vtkWeakPointerBase_h
26
27
#include "
vtkObjectBase.h
"
28
29
class
vtkObjectBaseToWeakPointerBaseFriendship;
30
31
class
VTK_COMMON_EXPORT
vtkWeakPointerBase
32
{
33
public
:
35
vtkWeakPointerBase
() : Object(0) {};
36
38
vtkWeakPointerBase
(
vtkObjectBase
* r);
39
41
vtkWeakPointerBase
(
const
vtkWeakPointerBase
& r);
42
44
~
vtkWeakPointerBase
();
45
47
49
vtkWeakPointerBase
& operator=(
vtkObjectBase
* r);
50
vtkWeakPointerBase
& operator=(
const
vtkWeakPointerBase
& r);
52
54
55
vtkObjectBase
*
GetPointer
()
const
56
{
57
// Inline implementation so smart pointer comparisons can be fully
58
// inlined.
59
return
this->Object;
60
}
62
63
private
:
64
friend
class
vtkObjectBaseToWeakPointerBaseFriendship;
65
66
protected
:
67
68
// Initialize weak pointer to given object.
69
class
NoReference
{};
70
vtkWeakPointerBase
(
vtkObjectBase
* r,
const
NoReference
&);
71
72
// Pointer to the actual object.
73
vtkObjectBase
*
Object
;
74
};
75
76
//----------------------------------------------------------------------------
77
// Need to use vtkstd_bool type because std: :less requires bool return
78
// type from operators. This example should not be used to justify
79
// using bool elsewhere in VTK.
80
81
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op) \
82
inline vtkstd_bool \
83
operator op (const vtkWeakPointerBase& l, const vtkWeakPointerBase& r) \
84
{ \
85
return (static_cast<void*>(l.GetPointer()) op \
86
static_cast<void*>(r.GetPointer())); \
87
} \
88
inline vtkstd_bool \
89
operator op (vtkObjectBase* l, const vtkWeakPointerBase& r) \
90
{ \
91
return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
92
} \
93
inline vtkstd_bool \
94
operator op (const vtkWeakPointerBase& l, vtkObjectBase* r) \
95
{ \
96
return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
97
}
98
99
100
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(==)
101
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(!=)
102
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(<)
103
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(<=)
104
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(>)
105
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(>=)
107
108
#undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
109
111
112
VTK_COMMON_EXPORT
ostream&
operator <<
(ostream& os,
113
const
vtkWeakPointerBase
& p);
115
116
#endif
Generated on Fri Aug 2 2013 12:19:47 for VTK by
1.8.4