ZFFramework
 
Loading...
Searching...
No Matches
ZFObserver Class Reference

holder object for observer logic, see ZFObject::observerNotify More...

#include <ZFObjectObserver.h>

Public Member Functions

void observerAdd (zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
 see ZFObject::observerNotify
 
void observerAddForOnce (zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
 see ZFObject::observerNotify
 
void observerRemove (zfidentity eventId, const ZFListener &callback)
 see ZFObject::observerNotify
 
void observerRemoveAll (zfidentity eventId)
 see ZFObject::observerNotify
 
void observerRemoveAll (void)
 see ZFObject::observerNotify
 
zfbool observerHasAdd (void) const
 see ZFObject::observerNotify
 
zfbool observerHasAdd (zfidentity eventId) const
 see ZFObject::observerNotify
 
void observerNotify (zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull) const
 see ZFObject::observerNotify
 
void observerNotifyWithSender (ZFObject *customSender, zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull) const
 see ZFObject::observerNotify
 
void observerNotifyReversely (zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull) const
 see ZFObject::observerNotify
 
void observerNotifyReverselyWithSender (ZFObject *customSender, zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull) const
 see ZFObject::observerNotify
 
void on (zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
 util to observerAdd
 
void observerHasAddStateAttach (zfidentity eventId, zfuint *flag, zfuint flagBit)
 attach a state that indicate whether the observer has add, for performance usage
 
void observerHasAddStateDetach (zfidentity eventId, zfuint *flag, zfuint flagBit)
 see observerHasAddStateAttach
 
void objectInfoT (zfstring &ret) const
 see objectInfo
 
zfstring objectInfo (void) const
 return a short string describe the object
 
zfany observerOwner (void) const
 owner object of this observer holder, or null if none
 

Detailed Description

holder object for observer logic, see ZFObject::observerNotify

Member Function Documentation

◆ observerHasAddStateAttach()

void ZFObserver::observerHasAddStateAttach ( zfidentity eventId,
zfuint * flag,
zfuint flagBit )

attach a state that indicate whether the observer has add, for performance usage

notifying an observer requires much CPU to check and execute, even if no observer has ever added
to optimize this, you may attach a flag to indicate whether any observer has ever added
usage:

enum {
Flag_MyEvent0,
Flag_MyEvent1,
};
zfuint myFlag = 0;
observer.observerHasAddStateAttach(E_XXX, &myFlag, Flag_MyEvent0);
observer.observerHasAddStateAttach(E_XXX, &myFlag, Flag_MyEvent1);
if(ZFBitTest(myFlag, Flag_MyEvent0)) {
observer.observerNotify(...);
}
_ZFT_t_zfuint zfuint
same as unsigned int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:169
#define ZFBitTest(var, bit)
macro to detect whether bit is set, zftrue if any one of test bit has set
Definition ZFCoreUtilMacro.h:16

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