Flutter Engine
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
 
bool operator!= (const T &value) const
 
Traits & get_traits ()
 
const Traits & get_traits () const
 

Detailed Description

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

Definition at line 28 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 44 of file unique_object.h.

◆ traits_type

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

Definition at line 45 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 47 of file unique_object.h.

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

◆ UniqueObject() [2/4]

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

Definition at line 48 of file unique_object.h.

48 : data_(value) {}
uint8_t value

◆ UniqueObject() [3/4]

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

Definition at line 50 of file unique_object.h.

50 : data_(value, traits) {}
uint8_t value

◆ UniqueObject() [4/4]

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

Definition at line 52 of file unique_object.h.

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

◆ ~UniqueObject()

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

Definition at line 55 of file unique_object.h.

55 { FreeIfNecessary(); }

Member Function Documentation

◆ get()

◆ get_traits() [1/2]

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

Definition at line 95 of file unique_object.h.

95 { return data_; }

◆ get_traits() [2/2]

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

Definition at line 96 of file unique_object.h.

96 { return data_; }

◆ is_valid()

◆ operator!=()

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

Definition at line 93 of file unique_object.h.

Referenced by fml::UniqueObject< fdio_ns_t *, UniqueFDIONSTraits >::get_traits().

93 { return data_.generic != value; }
uint8_t value

◆ operator=()

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

Definition at line 57 of file unique_object.h.

57  {
58  reset(other.release());
59  return *this;
60  }
void reset(const T &value=Traits::InvalidValue())
Definition: unique_object.h:62

◆ operator==()

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

Definition at line 91 of file unique_object.h.

Referenced by fml::UniqueObject< fdio_ns_t *, UniqueFDIONSTraits >::get_traits().

91 { return data_.generic == value; }
uint8_t value

◆ release()

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

Definition at line 81 of file unique_object.h.

Referenced by flutter_runner::IsolateConfigurator::ConfigureCurrentIsolate(), and fml::VisitFiles().

81  {
82  T old_generic = data_.generic;
83  data_.generic = Traits::InvalidValue();
84  return old_generic;
85  }

◆ reset()

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

Definition at line 62 of file unique_object.h.

Referenced by flutter_runner::MakeDataFileMapping(), fml::UniqueObject< fdio_ns_t *, UniqueFDIONSTraits >::operator=(), TEST(), flutter::testing::TEST_F(), and fml::ScopedTemporaryDirectory::~ScopedTemporaryDirectory().

62  {
63  FML_CHECK(data_.generic == Traits::InvalidValue() ||
64  data_.generic != value);
65  FreeIfNecessary();
66  data_.generic = value;
67  }
uint8_t value
#define FML_CHECK(condition)
Definition: logging.h:68

◆ swap()

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

Definition at line 69 of file unique_object.h.

Referenced by fml::UniqueObject< fdio_ns_t *, UniqueFDIONSTraits >::swap(), and fml::swap().

69  {
70  // Standard swap idiom: 'using std::swap' ensures that std::swap is
71  // present in the overload set, but we call swap unqualified so that
72  // any more-specific overloads can be used, if available.
73  using std::swap;
74  swap(static_cast<Traits&>(data_), static_cast<Traits&>(other.data_));
75  swap(data_.generic, other.data_.generic);
76  }
void swap(UniqueObject &other)
Definition: unique_object.h:69
void swap(const UniqueObject< T, Traits > &a, const UniqueObject< T, Traits > &b)

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