VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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
=========================================================================*/
24
#ifndef __vtkWeakPointerBase_h
25
#define __vtkWeakPointerBase_h
26
27
#include "vtkCommonCoreModule.h"
// For export macro
28
#include "
vtkObjectBase.h
"
29
30
class
vtkObjectBaseToWeakPointerBaseFriendship;
31
32
class
VTKCOMMONCORE_EXPORT
vtkWeakPointerBase
33
{
34
public
:
36
vtkWeakPointerBase
() : Object(0) {};
37
39
vtkWeakPointerBase
(
vtkObjectBase
* r);
40
42
vtkWeakPointerBase
(
const
vtkWeakPointerBase
& r);
43
45
~
vtkWeakPointerBase
();
46
48
50
vtkWeakPointerBase
& operator=(
vtkObjectBase
* r);
51
vtkWeakPointerBase
& operator=(
const
vtkWeakPointerBase
& r);
53
55
56
vtkObjectBase
* GetPointer()
const
57
{
58
// Inline implementation so smart pointer comparisons can be fully
59
// inlined.
60
return
this->Object;
61
}
63
64
private
:
65
friend
class
vtkObjectBaseToWeakPointerBaseFriendship;
66
67
protected
:
68
69
// Initialize weak pointer to given object.
70
class
NoReference
{};
71
vtkWeakPointerBase
(
vtkObjectBase
* r,
const
NoReference
&);
72
73
// Pointer to the actual object.
74
vtkObjectBase
*
Object
;
75
};
76
77
//----------------------------------------------------------------------------
78
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op) \
79
inline bool \
80
operator op (const vtkWeakPointerBase& l, const vtkWeakPointerBase& r) \
81
{ \
82
return (static_cast<void*>(l.GetPointer()) op \
83
static_cast<void*>(r.GetPointer())); \
84
} \
85
inline bool \
86
operator op (vtkObjectBase* l, const vtkWeakPointerBase& r) \
87
{ \
88
return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
89
} \
90
inline bool \
91
operator op (const vtkWeakPointerBase& l, vtkObjectBase* r) \
92
{ \
93
return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
94
}
95
96
97
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(==)
98
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(!=)
99
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(<)
100
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(<=)
101
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(>)
102
VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
(>=)
104
105
#undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
106
108
109
VTKCOMMONCORE_EXPORT ostream&
operator <<
(ostream& os,
110
const
vtkWeakPointerBase
& p);
112
113
#endif
114
// VTK-HeaderTest-Exclude: vtkWeakPointerBase.h
Generated on Thu May 24 2012 22:22:09 for VTK by
1.8.1