VTK  9.7.20261002
vtkWebGPU::Handle< T, Traits > Class Template Reference

#include <vtkWebGPUHandle.h>

Detailed Description

template<typename T, typename Traits>
class vtkWebGPU::Handle< T, Traits >

Reference-counted owner of a WebGPU C API handle.

Template Parameters
Tthe raw handle type, e.g. WGPUBuffer
Traitsa type with static AddRef(T) and Release(T) members

Definition at line 64 of file vtkWebGPUHandle.h.

Public Member Functions

 Handle ()=default
 Handle (std::nullptr_t)
 A null handle.
 ~Handle ()
 Handle (const Handle &other)
 Handle (Handle &&other) noexcept
Handle & operator= (std::nullptr_t)
 Release whatever is held and become null.
Handle & operator= (Handle other) noexcept
void Reset ()
 Release the referenced object, if any, and become null.
T Release ()
 Relinquish ownership to the caller, who becomes responsible for releasing the returned handle.
 operator bool () const
T Get () const
 Access the underlying raw handle without transferring ownership.
 operator T () const &
 Access the underlying raw handle without transferring ownership.
 operator T () const &&=delete
 Deleted so that a temporary cannot silently decay to a raw handle.

Static Public Member Functions

static Handle Acquire (T raw)
 Adopt raw without adding a reference.
static Handle Reference (T raw)
 Take a new reference to raw, which stays owned by the caller.

Constructor & Destructor Documentation

◆ Handle() [1/4]

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::Handle ( )
default

◆ Handle() [2/4]

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::Handle ( std::nullptr_t )
inline

A null handle.

Unlike construction from a raw handle, nullptr carries no ownership question, so this one is allowed to be implicit.

Definition at line 73 of file vtkWebGPUHandle.h.

◆ ~Handle()

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::~Handle ( )
inline

Definition at line 98 of file vtkWebGPUHandle.h.

◆ Handle() [3/4]

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::Handle ( const Handle< T, Traits > & other)
inline

Definition at line 100 of file vtkWebGPUHandle.h.

◆ Handle() [4/4]

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::Handle ( Handle< T, Traits > && other)
inlinenoexcept

Definition at line 109 of file vtkWebGPUHandle.h.

Member Function Documentation

◆ Acquire()

template<typename T, typename Traits>
Handle vtkWebGPU::Handle< T, Traits >::Acquire ( T raw)
inlinestatic

Adopt raw without adding a reference.

Use for handles returned by wgpu*Create* entry points, which hand back an owned reference.

Definition at line 79 of file vtkWebGPUHandle.h.

◆ Reference()

template<typename T, typename Traits>
Handle vtkWebGPU::Handle< T, Traits >::Reference ( T raw)
inlinestatic

Take a new reference to raw, which stays owned by the caller.

Definition at line 89 of file vtkWebGPUHandle.h.

◆ operator=() [1/2]

template<typename T, typename Traits>
Handle & vtkWebGPU::Handle< T, Traits >::operator= ( std::nullptr_t )
inline

Release whatever is held and become null.

Definition at line 117 of file vtkWebGPUHandle.h.

◆ operator=() [2/2]

template<typename T, typename Traits>
Handle & vtkWebGPU::Handle< T, Traits >::operator= ( Handle< T, Traits > other)
inlinenoexcept

Definition at line 123 of file vtkWebGPUHandle.h.

◆ Reset()

template<typename T, typename Traits>
void vtkWebGPU::Handle< T, Traits >::Reset ( )
inline

Release the referenced object, if any, and become null.

Definition at line 134 of file vtkWebGPUHandle.h.

◆ Release()

template<typename T, typename Traits>
T vtkWebGPU::Handle< T, Traits >::Release ( )
inline

Relinquish ownership to the caller, who becomes responsible for releasing the returned handle.

This handle becomes null.

Definition at line 146 of file vtkWebGPUHandle.h.

◆ Get()

template<typename T, typename Traits>
T vtkWebGPU::Handle< T, Traits >::Get ( ) const
inline

Access the underlying raw handle without transferring ownership.

The implicit conversion lets a Handle be passed straight to the C API.

Definition at line 153 of file vtkWebGPUHandle.h.

◆ operator T() [1/2]

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::operator T ( ) const &
inline

Access the underlying raw handle without transferring ownership.

The implicit conversion lets a Handle be passed straight to the C API.

Definition at line 154 of file vtkWebGPUHandle.h.

◆ operator T() [2/2]

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::operator T ( ) const &&
delete

Deleted so that a temporary cannot silently decay to a raw handle.

Storing the result of Handle::Acquire(...) into a raw field would release the object at the end of the statement and leave the field dangling; bind the handle to a named variable that outlives the use, or call Get()/Release() to say explicitly which lifetime is intended.

◆ operator bool()

template<typename T, typename Traits>
vtkWebGPU::Handle< T, Traits >::operator bool ( ) const
inlineexplicit

Definition at line 166 of file vtkWebGPUHandle.h.


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