VTK  9.1.0
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:
40 : Object(nullptr)
41 {
42 }
43
48
53
58
63
65
73
78 {
79 // Inline implementation so smart pointer comparisons can be fully
80 // inlined.
81 return this->Object;
82 }
83
84private:
85 friend class vtkObjectBaseToWeakPointerBaseFriendship;
86
87protected:
88 // Initialize weak pointer to given object.
90 {
91 };
93
94 // Pointer to the actual object.
96};
97
98//----------------------------------------------------------------------------
99#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op) \
100 inline bool operator op(const vtkWeakPointerBase& l, const vtkWeakPointerBase& r) \
101 { \
102 return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r.GetPointer())); \
103 } \
104 inline bool operator op(vtkObjectBase* l, const vtkWeakPointerBase& r) \
105 { \
106 return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
107 } \
108 inline bool operator op(const vtkWeakPointerBase& l, vtkObjectBase* r) \
109 { \
110 return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
111 }
121
122#undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
123
127VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, const vtkWeakPointerBase& p);
128
129#endif
130// VTK-HeaderTest-Exclude: vtkWeakPointerBase.h
abstract base class for most VTK objects
Definition: vtkObjectBase.h:70
Non-templated superclass for vtkWeakPointer.
vtkWeakPointerBase(const vtkWeakPointerBase &r)
Copy r's data object into the new weak pointer.
vtkWeakPointerBase(vtkObjectBase *r)
Initialize smart pointer to given object.
~vtkWeakPointerBase()
Destroy smart pointer.
vtkObjectBase * GetPointer() const
Get the contained pointer.
vtkObjectBase * Object
vtkWeakPointerBase(vtkWeakPointerBase &&r) noexcept
Move r's object into the new weak pointer, setting r to nullptr.
vtkWeakPointerBase & operator=(vtkObjectBase *r)
Assign object to reference.
vtkWeakPointerBase(vtkObjectBase *r, const NoReference &)
vtkWeakPointerBase & operator=(const vtkWeakPointerBase &r)
Assign object to reference.
vtkWeakPointerBase & operator=(vtkWeakPointerBase &&r) noexcept
Assign object to reference.
vtkWeakPointerBase() noexcept
Initialize smart pointer to nullptr.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkWeakPointerBase &p)
Compare smart pointer values.
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op)