VTK  9.2.20230528
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 <vtkSmartPointer.h>

Inherits vtkSmartPointerBase.

Collaboration diagram for vtkSmartPointer< T >:
[legend]

Public Member Functions

 vtkSmartPointer () noexcept
 Initialize smart pointer to nullptr. More...
 
template<typename U >
 vtkSmartPointer (vtkNew< U > &&r) noexcept
 Move the pointer from the vtkNew smart pointer to the new vtkSmartPointer, stealing its reference and resetting the vtkNew object to nullptr. More...
 
template<typename U >
vtkSmartPointeroperator= (const vtkNew< U > &r)
 Assign object to reference. More...
 
template<typename U >
vtkSmartPointeroperator= (U *r)
 Assign object to reference. 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...
 
void TakeReference (T *t)
 Transfer ownership of one reference to the given VTK object to this smart pointer. More...
 
 vtkSmartPointer (const vtkSmartPointer &r)
 Initialize smart pointer with a new reference to the same object referenced by given smart pointer. 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...
 
 vtkSmartPointer (vtkSmartPointer &&r) noexcept
 Move the contents of r into this. More...
 
template<class U >
 vtkSmartPointer (vtkSmartPointer< U > &&r) noexcept
 Initialize smart pointer with a new reference to the same object referenced by given smart pointer. More...
 
 vtkSmartPointer (T *r)
 Initialize smart pointer to given object. More...
 
template<typename U >
 vtkSmartPointer (const vtkNew< U > &r)
 Initialize smart pointer to given object. More...
 
vtkSmartPointeroperator= (const vtkSmartPointer &r)
 Assign object to reference. More...
 
template<class U >
vtkSmartPointeroperator= (const vtkSmartPointer< U > &r)
 Assign object to reference. More...
 
T * GetPointer () const noexcept
 Get the contained pointer. More...
 
T * Get () const noexcept
 Get the contained pointer. More...
 
- Public Member Functions inherited from vtkSmartPointerBase
 vtkSmartPointerBase () noexcept
 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 (vtkSmartPointerBase &&r) noexcept
 Move the pointee from r into this and reset @ r. More...
 
 ~vtkSmartPointerBase ()
 Destroy smart pointer and remove the reference to its object. More...
 
vtkObjectBaseGetPointer () const noexcept
 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 > ExtendedNew ()
 Create an instance of a VTK object in a memkind extended memory space. 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...
 
static vtkSmartPointer< T > New ()
 Create an instance of a VTK object. More...
 
template<class... ArgsT>
static vtkSmartPointer< T > New (ArgsT &&... args)
 Create an instance of a VTK object. 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)
Online Examples:

Tests:
vtkSmartPointer (Tests)

Definition at line 152 of file vtkSmartPointer.h.

Constructor & Destructor Documentation

◆ vtkSmartPointer() [1/9]

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

Initialize smart pointer to nullptr.

Definition at line 179 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [2/9]

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

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

Definition at line 190 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [3/9]

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 196 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [4/9]

template<class T >
vtkSmartPointer< T >::vtkSmartPointer ( vtkSmartPointer< T > &&  r)
inlinenoexcept

Move the contents of r into this.

Definition at line 208 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [5/9]

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

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

Definition at line 214 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [6/9]

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

Initialize smart pointer to given object.

Definition at line 225 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [7/9]

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

Initialize smart pointer to given object.

Definition at line 232 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [8/9]

template<class T >
template<typename U >
vtkSmartPointer< T >::vtkSmartPointer ( vtkNew< U > &&  r)
inlinenoexcept

Move the pointer from the vtkNew smart pointer to the new vtkSmartPointer, stealing its reference and resetting the vtkNew object to nullptr.

Definition at line 244 of file vtkSmartPointer.h.

◆ vtkSmartPointer() [9/9]

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

Definition at line 408 of file vtkSmartPointer.h.

Member Function Documentation

◆ operator=() [1/4]

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

Assign object to reference.

This removes any reference to an old object.

Definition at line 259 of file vtkSmartPointer.h.

◆ operator=() [2/4]

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 266 of file vtkSmartPointer.h.

◆ operator=() [3/4]

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

Assign object to reference.

This removes any reference to an old object.

Definition at line 280 of file vtkSmartPointer.h.

◆ operator=() [4/4]

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

Assign object to reference.

This adds a new reference to an old object.

Definition at line 293 of file vtkSmartPointer.h.

◆ GetPointer()

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

Get the contained pointer.

Definition at line 305 of file vtkSmartPointer.h.

◆ Get()

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

Get the contained pointer.

Definition at line 306 of file vtkSmartPointer.h.

◆ operator T*()

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

Get the contained pointer.

Definition at line 312 of file vtkSmartPointer.h.

◆ operator*()

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

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

Definition at line 318 of file vtkSmartPointer.h.

◆ operator->()

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

Provides normal pointer target member access using operator ->.

Definition at line 323 of file vtkSmartPointer.h.

◆ TakeReference()

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 337 of file vtkSmartPointer.h.

◆ New() [1/2]

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

Create an instance of a VTK object.

Definition at line 343 of file vtkSmartPointer.h.

◆ New() [2/2]

template<class T >
template<class... ArgsT>
static vtkSmartPointer<T> vtkSmartPointer< T >::New ( ArgsT &&...  args)
inlinestatic

Create an instance of a VTK object.

Definition at line 345 of file vtkSmartPointer.h.

◆ ExtendedNew()

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

Create an instance of a VTK object in a memkind extended memory space.

Note that not all vtkObjects support this yet and that VTK needs to be compiled with VTK_USE_MEMKIND to enable those that do. If not enabled, this is equivalent to calling New()

Definition at line 356 of file vtkSmartPointer.h.

◆ NewInstance()

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

Create a new instance of the given VTK object.

Definition at line 364 of file vtkSmartPointer.h.

◆ Take()

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 382 of file vtkSmartPointer.h.


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