VTK  9.0.3
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 : Object(nullptr) {}
40 
45 
50 
55 
60 
62 
70 
75  {
76  // Inline implementation so smart pointer comparisons can be fully
77  // inlined.
78  return this->Object;
79  }
80 
81 private:
82  friend class vtkObjectBaseToWeakPointerBaseFriendship;
83 
84 protected:
85  // Initialize weak pointer to given object.
87  {
88  };
90 
91  // Pointer to the actual object.
93 };
94 
95 //----------------------------------------------------------------------------
96 #define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op) \
97  inline bool operator op(const vtkWeakPointerBase& l, const vtkWeakPointerBase& r) \
98  { \
99  return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r.GetPointer())); \
100  } \
101  inline bool operator op(vtkObjectBase* l, const vtkWeakPointerBase& r) \
102  { \
103  return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
104  } \
105  inline bool operator op(const vtkWeakPointerBase& l, vtkObjectBase* r) \
106  { \
107  return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
108  }
118 
119 #undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
120 
124 VTKCOMMONCORE_EXPORT ostream& operator<<(ostream& os, const vtkWeakPointerBase& p);
125 
126 #endif
127 // VTK-HeaderTest-Exclude: vtkWeakPointerBase.h
abstract base class for most VTK objects
Definition: vtkObjectBase.h:64
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 & operator=(vtkObjectBase *r)
Assign object to reference.
vtkWeakPointerBase & operator=(vtkWeakPointerBase &&r) noexcept
~vtkWeakPointerBase()
Destroy smart pointer.
vtkWeakPointerBase & operator=(const vtkWeakPointerBase &r)
vtkObjectBase * Object
vtkWeakPointerBase(vtkWeakPointerBase &&r) noexcept
Move r's object into the new weak pointer, setting r to nullptr.
vtkWeakPointerBase(vtkObjectBase *r, const NoReference &)
vtkWeakPointerBase() noexcept
Initialize smart pointer to nullptr.
vtkObjectBase * GetPointer() const
Get the contained pointer.
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkWeakPointerBase &p)
Compare smart pointer values.
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op)