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

Allocate and hold a VTK object. More...

#include <vtkNew.h>

Public Member Functions

 vtkNew ()
 Create a new T on construction. More...
 
T * operator-> () const
 Enable pointer-like dereference syntax. More...
 
T & operator* () const
 Dereference the pointer and return a reference to the contained object. More...
 
 ~vtkNew ()
 Deletes reference to instance of T on destruction. More...
 
T * GetPointer () const
 Get a raw pointer to the contained object. More...
 
T * Get () const
 Get a raw pointer to the contained object. More...
 
 operator T * () const
 Get a raw pointer to the contained object. More...
 

Detailed Description

template<class T>
class vtkNew< T >

Allocate and hold a VTK object.

vtkNew is a class template that on construction allocates and initializes an instance of its template argument using T::New(). It assumes ownership of one reference during its lifetime, and calls T->Delete() on destruction.

Automatic casting to raw pointer is available for convenience, but users of this method should ensure that they do not return this pointer if the vtkNew will go out of scope without incrementing its reference count.

vtkNew is a drop in replacement for vtkSmartPointer, for example,

See also
vtkSmartPointer vtkWeakPointer
Examples:
vtkNew (Examples)
Tests:
vtkNew (Tests)

Definition at line 58 of file vtkNew.h.

Constructor & Destructor Documentation

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

Create a new T on construction.

Definition at line 68 of file vtkNew.h.

template<class T>
vtkNew< T >::~vtkNew ( )
inline

Deletes reference to instance of T on destruction.

Definition at line 77 of file vtkNew.h.

Member Function Documentation

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

Enable pointer-like dereference syntax.

Returns a pointer to the contained object.

Definition at line 92 of file vtkNew.h.

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

Get a raw pointer to the contained object.

When using this function be careful that the reference count does not drop to 0 when using the pointer returned. This will happen when the vtkNew object goes out of scope for example.

Definition at line 104 of file vtkNew.h.

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

Get a raw pointer to the contained object.

When using this function be careful that the reference count does not drop to 0 when using the pointer returned. This will happen when the vtkNew object goes out of scope for example.

Definition at line 108 of file vtkNew.h.

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

Get a raw pointer to the contained object.

When using this function be careful that the reference count does not drop to 0 when using the pointer returned. This will happen when the vtkNew object goes out of scope for example.

Definition at line 112 of file vtkNew.h.

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

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

When using this function be careful that the reference count does not drop to 0 when using the pointer returned. This will happen when the vtkNew object goes out of scope for example.

Definition at line 123 of file vtkNew.h.


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