Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
gr_cp< T > Class Template Reference

#include <GrD3DTypes.h>

Public Types

using element_type = T
 

Public Member Functions

constexpr gr_cp ()
 
constexpr gr_cp (std::nullptr_t)
 
 gr_cp (const gr_cp< T > &that)
 
 gr_cp (gr_cp< T > &&that)
 
 gr_cp (T *obj)
 
 ~gr_cp ()
 
gr_cp< T > & operator= (const gr_cp< T > &that)
 
gr_cp< T > & operator= (gr_cp< T > &&that)
 
 operator bool () const
 
Tget () const
 
Toperator-> () const
 
T ** operator& ()
 
void reset (T *object=nullptr)
 
void retain (T *object)
 
Trelease ()
 

Detailed Description

template<typename T>
class gr_cp< T >

Definition at line 48 of file GrD3DTypes.h.

Member Typedef Documentation

◆ element_type

template<typename T >
using gr_cp< T >::element_type = T

Definition at line 50 of file GrD3DTypes.h.

Constructor & Destructor Documentation

◆ gr_cp() [1/5]

template<typename T >
constexpr gr_cp< T >::gr_cp ( )
inlineconstexpr

Definition at line 52 of file GrD3DTypes.h.

52: fObject(nullptr) {}

◆ gr_cp() [2/5]

template<typename T >
constexpr gr_cp< T >::gr_cp ( std::nullptr_t  )
inlineconstexpr

Definition at line 53 of file GrD3DTypes.h.

53: fObject(nullptr) {}

◆ gr_cp() [3/5]

template<typename T >
gr_cp< T >::gr_cp ( const gr_cp< T > &  that)
inline

Shares the underlying object by calling AddRef(), so that both the argument and the newly created gr_cp both have a reference to it.

Definition at line 59 of file GrD3DTypes.h.

59: fObject(GrSafeComAddRef(that.get())) {}
static T * GrSafeComAddRef(T *obj)
Definition: GrD3DTypes.h:33
T * get() const
Definition: GrD3DTypes.h:108

◆ gr_cp() [4/5]

template<typename T >
gr_cp< T >::gr_cp ( gr_cp< T > &&  that)
inline

Move the underlying object from the argument to the newly created gr_cp. Afterwards only the new gr_cp will have a reference to the object, and the argument will point to null. No call to AddRef() or Release() will be made.

Definition at line 66 of file GrD3DTypes.h.

66: fObject(that.release()) {}
T * release()
Definition: GrD3DTypes.h:137

◆ gr_cp() [5/5]

template<typename T >
gr_cp< T >::gr_cp ( T obj)
inlineexplicit

Adopt the bare object into the newly created gr_cp. No call to AddRef() or Release() will be made.

Definition at line 72 of file GrD3DTypes.h.

72 {
73 fObject = obj;
74 }

◆ ~gr_cp()

template<typename T >
gr_cp< T >::~gr_cp ( )
inline

Calls Release() on the underlying object pointer.

Definition at line 79 of file GrD3DTypes.h.

79 {
80 GrSafeComRelease(fObject);
81 SkDEBUGCODE(fObject = nullptr);
82 }
static void GrSafeComRelease(T *obj)
Definition: GrD3DTypes.h:42
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()

Member Function Documentation

◆ get()

template<typename T >
T * gr_cp< T >::get ( ) const
inline

Definition at line 108 of file GrD3DTypes.h.

108{ return fObject; }

◆ operator bool()

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

Definition at line 106 of file GrD3DTypes.h.

106{ return this->get() != nullptr; }

◆ operator&()

template<typename T >
T ** gr_cp< T >::operator& ( )
inline

Definition at line 110 of file GrD3DTypes.h.

110{ return &fObject; }

◆ operator->()

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

Definition at line 109 of file GrD3DTypes.h.

109{ return fObject; }

◆ operator=() [1/2]

template<typename T >
gr_cp< T > & gr_cp< T >::operator= ( const gr_cp< T > &  that)
inline

Shares the underlying object referenced by the argument by calling AddRef() on it. If this gr_cp previously had a reference to an object (i.e. not null) it will call Release() on that object.

Definition at line 89 of file GrD3DTypes.h.

89 {
90 if (this != &that) {
91 this->reset(GrSafeComAddRef(that.get()));
92 }
93 return *this;
94 }
void reset(T *object=nullptr)
Definition: GrD3DTypes.h:116

◆ operator=() [2/2]

template<typename T >
gr_cp< T > & gr_cp< T >::operator= ( gr_cp< T > &&  that)
inline

Move the underlying object from the argument to the gr_cp. If the gr_cp previously held a reference to another object, Release() will be called on that object. No call to AddRef() will be made.

Definition at line 101 of file GrD3DTypes.h.

101 {
102 this->reset(that.release());
103 return *this;
104 }

◆ release()

template<typename T >
T * gr_cp< T >::release ( )
inline

Return the original object, and set the internal object to nullptr. The caller must assume ownership of the object, and manage its reference count directly. No call to Release() will be made.

Definition at line 137 of file GrD3DTypes.h.

137 {
138 T* obj = fObject;
139 fObject = nullptr;
140 return obj;
141 }
#define T
Definition: precompiler.cc:65

◆ reset()

template<typename T >
void gr_cp< T >::reset ( T object = nullptr)
inline

Adopt the new object, and call Release() on any previously held object (if not null). No call to AddRef() will be made.

Definition at line 116 of file GrD3DTypes.h.

116 {
117 T* oldObject = fObject;
118 fObject = object;
119 GrSafeComRelease(oldObject);
120 }

◆ retain()

template<typename T >
void gr_cp< T >::retain ( T object)
inline

Shares the new object by calling AddRef() on it. If this gr_cp previously had a reference to an object (i.e. not null) it will call Release() on that object.

Definition at line 126 of file GrD3DTypes.h.

126 {
127 if (this->fObject != object) {
128 this->reset(GrSafeComAddRef(object));
129 }
130 }

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