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

Hold a reference to a vtkObjectBase instance. More...

#include <vtkMeta.h>

Inherits vtkSmartPointerBase.

Collaboration diagram for vtkSmartPointer< T >:
[legend]

Public Member Functions

 vtkSmartPointer ()
 Initialize smart pointer to nullptr. More...
 
 vtkSmartPointer (T *r)
 Initialize smart pointer to given object. More...
 
 vtkSmartPointer (vtkNew< T > &r)
 Initialize smart pointer to given object. More...
 
template<class U >
 vtkSmartPointer (const vtkSmartPointer< U > &r)
 Initialize smart pointer with a new reference to the same object referenced by 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...
 
void TakeReference (T *t)
 Transfer ownership of one reference to the given VTK object to this smart pointer. More...
 
vtkSmartPointeroperator= (T *r)
 Assign object to reference. More...
 
vtkSmartPointeroperator= (vtkNew< T > &r)
 Assign object to reference. More...
 
template<class U >
vtkSmartPointeroperator= (const vtkSmartPointer< U > &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 vtkSmartPointerBase
 vtkSmartPointerBase ()
 Initialize smart pointer to nullptr. More...
 
 vtkSmartPointerBase (vtkObjectBase *r)
 Initialize smart pointer to given object. More...
 
 vtkSmartPointerBase (const vtkSmartPointerBase &r)
 Initialize smart pointer with a new reference to the same object referenced by given smart pointer. More...
 
 ~vtkSmartPointerBase ()
 Destroy smart pointer and remove the reference to its object. More...
 
vtkObjectBaseGetPointer () const
 Get the contained pointer. More...
 
void Report (vtkGarbageCollector *collector, const char *desc)
 Report the reference held by the smart pointer to a collector. More...
 
vtkSmartPointerBaseoperator= (vtkObjectBase *r)
 Assign object to reference. More...
 
vtkSmartPointerBaseoperator= (const vtkSmartPointerBase &r)
 Assign object to reference. More...
 

Static Public Member Functions

static vtkSmartPointer< T > New ()
 Create an instance of a VTK object. More...
 
static vtkSmartPointer< T > NewInstance (T *t)
 Create a new instance of the given VTK object. More...
 
static vtkSmartPointer< T > Take (T *t)
 Transfer ownership of one reference to the given VTK object to a new smart pointer. More...
 

Protected Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from vtkSmartPointerBase
vtkObjectBaseObject
 

Detailed Description

template<class T>
class vtkSmartPointer< T >

Hold a reference to a vtkObjectBase instance.

vtkSmartPointer is a class template that provides automatic casting for objects held by the vtkSmartPointerBase superclass.

Examples:
vtkSmartPointer (Examples)
Tests:
vtkSmartPointer (Tests)

Definition at line 31 of file vtkMeta.h.

Constructor & Destructor Documentation

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

Initialize smart pointer to nullptr.

Definition at line 43 of file vtkSmartPointer.h.

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

Initialize smart pointer to given object.

Definition at line 48 of file vtkSmartPointer.h.

template<class T>
vtkSmartPointer< T >::vtkSmartPointer ( vtkNew< T > &  r)
inline

Initialize smart pointer to given object.

Definition at line 53 of file vtkSmartPointer.h.

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

Initialize smart pointer with a new reference to the same object referenced by given smart pointer.

Definition at line 60 of file vtkSmartPointer.h.

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

Definition at line 213 of file vtkSmartPointer.h.

Member Function Documentation

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

Assign object to reference.

This removes any reference to an old object.

Definition at line 68 of file vtkSmartPointer.h.

template<class T>
vtkSmartPointer& vtkSmartPointer< T >::operator= ( vtkNew< T > &  r)
inline

Assign object to reference.

This removes a reference to an old object.

Definition at line 80 of file vtkSmartPointer.h.

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

Assign object to reference.

This removes any reference to an old object.

Definition at line 93 of file vtkSmartPointer.h.

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

Get the contained pointer.

Definition at line 104 of file vtkSmartPointer.h.

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

Get the contained pointer.

Definition at line 108 of file vtkSmartPointer.h.

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

Get the contained pointer.

Definition at line 117 of file vtkSmartPointer.h.

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

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

Definition at line 126 of file vtkSmartPointer.h.

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

Provides normal pointer target member access using operator ->.

Definition at line 134 of file vtkSmartPointer.h.

template<class T>
void vtkSmartPointer< T >::TakeReference ( T *  t)
inline

Transfer ownership of one reference to the given VTK object to this smart pointer.

This does not increment the reference count of the object, but will decrement it later. The caller is effectively passing ownership of one reference to the smart pointer. This is useful for code like:

vtkSmartPointer<vtkFoo> foo; foo.TakeReference(bar->NewFoo());

The input argument may not be another smart pointer.

Definition at line 151 of file vtkSmartPointer.h.

template<class T>
static vtkSmartPointer<T> vtkSmartPointer< T >::New ( )
inlinestatic

Create an instance of a VTK object.

Definition at line 159 of file vtkSmartPointer.h.

template<class T>
static vtkSmartPointer<T> vtkSmartPointer< T >::NewInstance ( T *  t)
inlinestatic

Create a new instance of the given VTK object.

Definition at line 167 of file vtkSmartPointer.h.

template<class T>
static vtkSmartPointer<T> vtkSmartPointer< T >::Take ( T *  t)
inlinestatic

Transfer ownership of one reference to the given VTK object to a new smart pointer.

The returned smart pointer does not increment the reference count of the object on construction but will decrement it on destruction. The caller is effectively passing ownership of one reference to the smart pointer. This is useful for code like:

vtkSmartPointer<vtkFoo> foo = vtkSmartPointer<vtkFoo>::Take(bar->NewFoo());

The input argument may not be another smart pointer.

Definition at line 185 of file vtkSmartPointer.h.


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