DelegateBase Class Reference

#include <delegate.h>

Inheritance diagram for DelegateBase:

详细描述

Delegate base class which can be used for DataType .

公共成员函数

  DelegateBase ()
  ~DelegateBase ()
template<typename STUBPTR >
  DelegateBase (void *objectPtr, STUBPTR stubPtr, Callback callback)
template<typename FN , typename STUBPTR >
  DelegateBase (FN &&fn, STUBPTR stub, Callback callback)
  DelegateBase (const DelegateBase &)=delete
  DelegateBase ( DelegateBase && src )
  MAXON_OPERATOR_MOVE_ASSIGNMENT ( DelegateBase )
void  重置 ()
ResultMem   CopyFrom (const DelegateBase & src )
template<typename FN , typename STUBPTR >
ResultMem   CopyFrom (FN &&f, STUBPTR stub, Callback callback)
template<typename OBJ , typename STUBPTR >
ResultMem   CopyFrom (OBJ &&object, STUBPTR stub)
Bool   IsEmpty () const
Bool   IsPopulated () const
Bool   IsStaticFunctionPointer () const
template<typename FUNCTIONPTR >
FUNCTIONPTR  GetStaticFunctionPointer () const
template<typename STUBPTR >
STUBPTR  GetStubPointer () const

Protected Types

enum   CALLBACKMODE {
   ALLOC ,
   DESTRUCT_AND_RELEASE ,
   COPY ,
   MOVE_AND_DESTRUCT
}
using  Callback = Int (*)( DelegateBase *dst, const DelegateBase * src , CALLBACKMODE mode)

Protected Member Functions

enum maxon::DelegateBase::CALLBACKMODE   MAXON_ENUM_ORDERED_LIST_CLASS ( CALLBACKMODE )

Static Protected Member Functions

template<typename REF >
static Callback   GetReferenceUtilityStub (void *)
template<typename REF >
static Callback   GetReferenceUtilityStub ( PointerHandler *)
static Int   PTMFUtilityStub ( DelegateBase *dst, const DelegateBase * src , CALLBACKMODE mode)
template<typename T >
static Int   UtilityStub ( DelegateBase *dst, const DelegateBase * src , CALLBACKMODE mode)
template<typename REFERENCE >
static Int   ReferenceUtilityStub ( DelegateBase *dst, const DelegateBase * src , CALLBACKMODE mode)

Protected Attributes

void *  _storage [5]
void *  _objectPtr
void(*  _stubPtr )()
Callback   _callback

Member Typedef Documentation

◆  Callback

using Callback = Int (*)( DelegateBase * dst, const DelegateBase * src , CALLBACKMODE mode)
protected

Member Enumeration Documentation

◆  CALLBACKMODE

enum CALLBACKMODE
strong protected
Enumerator
ALLOC 

Allocates memory for an object.

DESTRUCT_AND_RELEASE 

Destructs the object to which dst points and releases the memory.

COPY 

Copies the object from src to dst and returns the size on success (0 on failure).

MOVE_AND_DESTRUCT 

Moves the object from src to dst and returns the size (only used for internal storage, cannot fail).

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

◆  DelegateBase() [1/5]

DelegateBase ( )

◆  ~DelegateBase()

~ DelegateBase ( )

◆  DelegateBase() [2/5]

DelegateBase ( void *  objectPtr ,
STUBPTR  stubPtr ,
Callback   callback  
)

Constructs a delegate using object, stub and utility callback pointer.

Template Parameters
STUBPTR The stub pointer type.
参数
[in] objectPtr Self pointer of the object. Might be nullptr if the method has been inlined into the stub.
[in] stubPtr Stub method pointer (which forward the call to the callable).
[in] callback Utility callback which handles copy, move and destruction of the object. Nullptr for a static function.

◆  DelegateBase() [3/5]

DelegateBase ( FN &&  fn ,
STUBPTR  stub ,
Callback   callback  
)

Assign when T is not a Delegate , but a function pointer, ptmf or a PTMFWrapper<OBJECT*, RESULT (OBJECT::*)(ARGS...)>.

◆  DelegateBase() [4/5]

DelegateBase ( const DelegateBase )
delete

◆  DelegateBase() [5/5]

DelegateBase ( DelegateBase &&  src )

成员函数文档编制

◆  MAXON_ENUM_ORDERED_LIST_CLASS()

enum maxon::DelegateBase::CALLBACKMODE MAXON_ENUM_ORDERED_LIST_CLASS ( CALLBACKMODE   )
protected

◆  MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( DelegateBase   )

◆  Reset()

void Reset ( )

◆  CopyFrom() [1/3]

ResultMem CopyFrom ( const DelegateBase src )
参数
[in] src Source delegate.
返回
OK on success.

◆  CopyFrom() [2/3]

ResultMem CopyFrom ( FN &&  f ,
STUBPTR  stub ,
Callback   callback  
)

Assign when T is not a Delegate , but a function pointer, ptmf or a PTMFWrapper<OBJECT*, RESULT (OBJECT::*)(ARGS...)>.

◆  CopyFrom() [3/3]

ResultMem CopyFrom ( OBJ &&  object ,
STUBPTR  stub  
)

Copies or moves #object into the Delegate and sets #stub as the handler for delegate calls. #stub will receive a pointer to the object held by the Delegate in its first parameter.

参数
[in] object The object to move or copy.
[in] stub The call handler.
返回
OK on success.

◆  IsEmpty()

Bool IsEmpty ( ) const

◆  IsPopulated()

Bool IsPopulated ( ) const

◆  IsStaticFunctionPointer()

Bool IsStaticFunctionPointer ( ) const

◆  GetStaticFunctionPointer()

FUNCTIONPTR GetStaticFunctionPointer ( ) const

◆  GetStubPointer()

STUBPTR GetStubPointer ( ) const

◆  GetReferenceUtilityStub() [1/2]

static Callback GetReferenceUtilityStub ( void *  )
static protected

◆  GetReferenceUtilityStub() [2/2]

static Callback GetReferenceUtilityStub ( PointerHandler )
static protected

◆  PTMFUtilityStub()

static Int PTMFUtilityStub ( DelegateBase dst ,
const DelegateBase src ,
CALLBACKMODE   mode  
)
static protected

A dummy stub for inlined PTMF which does nothing.

◆  UtilityStub()

Int UtilityStub ( DelegateBase dst ,
const DelegateBase src ,
CALLBACKMODE   mode  
)
static protected

Destructs, copies or moves an object with operator ()().

◆  ReferenceUtilityStub()

static Int ReferenceUtilityStub ( DelegateBase dst ,
const DelegateBase src ,
CALLBACKMODE   mode  
)
static protected

Destructs, copies or moves a reference with operator ()(). This treats _storage[0] as if it was not just a pointer, but a REFERENCE.

Member Data Documentation

◆  _storage

void* _storage[5] protected

◆  _objectPtr

void* _objectPtr protected

◆  _stubPtr

void(* _stubPtr() protected

◆  _callback

Callback _callback
protected