#include <genericdata.h>
GenericDataTemplate wraps an object of arbitary type. It's similar to Data, but with the advantage that you don't need to register the type of the wrapped object as a DataType. This is bought with some restrictions:
REFCOUNTED | True if reference counting shall be used for the wrapped object. In that case, multiple GenericDataTemplate instances can share a single object. |
Public Types | |
using | CopyType = typename std::conditional< REFCOUNTED, GenericDataTemplate, DummyParamType >::type |
Public Member Functions | |
GenericDataTemplate ()=default | |
GenericDataTemplate (GenericDataTemplate &&src) | |
MAXON_OPERATOR_MOVE_ASSIGNMENT (GenericDataTemplate) | |
GenericDataTemplate (const CopyType &src) | |
GenericDataTemplate & | operator= (const CopyType &src) |
void | Reset () |
~GenericDataTemplate () | |
template<typename T > | |
Result< void > | Set (T &&value) |
Bool | IsEmpty () const |
Bool | IsPopulated () const |
template<typename T > | |
const T & | Get () const |
template<typename T > | |
ConstIf< T, REFCOUNTED >::type & | Get () |
template<typename T > | |
Result< typename ConstIf< T, REFCOUNTED >::type & > | GetOrCreate () |
template<typename T > | |
Result< T & > | Create () |
const void * | GetPointer () const |
ConstIf< void, REFCOUNTED >::type * | GetPointer () |
Private Member Functions | |
void | RemoveRef () |
void | AddRef () |
Static Private Member Functions | |
template<typename T > | |
static void | Free (GenericDataTemplate *v) |
Private Attributes | |
void * | _ptr |
void(* | _free )(GenericDataTemplate *) |
using CopyType = typename std::conditional<REFCOUNTED, GenericDataTemplate, DummyParamType>::type |
|
default |
Constructs an empty GenericData.
GenericDataTemplate | ( | GenericDataTemplate< REFCOUNTED > && | src | ) |
Constructs a GenericData by moving the contents of src to the new GenericData. src will be an empty GenericData afterwards.
[in,out] | src | The source object. |
|
explicit |
~GenericDataTemplate | ( | ) |
Destructs this GenericData. This frees any previously set value.
MAXON_OPERATOR_MOVE_ASSIGNMENT | ( | GenericDataTemplate< REFCOUNTED > | ) |
GenericDataTemplate& operator= | ( | const CopyType & | src | ) |
void Reset | ( | ) |
Resets this GenericData to an empty object. This frees any previously set value.
Result<void> Set | ( | T && | value | ) |
Initializes this GenericData with value. This frees any previously set value at first.
[in] | value | The value to wrap. |
Bool IsEmpty | ( | ) | const |
Checks if this GenericData is empty.
Bool IsPopulated | ( | ) | const |
Checks if this GenericData has a wrapped value.
const T& Get | ( | ) | const |
Returns the wrapped value. The type T has to match the exact type of the wrapped value, otherwise the behaviour is undetermined. There is no check that the type matches.
T | The type of the wrapped value. |
Returns the wrapped value. The type T has to match the exact type of the wrapped value, otherwise the behaviour is undetermined. There is no check that the type matches.
T | The type of the wrapped value. |
Result<T&> Create | ( | ) |
const void* GetPointer | ( | ) | const |
Returns a pointer to the wrapped value.
Returns a pointer to the wrapped value.
|
staticprivate |
|
private |
|
private |
|
private |
|
private |