added CFRef holder templated class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36094 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2005-11-06 07:19:18 +00:00
parent 316189733a
commit 18b94824f5

View File

@@ -375,6 +375,55 @@ private :
typedef wxMacUPP<NMProcPtr,NMUPP,NewNMUPP,DisposeNMUPP> wxMacNMUPP ;
template <typename refType> class wxMacCFRefHolder
{
public :
wxMacCFRefHolder()
: m_ref(NULL) , m_release(false)
{
}
wxMacCFRefHolder( refType ref , bool release = true )
: m_ref(ref) , m_release(release)
{
}
~wxMacCFRefHolder()
{
CFRelease( m_ref ) ;
}
void Release()
{
if ( m_release && m_ref != NULL )
CFRelease( m_ref ) ;
m_ref = NULL ;
}
refType Detach()
{
refType val = m_ref ;
m_release = false ;
m_ref = NULL ;
return val ;
}
void Set( refType ref , bool release = true )
{
Release() ;
m_release = release ;
m_ref = ref ;
}
operator refType () const { return m_ref; }
private :
refType m_ref ;
bool m_release ;
DECLARE_NO_COPY_CLASS( wxMacCFRefHolder )
} ;
#if wxUSE_GUI
/*
GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ;