Flutter Engine
 
Loading...
Searching...
No Matches
fml::UniqueObject< T, Traits > Class Template Reference

#include <unique_object.h>

Public Types

using element_type = T
 
using traits_type = Traits
 

Public Member Functions

 UniqueObject ()
 
 UniqueObject (const T &value)
 
 UniqueObject (const T &value, const Traits &traits)
 
 UniqueObject (UniqueObject &&other)
 
 ~UniqueObject ()
 
UniqueObjectoperator= (UniqueObject &&other)
 
void reset (const T &value=Traits::InvalidValue())
 
void swap (UniqueObject &other)
 
release ()
 
const T & get () const
 
bool is_valid () const
 
bool operator== (const T &value) const
 
Traits & get_traits ()
 
const Traits & get_traits () const
 

Detailed Description

template<typename T, typename Traits>
requires UniqueObjectTraits<T, Traits>
class fml::UniqueObject< T, Traits >

Definition at line 30 of file unique_object.h.

Member Typedef Documentation

◆ element_type

template<typename T , typename Traits >
using fml::UniqueObject< T, Traits >::element_type = T

Definition at line 46 of file unique_object.h.

◆ traits_type

template<typename T , typename Traits >
using fml::UniqueObject< T, Traits >::traits_type = Traits

Definition at line 47 of file unique_object.h.

Constructor & Destructor Documentation

◆ UniqueObject() [1/4]

template<typename T , typename Traits >
fml::UniqueObject< T, Traits >::UniqueObject ( )
inline

Definition at line 49 of file unique_object.h.

49: data_(Traits::InvalidValue()) {}

◆ UniqueObject() [2/4]

template<typename T , typename Traits >
fml::UniqueObject< T, Traits >::UniqueObject ( const T &  value)
inlineexplicit

Definition at line 50 of file unique_object.h.

50: data_(value) {}

References value.

◆ UniqueObject() [3/4]

template<typename T , typename Traits >
fml::UniqueObject< T, Traits >::UniqueObject ( const T &  value,
const Traits &  traits 
)
inline

Definition at line 52 of file unique_object.h.

52: data_(value, traits) {}

References value.

◆ UniqueObject() [4/4]

template<typename T , typename Traits >
fml::UniqueObject< T, Traits >::UniqueObject ( UniqueObject< T, Traits > &&  other)
inline

Definition at line 54 of file unique_object.h.

55 : data_(other.release(), other.get_traits()) {}

◆ ~UniqueObject()

template<typename T , typename Traits >
fml::UniqueObject< T, Traits >::~UniqueObject ( )
inline

Definition at line 57 of file unique_object.h.

57 {
58 // NOLINTNEXTLINE(clang-analyzer-core.StackAddressEscape)
59 FreeIfNecessary();
60 }

Member Function Documentation

◆ get()

◆ get_traits() [1/2]

template<typename T , typename Traits >
Traits & fml::UniqueObject< T, Traits >::get_traits ( )
inline

Definition at line 98 of file unique_object.h.

98{ return data_; }

◆ get_traits() [2/2]

template<typename T , typename Traits >
const Traits & fml::UniqueObject< T, Traits >::get_traits ( ) const
inline

Definition at line 99 of file unique_object.h.

99{ return data_; }

◆ is_valid()

◆ operator=()

template<typename T , typename Traits >
UniqueObject & fml::UniqueObject< T, Traits >::operator= ( UniqueObject< T, Traits > &&  other)
inline

Definition at line 62 of file unique_object.h.

62 {
63 reset(other.release());
64 return *this;
65 }
void reset(const T &value=Traits::InvalidValue())

References fml::UniqueObject< T, Traits >::reset().

◆ operator==()

template<typename T , typename Traits >
bool fml::UniqueObject< T, Traits >::operator== ( const T &  value) const
inline

Definition at line 96 of file unique_object.h.

96{ return data_.generic == value; }
int32_t value

References value.

◆ release()

template<typename T , typename Traits >
T fml::UniqueObject< T, Traits >::release ( )
inline

Definition at line 86 of file unique_object.h.

86 {
87 T old_generic = data_.generic;
88 data_.generic = Traits::InvalidValue();
89 return old_generic;
90 }

Referenced by zircon::dart::System::ChannelFromFile(), flutter_runner::IsolateConfigurator::ConfigureCurrentIsolate(), impeller::android::SurfaceTransaction::SetContents(), and fml::VisitFiles().

◆ reset()

template<typename T , typename Traits >
void fml::UniqueObject< T, Traits >::reset ( const T &  value = Traits::InvalidValue())
inline

Definition at line 67 of file unique_object.h.

67 {
68 FML_CHECK(data_.generic == Traits::InvalidValue() ||
69 data_.generic != value);
70 FreeIfNecessary();
71 data_.generic = value;
72 }
#define FML_CHECK(condition)
Definition logging.h:104

References FML_CHECK, and value.

Referenced by impeller::android::HardwareBuffer::HardwareBuffer(), fml::UniqueObject< T, Traits >::operator=(), impeller::android::SurfaceControl::SurfaceControl(), impeller::compiler::testing::CompilerTest::~CompilerTest(), and fml::ScopedTemporaryDirectory::~ScopedTemporaryDirectory().

◆ swap()

template<typename T , typename Traits >
void fml::UniqueObject< T, Traits >::swap ( UniqueObject< T, Traits > &  other)
inline

Definition at line 74 of file unique_object.h.

74 {
75 // Standard swap idiom: 'using std::swap' ensures that std::swap is
76 // present in the overload set, but we call swap unqualified so that
77 // any more-specific overloads can be used, if available.
78 using std::swap;
79 swap(static_cast<Traits&>(data_), static_cast<Traits&>(other.data_));
80 swap(data_.generic, other.data_.generic);
81 }
void swap(UniqueObject &other)

References fml::UniqueObject< T, Traits >::swap().

Referenced by fml::swap(), and fml::UniqueObject< T, Traits >::swap().


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