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

a weak reference to a vtkObject. More...

#include <vtkWeakPointer.h>

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

Public Member Functions

 vtkWeakPointer ()
 Initialize smart pointer to NULL. More...
 
 vtkWeakPointer (T *r)
 Initialize smart pointer to given object. More...
 
 vtkWeakPointer (const vtkWeakPointerBase &r)
 Initialize smart pointer with the given smart pointer. More...
 
 operator T * () const
 Get the contained pointer. More...
 
T & operator* () const
 Dereference the pointer and return a reference to the contained object. More...
 
T * operator-> () const
 Provides normal pointer target member access using operator ->. More...
 
vtkWeakPointeroperator= (T *r)
 Assign object to reference. More...
 
vtkWeakPointeroperator= (const vtkWeakPointerBase &r)
 Assign object to reference. More...
 
T * GetPointer () const
 Get the contained pointer. More...
 
T * Get () const
 Get the contained pointer. More...
 
- Public Member Functions inherited from vtkWeakPointerBase
 vtkWeakPointerBase ()
 Initialize smart pointer to NULL. More...
 
 vtkWeakPointerBase (vtkObjectBase *r)
 Initialize smart pointer to given object. More...
 
 vtkWeakPointerBase (const vtkWeakPointerBase &r)
 Initialize weak pointer . 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...
 

Protected Member Functions

 vtkWeakPointer (T *r, const NoReference &n)
 
- Protected Member Functions inherited from vtkWeakPointerBase
 vtkWeakPointerBase (vtkObjectBase *r, const NoReference &)
 

Additional Inherited Members

- 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 NULL, 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 52 of file vtkWeakPointer.h.

Constructor & Destructor Documentation

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

Initialize smart pointer to NULL.

Definition at line 58 of file vtkWeakPointer.h.

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

Initialize smart pointer to given object.

Definition at line 63 of file vtkWeakPointer.h.

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

Initialize smart pointer with the given smart pointer.

Definition at line 68 of file vtkWeakPointer.h.

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

Definition at line 154 of file vtkWeakPointer.h.

Member Function Documentation

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

Assign object to reference.

Definition at line 74 of file vtkWeakPointer.h.

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

Assign object to reference.

Definition at line 85 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 96 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 100 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 109 of file vtkWeakPointer.h.

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

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

Definition at line 118 of file vtkWeakPointer.h.

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

Provides normal pointer target member access using operator ->.

Definition at line 126 of file vtkWeakPointer.h.


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