Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter > Class Template Reference

Generic scopeguard designed to handle any type of handle. More...

#include <ScopeGuard.h>

Public Member Functions

 CScopeGuard (std::function< Deleter > del, Handle handle=invalid)
 
 ~CScopeGuard () noexcept
 
 operator Handle () const
 
 operator bool () const
 
void attach (Handle handle)
 attach a new handle to this instance, if there's already a handle it will be closed.
 
Handle release ()
 release the managed handle so that it won't be auto closed
 
void reset ()
 reset the instance, closing any managed handle and setting it to invalid
 
 CScopeGuard ()=delete
 
 CScopeGuard (const CScopeGuard &rhs)=delete
 
CScopeGuardoperator= (const CScopeGuard &rhs)=delete
 
 CScopeGuard (CScopeGuard &&rhs) noexcept
 
CScopeGuardoperator= (CScopeGuard &&rhs) noexcept
 

Detailed Description

template<typename Handle, Handle invalid, typename Deleter>
class KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >

Generic scopeguard designed to handle any type of handle.

This is not necessary but recommended to cut down on some typing using CSocketHandle = CScopeGuard<SOCKET, INVALID_SOCKET, closesocket>;

CSocketHandle sh(closesocket, open(thingy));

Constructor & Destructor Documentation

◆ CScopeGuard() [1/4]

template<typename Handle , Handle invalid, typename Deleter >
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::CScopeGuard ( std::function< Deleter > del,
Handle handle = invalid )
inline

◆ ~CScopeGuard()

template<typename Handle , Handle invalid, typename Deleter >
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::~CScopeGuard ( )
inlinenoexcept

◆ CScopeGuard() [2/4]

template<typename Handle , Handle invalid, typename Deleter >
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::CScopeGuard ( )
delete

◆ CScopeGuard() [3/4]

template<typename Handle , Handle invalid, typename Deleter >
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::CScopeGuard ( const CScopeGuard< Handle, invalid, Deleter > & rhs)
delete

◆ CScopeGuard() [4/4]

template<typename Handle , Handle invalid, typename Deleter >
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::CScopeGuard ( CScopeGuard< Handle, invalid, Deleter > && rhs)
inlinenoexcept

Member Function Documentation

◆ attach()

template<typename Handle , Handle invalid, typename Deleter >
void KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::attach ( Handle handle)
inline

attach a new handle to this instance, if there's already a handle it will be closed.

Parameters
[in]handleThe handle to manage

◆ operator bool()

template<typename Handle , Handle invalid, typename Deleter >
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::operator bool ( ) const
inline

◆ operator Handle()

template<typename Handle , Handle invalid, typename Deleter >
KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::operator Handle ( ) const
inline

◆ operator=() [1/2]

template<typename Handle , Handle invalid, typename Deleter >
CScopeGuard & KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::operator= ( const CScopeGuard< Handle, invalid, Deleter > & rhs)
delete

◆ operator=() [2/2]

template<typename Handle , Handle invalid, typename Deleter >
CScopeGuard & KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::operator= ( CScopeGuard< Handle, invalid, Deleter > && rhs)
inlinenoexcept

◆ release()

template<typename Handle , Handle invalid, typename Deleter >
Handle KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::release ( )
inline

release the managed handle so that it won't be auto closed

Returns
The handle being managed by the guard

◆ reset()

template<typename Handle , Handle invalid, typename Deleter >
void KODI::UTILS::CScopeGuard< Handle, invalid, Deleter >::reset ( )
inline

reset the instance, closing any managed handle and setting it to invalid


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