Flutter Engine
fml::CFRef< T > Class Template Reference

#include <cf_utils.h>

Public Member Functions

 CFRef ()
 
 CFRef (T instance)
 
 CFRef (const CFRef &other)
 
 CFRef (CFRef &&other)
 
CFRefoperator= (CFRef &&other)
 
 ~CFRef ()
 
void Reset (T instance=nullptr)
 
Release ()
 
 operator T () const
 
 operator bool () const
 

Detailed Description

template<class T>
class fml::CFRef< T >

Definition at line 15 of file cf_utils.h.

Constructor & Destructor Documentation

◆ CFRef() [1/4]

template<class T>
fml::CFRef< T >::CFRef ( )
inline

Definition at line 17 of file cf_utils.h.

17 : instance_(nullptr) {}

◆ CFRef() [2/4]

template<class T>
fml::CFRef< T >::CFRef ( instance)
inline

Definition at line 19 of file cf_utils.h.

19 : instance_(instance) {}

◆ CFRef() [3/4]

template<class T>
fml::CFRef< T >::CFRef ( const CFRef< T > &  other)
inline

Definition at line 21 of file cf_utils.h.

21  : instance_(other.instance_) {
22  if (instance_) {
23  CFRetain(instance_);
24  }
25  }

◆ CFRef() [4/4]

template<class T>
fml::CFRef< T >::CFRef ( CFRef< T > &&  other)
inline

Definition at line 27 of file cf_utils.h.

27  : instance_(other.instance_) {
28  other.instance_ = nullptr;
29  }

◆ ~CFRef()

template<class T>
fml::CFRef< T >::~CFRef ( )
inline

Definition at line 36 of file cf_utils.h.

36  {
37  if (instance_ != nullptr) {
38  CFRelease(instance_);
39  }
40  instance_ = nullptr;
41  }

Member Function Documentation

◆ operator bool()

template<class T>
fml::CFRef< T >::operator bool ( ) const
inline

Definition at line 62 of file cf_utils.h.

62 { return instance_ != nullptr; }

◆ operator T()

template<class T>
fml::CFRef< T >::operator T ( ) const
inline

Definition at line 60 of file cf_utils.h.

60 { return instance_; }

◆ operator=()

template<class T>
CFRef& fml::CFRef< T >::operator= ( CFRef< T > &&  other)
inline

Definition at line 31 of file cf_utils.h.

Referenced by fml::CFRef< CVOpenGLESTextureCacheRef >::operator bool().

31  {
32  Reset(other.Release());
33  return *this;
34  }
void Reset(T instance=nullptr)
Definition: cf_utils.h:43

◆ Release()

template<class T>
T fml::CFRef< T >::Release ( )
inline

Definition at line 54 of file cf_utils.h.

54  {
55  auto instance = instance_;
56  instance_ = nullptr;
57  return instance;
58  }

◆ Reset()

template<class T>
void fml::CFRef< T >::Reset ( instance = nullptr)
inline

Definition at line 43 of file cf_utils.h.

Referenced by flutter::IOSContextMetal::IOSContextMetal(), flutter::IOSExternalTextureGL::IOSExternalTextureGL(), fml::CFRef< CVOpenGLESTextureCacheRef >::operator=(), and fml::testing::TEST().

43  {
44  if (instance_ == instance) {
45  return;
46  }
47  if (instance_ != nullptr) {
48  CFRelease(instance_);
49  }
50 
51  instance_ = instance;
52  }

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