VTK
Public Member Functions | List of all members
vtkWeakPointer< T > Class Template Reference

a weak reference to a vtkObject. More...

#include <vtkMeta.h>

Inheritance diagram for vtkWeakPointer< T >:
[legend]
Collaboration diagram for vtkWeakPointer< T >:
[legend]

Public Member Functions

 vtkWeakPointer () noexcept
 Initialize smart pointer to nullptr. More...
 
- Public Member Functions inherited from vtkWeakPointerBase
 vtkWeakPointerBase () noexcept
 Initialize smart pointer to nullptr. More...
 
 vtkWeakPointerBase (vtkObjectBase *r)
 Initialize smart pointer to given object. More...
 
 vtkWeakPointerBase (const vtkWeakPointerBase &r)
 Copy r's data object into the new weak pointer. More...
 
 vtkWeakPointerBase (vtkWeakPointerBase &&r) noexcept
 Move r's object into the new weak pointer, setting r to nullptr. More...
 
 ~vtkWeakPointerBase ()
 Destroy smart pointer. More...
 
vtkWeakPointerBaseoperator= (vtkObjectBase *r)
 Assign object to reference. More...
 
vtkWeakPointerBaseoperator= (const vtkWeakPointerBase &r)
 
vtkWeakPointerBaseoperator= (vtkWeakPointerBase &&r) noexcept
 
vtkObjectBaseGetPointer () const
 Get the contained pointer. More...
 
 vtkWeakPointer (const vtkWeakPointer &r)
 Initialize smart pointer with the given smart pointer. More...
 
template<class U >
 vtkWeakPointer (const vtkWeakPointer< U > &r)
 Initialize smart pointer with the given smart pointer. More...
 
 vtkWeakPointer (vtkWeakPointer &&r) noexcept
 Move r's object into the new weak pointer, setting r to nullptr. More...
 
template<class U >
 vtkWeakPointer (vtkWeakPointer< U > &&r) noexcept
 Initialize smart pointer with the given smart pointer. More...
 
 vtkWeakPointer (T *r)
 Initialize smart pointer to given object. More...
 
template<typename U >
 vtkWeakPointer (const vtkNew< U > &r)
 Initialize smart pointer with the given smart pointer. More...
 
vtkWeakPointeroperator= (const vtkWeakPointer &r)
 Assign object to reference. More...
 
template<class U >
vtkWeakPointeroperator= (const vtkWeakPointer< U > &r)
 Initialize smart pointer with the given smart pointer. More...
 
vtkWeakPointeroperator= (vtkWeakPointer &&r) noexcept
 Move r's object into this weak pointer, setting r to nullptr. More...
 
template<class U >
vtkWeakPointeroperator= (vtkWeakPointer< U > &&r) noexcept
 Initialize smart pointer with the given smart pointer. More...
 
vtkWeakPointeroperator= (T *r)
 Assign object to reference. More...
 
template<typename U >
vtkWeakPointeroperator= (const vtkNew< U > &r)
 Initialize smart pointer with the given smart pointer. More...
 
T * GetPointer () const noexcept
 Get the contained pointer. More...
 
T * Get () const noexcept
 Initialize smart pointer with the given smart pointer. More...
 
 operator T* () const noexcept
 Initialize smart pointer with the given smart pointer. More...
 
T & operator* () const noexcept
 Dereference the pointer and return a reference to the contained object. More...
 
T * operator-> () const noexcept
 Provides normal pointer target member access using operator ->. More...
 
 vtkWeakPointer (T *r, const NoReference &n)
 Initialize smart pointer with the given smart pointer. More...
 

Additional Inherited Members

- Protected Member Functions inherited from vtkWeakPointerBase
 vtkWeakPointerBase (vtkObjectBase *r, const NoReference &)
 
- Protected Attributes inherited from vtkWeakPointerBase
vtkObjectBaseObject
 

Detailed Description

template<class T>
class vtkWeakPointer< T >

a weak reference to a vtkObject.

A weak reference to a vtkObject, which means that assigning a vtkObject to the vtkWeakPointer does not affect the reference count of the vtkObject. However, when the vtkObject is destroyed, the vtkWeakPointer gets initialized to nullptr, thus avoiding any dangling references.

vtkWeakPointer<vtkTable> weakTable = table;

Some time later the table may be deleted, but if it is tested for null then the weak pointer will not leave a dangling pointer.

table->Delete();
if (weakTable)
{
// Never executed as the weak table pointer will be null here
cout << "Number of columns in table: " << weakTable->GetNumberOfColumns()
<< endl;
}

Definition at line 34 of file vtkMeta.h.

Constructor & Destructor Documentation

◆ vtkWeakPointer() [1/8]

template<class T>
vtkWeakPointer< T >::vtkWeakPointer ( )
inlinenoexcept

Initialize smart pointer to nullptr.

Definition at line 82 of file vtkWeakPointer.h.

◆ vtkWeakPointer() [2/8]

template<class T>
vtkWeakPointer< T >::vtkWeakPointer ( const vtkWeakPointer< T > &  r)
inline

Initialize smart pointer with the given smart pointer.

Definition at line 88 of file vtkWeakPointer.h.

◆ vtkWeakPointer() [3/8]

template<class T>
template<class U >
vtkWeakPointer< T >::vtkWeakPointer ( const vtkWeakPointer< U > &  r)
inline

Initialize smart pointer with the given smart pointer.

Definition at line 94 of file vtkWeakPointer.h.

◆ vtkWeakPointer() [4/8]

template<class T>
vtkWeakPointer< T >::vtkWeakPointer ( vtkWeakPointer< T > &&  r)
inlinenoexcept

Move r's object into the new weak pointer, setting r to nullptr.

Definition at line 105 of file vtkWeakPointer.h.

◆ vtkWeakPointer() [5/8]

template<class T>
template<class U >
vtkWeakPointer< T >::vtkWeakPointer ( vtkWeakPointer< U > &&  r)
inlinenoexcept

Initialize smart pointer with the given smart pointer.

Definition at line 108 of file vtkWeakPointer.h.

◆ vtkWeakPointer() [6/8]

template<class T>
vtkWeakPointer< T >::vtkWeakPointer ( T *  r)
inline

Initialize smart pointer to given object.

Definition at line 118 of file vtkWeakPointer.h.

◆ vtkWeakPointer() [7/8]

template<class T>
template<typename U >
vtkWeakPointer< T >::vtkWeakPointer ( const vtkNew< U > &  r)
inline

Initialize smart pointer with the given smart pointer.

Definition at line 125 of file vtkWeakPointer.h.

◆ vtkWeakPointer() [8/8]

template<class T>
vtkWeakPointer< T >::vtkWeakPointer ( T *  r,
const NoReference n 
)
inlineprotected

Initialize smart pointer with the given smart pointer.

Definition at line 236 of file vtkWeakPointer.h.

Member Function Documentation

◆ operator=() [1/6]

template<class T>
vtkWeakPointer& vtkWeakPointer< T >::operator= ( const vtkWeakPointer< T > &  r)
inline

Assign object to reference.

Definition at line 136 of file vtkWeakPointer.h.

◆ operator=() [2/6]

template<class T>
template<class U >
vtkWeakPointer& vtkWeakPointer< T >::operator= ( const vtkWeakPointer< U > &  r)
inline

Initialize smart pointer with the given smart pointer.

Definition at line 143 of file vtkWeakPointer.h.

◆ operator=() [3/6]

template<class T>
vtkWeakPointer& vtkWeakPointer< T >::operator= ( vtkWeakPointer< T > &&  r)
inlinenoexcept

Move r's object into this weak pointer, setting r to nullptr.

Definition at line 156 of file vtkWeakPointer.h.

◆ operator=() [4/6]

template<class T>
template<class U >
vtkWeakPointer& vtkWeakPointer< T >::operator= ( vtkWeakPointer< U > &&  r)
inlinenoexcept

Initialize smart pointer with the given smart pointer.

Definition at line 163 of file vtkWeakPointer.h.

◆ operator=() [5/6]

template<class T>
vtkWeakPointer& vtkWeakPointer< T >::operator= ( T *  r)
inline

Assign object to reference.

Definition at line 176 of file vtkWeakPointer.h.

◆ operator=() [6/6]

template<class T>
template<typename U >
vtkWeakPointer& vtkWeakPointer< T >::operator= ( const vtkNew< U > &  r)
inline

Initialize smart pointer with the given smart pointer.

Definition at line 184 of file vtkWeakPointer.h.

◆ GetPointer()

template<class T>
T* vtkWeakPointer< T >::GetPointer ( ) const
inlinenoexcept

Get the contained pointer.

Definition at line 197 of file vtkWeakPointer.h.

◆ Get()

template<class T>
T* vtkWeakPointer< T >::Get ( ) const
inlinenoexcept

Initialize smart pointer with the given smart pointer.

Definition at line 198 of file vtkWeakPointer.h.

◆ operator T*()

template<class T>
vtkWeakPointer< T >::operator T* ( ) const
inlinenoexcept

Initialize smart pointer with the given smart pointer.

Definition at line 199 of file vtkWeakPointer.h.

◆ operator*()

template<class T>
T& vtkWeakPointer< T >::operator* ( ) const
inlinenoexcept

Dereference the pointer and return a reference to the contained object.

Definition at line 205 of file vtkWeakPointer.h.

◆ operator->()

template<class T>
T* vtkWeakPointer< T >::operator-> ( ) const
inlinenoexcept

Provides normal pointer target member access using operator ->.

Definition at line 210 of file vtkWeakPointer.h.


The documentation for this class was generated from the following files:
vtkTable
A table, which contains similar-typed columns of data.
Definition: vtkTable.h:62
vtkObjectBase::Delete
virtual void Delete()
Delete a VTK object.
vtkTable::New
static vtkTable * New()
vtkTable::GetNumberOfColumns
vtkIdType GetNumberOfColumns()
Get the number of columns in the table.
vtkWeakPointer
a weak reference to a vtkObject.
Definition: vtkMeta.h:34