Flutter Engine
fml::RefPtr< T > Class Template Referencefinal

#include <ref_ptr.h>

Public Member Functions

 RefPtr ()
 
 RefPtr (std::nullptr_t)
 
template<typename U >
 RefPtr (U *p)
 
 RefPtr (const RefPtr< T > &r)
 
template<typename U >
 RefPtr (const RefPtr< U > &r)
 
 RefPtr (RefPtr< T > &&r)
 
template<typename U >
 RefPtr (RefPtr< U > &&r)
 
 ~RefPtr ()
 
T * get () const
 
T & operator* () const
 
T * operator-> () const
 
RefPtr< T > & operator= (const RefPtr< T > &r)
 
template<typename U >
RefPtr< T > & operator= (const RefPtr< U > &r)
 
RefPtr< T > & operator= (RefPtr< T > &&r)
 
template<typename U >
RefPtr< T > & operator= (RefPtr< U > &&r)
 
void swap (RefPtr< T > &r)
 
RefPtr< T > Clone () const
 
 operator bool () const
 
template<typename U >
bool operator== (const RefPtr< U > &rhs) const
 
template<typename U >
bool operator!= (const RefPtr< U > &rhs) const
 
template<typename U >
bool operator< (const RefPtr< U > &rhs) const
 

Friends

template<typename U >
class RefPtr
 
RefPtr< T > AdoptRef (T *)
 

Detailed Description

template<typename T>
class fml::RefPtr< T >

Definition at line 65 of file ref_ptr.h.

Constructor & Destructor Documentation

◆ RefPtr() [1/7]

template<typename T>
fml::RefPtr< T >::RefPtr ( )
inline

Definition at line 67 of file ref_ptr.h.

67 : ptr_(nullptr) {}

◆ RefPtr() [2/7]

template<typename T>
fml::RefPtr< T >::RefPtr ( std::nullptr_t  )
inline

Definition at line 68 of file ref_ptr.h.

69  : ptr_(nullptr) {} // NOLINT(google-explicit-constructor)

◆ RefPtr() [3/7]

template<typename T>
template<typename U >
fml::RefPtr< T >::RefPtr ( U *  p)
inlineexplicit

Definition at line 76 of file ref_ptr.h.

76  : ptr_(p) {
77  if (ptr_) {
78  ptr_->AddRef();
79  }
80  }

◆ RefPtr() [4/7]

template<typename T>
fml::RefPtr< T >::RefPtr ( const RefPtr< T > &  r)
inline

Definition at line 83 of file ref_ptr.h.

83  : ptr_(r.ptr_) {
84  if (ptr_) {
85  ptr_->AddRef();
86  }
87  }

◆ RefPtr() [5/7]

template<typename T>
template<typename U >
fml::RefPtr< T >::RefPtr ( const RefPtr< U > &  r)
inline

Definition at line 90 of file ref_ptr.h.

91  : ptr_(r.ptr_) { // NOLINT(google-explicit-constructor)
92  if (ptr_) {
93  ptr_->AddRef();
94  }
95  }

◆ RefPtr() [6/7]

template<typename T>
fml::RefPtr< T >::RefPtr ( RefPtr< T > &&  r)
inline

Definition at line 98 of file ref_ptr.h.

98 : ptr_(r.ptr_) { r.ptr_ = nullptr; }

◆ RefPtr() [7/7]

template<typename T>
template<typename U >
fml::RefPtr< T >::RefPtr ( RefPtr< U > &&  r)
inline

Definition at line 101 of file ref_ptr.h.

101  : ptr_(r.ptr_) { // NOLINT(google-explicit-constructor)
102  r.ptr_ = nullptr;
103  }

◆ ~RefPtr()

template<typename T>
fml::RefPtr< T >::~RefPtr ( )
inline

Definition at line 106 of file ref_ptr.h.

106  {
107  if (ptr_) {
108  ptr_->Release();
109  }
110  }

Member Function Documentation

◆ Clone()

template<typename T>
RefPtr<T> fml::RefPtr< T >::Clone ( ) const
inline

Definition at line 180 of file ref_ptr.h.

180 { return *this; }

◆ get()

◆ operator bool()

template<typename T>
fml::RefPtr< T >::operator bool ( ) const
inlineexplicit

Definition at line 182 of file ref_ptr.h.

182 { return !!ptr_; }

◆ operator!=()

template<typename T>
template<typename U >
bool fml::RefPtr< T >::operator!= ( const RefPtr< U > &  rhs) const
inline

Definition at line 190 of file ref_ptr.h.

190  {
191  return !operator==(rhs);
192  }
bool operator==(const RefPtr< U > &rhs) const
Definition: ref_ptr.h:185

◆ operator*()

template<typename T>
T& fml::RefPtr< T >::operator* ( ) const
inline

Definition at line 114 of file ref_ptr.h.

114  {
115  FML_DCHECK(ptr_);
116  return *ptr_;
117  }
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ operator->()

template<typename T>
T* fml::RefPtr< T >::operator-> ( ) const
inline

Definition at line 119 of file ref_ptr.h.

119  {
120  FML_DCHECK(ptr_);
121  return ptr_;
122  }
#define FML_DCHECK(condition)
Definition: logging.h:86

◆ operator<()

template<typename T>
template<typename U >
bool fml::RefPtr< T >::operator< ( const RefPtr< U > &  rhs) const
inline

Definition at line 195 of file ref_ptr.h.

195  {
196  return ptr_ < rhs.ptr_;
197  }

◆ operator=() [1/4]

template<typename T>
RefPtr<T>& fml::RefPtr< T >::operator= ( const RefPtr< T > &  r)
inline

Definition at line 125 of file ref_ptr.h.

125  {
126  // Handle self-assignment.
127  if (r.ptr_ == ptr_) {
128  return *this;
129  }
130  if (r.ptr_) {
131  r.ptr_->AddRef();
132  }
133  T* old_ptr = ptr_;
134  ptr_ = r.ptr_;
135  if (old_ptr) {
136  old_ptr->Release();
137  }
138  return *this;
139  }

◆ operator=() [2/4]

template<typename T>
template<typename U >
RefPtr<T>& fml::RefPtr< T >::operator= ( const RefPtr< U > &  r)
inline

Definition at line 142 of file ref_ptr.h.

142  {
143  if (reinterpret_cast<T*>(r.ptr_) == ptr_) {
144  return *this;
145  }
146  if (r.ptr_) {
147  r.ptr_->AddRef();
148  }
149  T* old_ptr = ptr_;
150  ptr_ = r.ptr_;
151  if (old_ptr) {
152  old_ptr->Release();
153  }
154  return *this;
155  }

◆ operator=() [3/4]

template<typename T>
RefPtr<T>& fml::RefPtr< T >::operator= ( RefPtr< T > &&  r)
inline

Definition at line 160 of file ref_ptr.h.

160  {
161  RefPtr<T>(std::move(r)).swap(*this);
162  return *this;
163  }
void swap(RefPtr< T > &r)
Definition: ref_ptr.h:171

◆ operator=() [4/4]

template<typename T>
template<typename U >
RefPtr<T>& fml::RefPtr< T >::operator= ( RefPtr< U > &&  r)
inline

Definition at line 166 of file ref_ptr.h.

166  {
167  RefPtr<T>(std::move(r)).swap(*this);
168  return *this;
169  }
void swap(RefPtr< T > &r)
Definition: ref_ptr.h:171

◆ operator==()

template<typename T>
template<typename U >
bool fml::RefPtr< T >::operator== ( const RefPtr< U > &  rhs) const
inline

Definition at line 185 of file ref_ptr.h.

Referenced by fml::RefPtr< flutter::CanvasImage >::operator!=().

185  {
186  return ptr_ == rhs.ptr_;
187  }

◆ swap()

template<typename T>
void fml::RefPtr< T >::swap ( RefPtr< T > &  r)
inline

Definition at line 171 of file ref_ptr.h.

Referenced by fml::RefPtr< flutter::CanvasImage >::operator=().

171  {
172  T* p = ptr_;
173  ptr_ = r.ptr_;
174  r.ptr_ = p;
175  }

Friends And Related Function Documentation

◆ AdoptRef

template<typename T>
RefPtr<T> AdoptRef ( T *  )
friend

Definition at line 218 of file ref_ptr.h.

218  {
219 #ifndef NDEBUG
220  ptr->Adopt();
221 #endif
222  return RefPtr<T>(ptr, RefPtr<T>::ADOPT);
223 }

◆ RefPtr

template<typename T>
template<typename U >
friend class RefPtr
friend

Definition at line 201 of file ref_ptr.h.


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