ZFFramework
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ZFCallback Class Reference

callback used by ZFFramework More...

#include <ZFCallback.h>

Inheritance diagram for ZFCallback:
ZFCallbackT< zftimet > ZFCallbackT< void > ZFCallbackT< T_Return, T_Param0, T_Param1, T_Param2, T_Param3, T_Param4, T_Param5, T_Param6, T_Param7, T_Dummy > ZFIOCallback ZFListener ZFInput ZFOutput

Public Member Functions

template<typename T_ReturnType >
T_ReturnType executeExact () const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 >
T_ReturnType executeExact (Type0 param0) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 , typename Type1 >
T_ReturnType executeExact (Type0 param0, Type1 param1) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 >
T_ReturnType executeExact (Type0 param0, Type1 param1, Type2 param2) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 >
T_ReturnType executeExact (Type0 param0, Type1 param1, Type2 param2, Type3 param3) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 >
T_ReturnType executeExact (Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 , typename Type5 >
T_ReturnType executeExact (Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4, Type5 param5) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 , typename Type5 , typename Type6 >
T_ReturnType executeExact (Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4, Type5 param5, Type6 param6) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
template<typename T_ReturnType , typename Type0 , typename Type1 , typename Type2 , typename Type3 , typename Type4 , typename Type5 , typename Type6 , typename Type7 >
T_ReturnType executeExact (Type0 param0, Type1 param1, Type2 param2, Type3 param3, Type4 param4, Type5 param5, Type6 param6, Type7 param7) const
 see ZFCallback, you must assign the exact return type and param types for safe
 
zfindex objectRetainCount (void) const
 get current retain count
 
void objectInfoT (zfstring &ret) const
 see objectInfo
 
zfstring objectInfo (void) const
 return object info
 
ZFCompareResult objectCompare (const ZFCallback &ref) const
 compare with another callback
 
ZFCompareResult objectCompareByInstance (const ZFCallback &ref) const
 compare callback by instance only (same callback contents not necessarily to be same instance)
 
void callbackClear (void)
 explicitly clear reference of this callback
 
void callbackId (const zfchar *callbackId)
 an unique id for the callback, used for cache logic
 
const zfcharcallbackId (void) const
 see callbackId
 
void callbackTag (const zfchar *key, ZFObject *tag)
 retain and store a autoreleased object attached to this callback, or set null to remove
 
zfany callbackTag (const zfchar *key) const
 see callbackTag
 
void callbackTagGetAllKeyValue (ZFCoreArray< zfstring > &allKey, ZFCoreArray< zfauto > &allValue) const
 see callbackTag
 
void callbackTagRemove (const zfchar *key)
 remove tag, same as set tag to null
 
zfauto callbackTagRemoveAndGet (const zfchar *key)
 remove tag, return removed tag or null if not exist
 
void callbackTagRemoveAll (void)
 see callbackTag
 
zfbool callbackValid (void) const
 return true if callback is valid
 
ZFCallbackType callbackType (void) const
 get the type of callback
 
zfany callbackOwnerObject (void) const
 get the owner object, valid only if type is class member method
 
const ZFMethodcallbackMethod (void) const
 get the method or null if not declared by ZFMethod
 
ZFFuncAddrType callbackRawFunction (void) const
 get static function, valid only if type is ZFCallbackTypeRawFunction
 
void * callbackLambdaImpl (void) const
 impl for lambda type
 
ZFFuncAddrType callbackLambdaInvoker (void) const
 impl for lambda type
 
void callbackOwnerObjectRetain (void) const
 retain owner object and auto release it after callback's retain count reduced to 0
 
void callbackOwnerObjectRelease (void) const
 manually release the owner, see callbackOwnerObjectRetain
 
void callbackSerializeCustomType (const zfchar *customType)
 see ZFTypeId_ZFCallback
 
const zfcharcallbackSerializeCustomType (void) const
 see ZFTypeId_ZFCallback
 
void callbackSerializeCustomData (const ZFSerializableData *customData)
 see ZFTypeId_ZFCallback
 
void callbackSerializeCustomData (const ZFSerializableData &customData)
 see ZFTypeId_ZFCallback
 
const ZFSerializableDatacallbackSerializeCustomData (void) const
 see ZFTypeId_ZFCallback
 
void callbackSerializeCustomDisable (zfbool disable)
 see ZFTypeId_ZFCallback
 
zfbool callbackSerializeCustomDisabled (void) const
 see ZFTypeId_ZFCallback
 
const ZFPathInfopathInfo (void) const
 used for impl to store path related info, see ZFPathInfo
 
void pathInfo (const ZFPathInfo *pathInfo)
 see pathInfo
 
void pathInfo (const zfchar *pathType, const zfchar *pathData)
 see pathInfo
 

Detailed Description

callback used by ZFFramework

a callback may be a class member or static member declared as ZFMethod, or static raw function, it's a ZFMethod pointer container in fact
use ZFCallbackForXXX to create a callback, then you may pass it as param or store it for future use
to execute callback, use executeExact similar to ZFMethod::execute, while you have no need to take care of the owner object

Warning
before execute, you must check whether the callback is valid (by callbackValid or cb != zfnull or !cb), otherwise, assert fail
while execute, similar to ZFMethod, you must explicitly assign the ReturnType and each ParamType for the template param
Note
you may also declare a child class of ZFCallback, by ZFCALLBACK_DECLARE_XXX, see ZFCALLBACK_DECLARE_BEGIN

Member Function Documentation

◆ objectCompare()

ZFCompareResult ZFCallback::objectCompare ( const ZFCallback & ref) const

compare with another callback

two callback is considered the same if all of these are same:

◆ callbackClear()

void ZFCallback::callbackClear ( void )

explicitly clear reference of this callback

useful for script with GC logic, to explicitly release reference of callback

◆ callbackId()

void ZFCallback::callbackId ( const zfchar * callbackId)

an unique id for the callback, used for cache logic

two callback with same callback id is treated as same callback, which is useful to achieve cache logic
you must ensure the callback id is unique and verbose enough to describe the callback, otherwise, leave it empty

◆ callbackTag()

void ZFCallback::callbackTag ( const zfchar * key,
ZFObject * tag )

retain and store a autoreleased object attached to this callback, or set null to remove

recommended to have "ZFCallbackTagKeyword_" as prefix for key name
usually used to store the owner object, so that it'll be released automatically when all the callback's references were deleted, you can also retain the owner by callbackOwnerObjectRetain
you can also save state for the callback as the auto released data

◆ callbackTagRemoveAll()

void ZFCallback::callbackTagRemoveAll ( void )

see callbackTag

Note
it's unsafe to remove all tag manually, which may break unrelated modules' additional logic, remove only if necessary
typically, you should remove exactly the one you have added

◆ callbackOwnerObjectRetain()

void ZFCallback::callbackOwnerObjectRetain ( void ) const

retain owner object and auto release it after callback's retain count reduced to 0

by default, owner won't be retained, you may use this method to retain owner, or use callbackTag to store owner

◆ callbackSerializeCustomType()

void ZFCallback::callbackSerializeCustomType ( const zfchar * customType)

see ZFTypeId_ZFCallback

you may set to ZFCallbackSerializeCustomTypeDisable to explicitly disable callback serialization


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