GenericData Class Reference

#include <genericdata.h>

详细描述

GenericData wraps an object of arbitary type. Therefore it's similar to 数据 , but it supports less operations:

The advantage is that you don't need to register the type of the wrapped object as a DataType .

公共成员函数

  GenericData ()=default
  GenericData ( GenericData && src )
  MAXON_OPERATOR_MOVE_ASSIGNMENT ( GenericData )
void  重置 ()
  ~GenericData ()
template<typename T >
Result < void >  Set (T &&value)
Bool   IsEmpty () const
Bool   IsPopulated () const
template<typename T >
const T &  Get () const
template<typename T >
T &  Get ()
const void *  GetPointer () const
void *  GetPointer ()

Static Private Member Functions

template<typename T >
static void  Free ( GenericData *v)

Private Attributes

void *  _ptr
void(*  _free )( GenericData *)

构造函数 & 析构函数文档编制

◆  GenericData() [1/2]

GenericData ( )
default

Constructs an empty GenericData .

◆  GenericData() [2/2]

GenericData ( GenericData &&  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.

◆  ~GenericData()

~ GenericData ( )

Destructs this GenericData . This frees any previously set value.

成员函数文档编制

◆  MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( GenericData   )

◆  Reset()

void Reset ( )

Resets this GenericData to an empty object. This frees any previously set value.

◆  Set()

Result <void> Set ( T &&  value )

Initializes this GenericData with value. This frees any previously set value at first.

参数
[in] value The value to wrap.
返回
OK on success.

◆  IsEmpty()

Bool IsEmpty ( ) const

Checks if this GenericData is empty.

返回
True if this GenericData has no wrapped value, false otherwise.

◆  IsPopulated()

Bool IsPopulated ( ) const

Checks if this GenericData has a wrapped value.

返回
True if this GenericData has a wrapped value, false otherwise.

◆  Get() [1/2]

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.

Template Parameters
T The type of the wrapped value.
返回
The wrapped value of type T.

◆  Get() [2/2]

T& Get ( )

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.

Template Parameters
T The type of the wrapped value.
返回
The wrapped value of type T.

◆  GetPointer() [1/2]

const void* GetPointer ( ) const

Returns a pointer to the wrapped value.

返回
Pointer to the wrapped values.

◆  GetPointer() [2/2]

void* GetPointer ( )

Returns a pointer to the wrapped value.

返回
Pointer to the wrapped values.

◆  Free()

static void Free ( GenericData v )
static private

Member Data Documentation

◆  _ptr

void* _ptr private

◆  _free

void(* _free( GenericData *)
private