Allocate and hold a VTK object.
More...
#include <vtkNew.h>
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,
renWin->AddRenderer(ren);
iren->SetRenderWindow(renWin);
- See also
- vtkSmartPointer vtkWeakPointer
- Examples:
- vtkNew (Examples)
- Online Examples:
- Tests:
- vtkNew (Tests)
Definition at line 171 of file vtkNew.h.
◆ vtkNew() [1/3]
Create a new T on construction.
Definition at line 204 of file vtkNew.h.
◆ vtkNew() [2/3]
Move the object into the constructed vtkNew wrapper, stealing its reference.
The argument is reset to nullptr.
Definition at line 215 of file vtkNew.h.
◆ vtkNew() [3/3]
template<class T >
template<typename U >
Move the object into the constructed vtkNew wrapper, stealing its reference.
The argument is reset to nullptr.
Definition at line 222 of file vtkNew.h.
◆ ~vtkNew()
Deletes reference to instance of T.
Definition at line 235 of file vtkNew.h.
◆ Reset()
Deletes reference to instance of T.
Definition at line 237 of file vtkNew.h.
◆ operator->()
template<class T >
T* vtkNew< T >::operator-> |
( |
| ) |
const |
|
inlinenoexcept |
Enable pointer-like dereference syntax.
Returns a pointer to the contained object.
Definition at line 252 of file vtkNew.h.
◆ GetPointer()
template<class T >
T* vtkNew< T >::GetPointer |
( |
| ) |
const |
|
inlinenoexcept |
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 261 of file vtkNew.h.
◆ Get()
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 262 of file vtkNew.h.
◆ operator T*()
template<class T >
vtkNew< T >::operator T* |
( |
| ) |
const |
|
inlinenoexcept |
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 263 of file vtkNew.h.
◆ operator*()
template<class T >
T& vtkNew< T >::operator* |
( |
| ) |
const |
|
inlinenoexcept |
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 271 of file vtkNew.h.
◆ operator=()
Move assignment operator.
Definition at line 276 of file vtkNew.h.
◆ vtkNew
template<class T >
template<typename U >
◆ vtkSmartPointer
template<class T >
template<typename U >
◆ vtkWeakPointer
template<class T >
template<typename U >
The documentation for this class was generated from the following files: