nicegraf
ngf::ngf_handle< T, ObjectManagementFuncs > Class Template Reference

Public Types

typedef ObjectManagementFuncs::InitType init_type
 

Public Member Functions

 ngf_handle (T raw)
 
 ngf_handle ()
 
 ngf_handle (const ngf_handle &)=delete
 
 ngf_handle (ngf_handle &&other)
 
 ~ngf_handle ()
 
ngf_handleoperator= (const ngf_handle &)=delete
 
ngf_handleoperator= (ngf_handle &&other) noexcept
 
ngf_error initialize (const typename ObjectManagementFuncs::InitType &info)
 
get ()
 
const T get () const
 
release ()
 
 operator T ()
 
 operator const T () const
 
void reset (T new_handle)
 

Detailed Description

template<class T, class ObjectManagementFuncs>
class ngf::ngf_handle< T, ObjectManagementFuncs >

A move-only RAII wrapper over nicegraf handles that provides unique ownership semantics.

Constructor & Destructor Documentation

◆ ngf_handle() [1/2]

template<class T , class ObjectManagementFuncs >
ngf::ngf_handle< T, ObjectManagementFuncs >::ngf_handle ( T raw)
inlineexplicit

Wraps a raw handle to a nicegraf object.

◆ ngf_handle() [2/2]

template<class T , class ObjectManagementFuncs >
ngf::ngf_handle< T, ObjectManagementFuncs >::ngf_handle ( )
inline

Wraps a null handle.

◆ ~ngf_handle()

template<class T , class ObjectManagementFuncs >
ngf::ngf_handle< T, ObjectManagementFuncs >::~ngf_handle ( )
inline

Disposes of the owned handle, if it is not null.

Member Function Documentation

◆ get() [1/2]

template<class T , class ObjectManagementFuncs >
T ngf::ngf_handle< T, ObjectManagementFuncs >::get ( )
inline
Returns
The raw handle to the wrapped object.

◆ get() [2/2]

template<class T , class ObjectManagementFuncs >
const T ngf::ngf_handle< T, ObjectManagementFuncs >::get ( ) const
inline
Returns
The raw handle to the wrapped object.

◆ initialize()

template<class T , class ObjectManagementFuncs >
ngf_error ngf::ngf_handle< T, ObjectManagementFuncs >::initialize ( const typename ObjectManagementFuncs::InitType & info)
inline

Creates a new handle using the provided configuration, and takes ownership of it.

◆ operator const T()

template<class T , class ObjectManagementFuncs >
ngf::ngf_handle< T, ObjectManagementFuncs >::operator const T ( ) const
inline

Implicit conversion to the raw handle type.

◆ operator T()

template<class T , class ObjectManagementFuncs >
ngf::ngf_handle< T, ObjectManagementFuncs >::operator T ( )
inline

Implicit conversion to the raw handle type.

◆ operator=()

template<class T , class ObjectManagementFuncs >
ngf_handle & ngf::ngf_handle< T, ObjectManagementFuncs >::operator= ( ngf_handle< T, ObjectManagementFuncs > && other)
inlinenoexcept

Takes ownership of the handle wrapped by another object.

◆ release()

template<class T , class ObjectManagementFuncs >
T ngf::ngf_handle< T, ObjectManagementFuncs >::release ( )
inline

Relinquishes ownership of the wrapped object and returns a raw handle to it. After this call completes, it is the responsibility of the calling code to dispose of the handle properly when it is no longer needed.

◆ reset()

template<class T , class ObjectManagementFuncs >
void ngf::ngf_handle< T, ObjectManagementFuncs >::reset ( T new_handle)
inline

Wraps a raw handle to a nicegraf object.