VTK
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
31class vtkObjectBaseToWeakPointerBaseFriendship;
32
33class VTKCOMMONCORE_EXPORT vtkWeakPointerBase
34{
35public:
39 vtkWeakPointerBase() : Object(0) {}
40
45
50
55
57
64
69 {
70 // Inline implementation so smart pointer comparisons can be fully
71 // inlined.
72 return this->Object;
73 }
74
75private:
76 friend class vtkObjectBaseToWeakPointerBaseFriendship;
77
78protected:
79
80 // Initialize weak pointer to given object.
81 class NoReference {};
83
84 // Pointer to the actual 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 }
115
116#undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
117
121VTKCOMMONCORE_EXPORT ostream& operator << (ostream& os,
122 const vtkWeakPointerBase& p);
123
124#endif
125// VTK-HeaderTest-Exclude: vtkWeakPointerBase.h
abstract base class for most VTK objects
Definition: vtkObjectBase.h:66
Non-templated superclass for vtkWeakPointer.
vtkWeakPointerBase(const vtkWeakPointerBase &r)
Initialize weak pointer .
vtkWeakPointerBase(vtkObjectBase *r)
Initialize smart pointer to given object.
vtkWeakPointerBase()
Initialize smart pointer to NULL.
~vtkWeakPointerBase()
Destroy smart pointer.
vtkObjectBase * GetPointer() const
Get the contained pointer.
vtkObjectBase * Object
vtkWeakPointerBase & operator=(vtkObjectBase *r)
Assign object to reference.
vtkWeakPointerBase(vtkObjectBase *r, const NoReference &)
vtkWeakPointerBase & operator=(const vtkWeakPointerBase &r)
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkWeakPointerBase &p)
Compare smart pointer values.
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op)