VTK
Public Member Functions | Protected Member Functions
vtkWeakPointer< T > Class Template Reference

a weak reference to a vtkObject. More...

#include <vtkWeakPointer.h>

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

List of all members.

Public Member Functions

 vtkWeakPointer ()
 vtkWeakPointer (T *r)
 vtkWeakPointer (const vtkWeakPointerBase &r)
vtkWeakPointeroperator= (T *r)
vtkWeakPointeroperator= (const vtkWeakPointerBase &r)
T * GetPointer () const
 operator T * () const
T & operator* () const
T * operator-> () const

Protected Member Functions

 vtkWeakPointer (T *r, const NoReference &n)

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.

 vtkTable *table = vtkTable::New();
 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 51 of file vtkWeakPointer.h.


Constructor & Destructor Documentation

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

Initialize smart pointer to NULL.

Definition at line 55 of file vtkWeakPointer.h.

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

Initialize smart pointer to given object.

Definition at line 58 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 61 of file vtkWeakPointer.h.

template<class T>
vtkWeakPointer< T >::vtkWeakPointer ( T *  r,
const NoReference n 
) [inline, protected]

Definition at line 137 of file vtkWeakPointer.h.


Member Function Documentation

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

Assign object to reference.

Definition at line 65 of file vtkWeakPointer.h.

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

Assign object to reference.

Reimplemented from vtkWeakPointerBase.

Definition at line 74 of file vtkWeakPointer.h.

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

Get the contained pointer.

Reimplemented from vtkWeakPointerBase.

Definition at line 83 of file vtkWeakPointer.h.

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

Get the contained pointer.

Definition at line 91 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 100 of file vtkWeakPointer.h.

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

Provides normal pointer target member access using operator ->.

Definition at line 108 of file vtkWeakPointer.h.


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