VTK  9.0.20210508
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() noexcept
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 
84 private:
85  friend class vtkObjectBaseToWeakPointerBaseFriendship;
86 
87 protected:
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  }
112 
121 
122 #undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
123 
127 VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, const vtkWeakPointerBase& p);
128 
129 #endif
130 // VTK-HeaderTest-Exclude: vtkWeakPointerBase.h
vtkWeakPointerBase::Object
vtkObjectBase * Object
Definition: vtkWeakPointerBase.h:95
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:99
vtkWeakPointerBase::GetPointer
vtkObjectBase * GetPointer() const
Get the contained pointer.
Definition: vtkWeakPointerBase.h:77
vtkWeakPointerBase::operator=
vtkWeakPointerBase & operator=(const vtkWeakPointerBase &r)
Assign object to reference.
vtkWeakPointerBase::vtkWeakPointerBase
vtkWeakPointerBase(vtkObjectBase *r)
Initialize smart pointer to given object.
vtkWeakPointerBase::vtkWeakPointerBase
vtkWeakPointerBase(vtkObjectBase *r, const NoReference &)
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:70
vtkWeakPointerBase
Non-templated superclass for vtkWeakPointer.
Definition: vtkWeakPointerBase.h:34
vtkWeakPointerBase::vtkWeakPointerBase
vtkWeakPointerBase(vtkWeakPointerBase &&r) noexcept
Move r's object into the new weak pointer, setting r to nullptr.
vtkWeakPointerBase::vtkWeakPointerBase
vtkWeakPointerBase(const vtkWeakPointerBase &r)
Copy r's data object into the new weak pointer.
vtkWeakPointerBase::operator=
vtkWeakPointerBase & operator=(vtkWeakPointerBase &&r) noexcept
Assign object to reference.
vtkWeakPointerBase::NoReference
Definition: vtkWeakPointerBase.h:90
vtkWeakPointerBase::~vtkWeakPointerBase
~vtkWeakPointerBase()
Destroy smart pointer.
vtkWeakPointerBase::vtkWeakPointerBase
vtkWeakPointerBase() noexcept
Initialize smart pointer to nullptr.
Definition: vtkWeakPointerBase.h:39
vtkWeakPointerBase::operator=
vtkWeakPointerBase & operator=(vtkObjectBase *r)
Assign object to reference.