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...
 
 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)
 Assign object to reference. 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
 Move r's object into this weak pointer, setting r to nullptr. More...
 
vtkWeakPointeroperator= (T *r)
 Assign object to reference. More...
 
template<typename U >
vtkWeakPointeroperator= (const vtkNew< U > &r)
 Assign object to reference. 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...
 
vtkObjectBaseGetPointer () const
 Get the contained pointer. More...
 
vtkWeakPointerBaseoperator= (vtkObjectBase *r)
 Assign object to reference. More...
 
vtkWeakPointerBaseoperator= (const vtkWeakPointerBase &r)
 Assign object to reference. More...
 
vtkWeakPointerBaseoperator= (vtkWeakPointerBase &&r) noexcept
 Assign object to reference. More...
 
T * GetPointer () const noexcept
 Get the contained pointer. More...
 
T * Get () const noexcept
 Get the contained pointer. More...
 
 operator T * () const noexcept
 Get the contained 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)
 Get the contained 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;
}
Tests:
vtkWeakPointer (Tests)

Definition at line 31 of file vtkMeta.h.

Constructor & Destructor Documentation

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

Initialize smart pointer to nullptr.

Definition at line 85 of file vtkWeakPointer.h.

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

Initialize smart pointer with the given smart pointer.

Definition at line 94 of file vtkWeakPointer.h.

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 100 of file vtkWeakPointer.h.

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 111 of file vtkWeakPointer.h.

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

Initialize smart pointer with the given smart pointer.

Definition at line 117 of file vtkWeakPointer.h.

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

Initialize smart pointer to given object.

Definition at line 128 of file vtkWeakPointer.h.

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 135 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 260 of file vtkWeakPointer.h.

Member Function Documentation

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

Assign object to reference.

Definition at line 146 of file vtkWeakPointer.h.

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

Assign object to reference.

Definition at line 153 of file vtkWeakPointer.h.

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 166 of file vtkWeakPointer.h.

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

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

Definition at line 173 of file vtkWeakPointer.h.

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

Assign object to reference.

Definition at line 186 of file vtkWeakPointer.h.

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

Assign object to reference.

Definition at line 194 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 207 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 211 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 215 of file vtkWeakPointer.h.

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

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

Definition at line 224 of file vtkWeakPointer.h.

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

Provides normal pointer target member access using operator ->.

Definition at line 232 of file vtkWeakPointer.h.


The documentation for this class was generated from the following files: