Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
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)
 
T release ()
 
const Tget () 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) {}

◆ 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) {}

◆ 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()

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

Definition at line 87 of file unique_object.h.

87{ return data_.generic; }

◆ 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()

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

Definition at line 89 of file unique_object.h.

89{ return Traits::IsValid(data_.generic); }

◆ 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.

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 }
m reset()

◆ 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.

91{ return data_.generic == value; }

◆ release()

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

Definition at line 81 of file unique_object.h.

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

◆ 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.

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

◆ 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.

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)

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