6#ifndef _ZFI_ZFObjectCore_h_
7#define _ZFI_ZFObjectCore_h_
24#define ZFTOKEN_ZFObjectInfoLeft "<"
29#define ZFTOKEN_ZFObjectInfoRight ">"
43#define ZFTOKEN_ZFObjectInstanceStateOnInit "OnInit"
45#define ZFTOKEN_ZFObjectInstanceStateOnInitFinish "OnInitFinish"
47#define ZFTOKEN_ZFObjectInstanceStateIdle "Idle"
49#define ZFTOKEN_ZFObjectInstanceStateOnDeallocPrepare "OnDeallocPrepare"
51#define ZFTOKEN_ZFObjectInstanceStateOnDealloc "OnDealloc"
56 static const ZFClass *ClassData(
void) {
59 static void _ZFP_Obj_initImpl(
ZFClass *cls) {}
62template<
typename T_ZFObject,
int val
id>
210 _ZFP_ZFOBJECT_DECLARE(ZFObject, _ZFP_Obj_Base)
211 _ZFP_ZFOBJECT_DECLARE_OBJECT(ZFObject, _ZFP_Obj_Base, _ZFP_Obj_Base)
215 enum {_ZFP_ZFObjectCanAllocPublic = 1};
216 static void _ZFP_Obj_initImpl(
ZFClass *cls) {}
218 static inline void _ZFP_zfAllocCacheRelease(
ZF_IN ZFObject *_obj) {}
219 virtual inline void _ZFP_ObjI_onInitIvk(
void) {}
220 virtual inline void _ZFP_ObjI_onDeallocIvk(
void) {}
280 return _objectRetainCount;
283 zffinal _ZFP_I_zfweak *_ZFP_ZFObject_weakHolder(
void);
287 ret += this->
classData()->classNameFull();
320 this->objectInfoImpl(ret);
384 return this->objectCompareImpl(anotherObj);
387 return this->objectCompareValueImpl(anotherObj);
419 ,
ZF_IN ZFObject *param0
469 ,
ZF_IN ZFObject *tag
584 ZF_IN ZFObject *customSender
597 ZF_IN ZFObject *customSender
643 this->
observerAdd(eventId, observer, observerLevel);
649 impl.execute(
ZFArgs().sender(
this));
676 void *_ZFP_ZFObjectMutexImpl(
void);
677 void _ZFP_ZFObjectLock(
void);
678 void _ZFP_ZFObjectUnlock(
void);
679 zfbool _ZFP_ZFObjectTryLock(
void);
681 void _ZFP_ZFObject_objectOnInit(
void);
682 void _ZFP_ZFObject_objectOnInitFinish(
void);
683 void _ZFP_ZFObject_objectOnInitFromCache(
void);
684 void _ZFP_ZFObjectCheckRelease(
void);
779 ++_objectRetainCount;
788 --_objectRetainCount;
818 zffinal inline void _ZFP_ZFObject_objectPropertyValueOnUpdate(
820 ,
ZF_IN const void *oldValue
824 zffinal inline void _ZFP_ZFObject_objectPropertyValueOnReset(
827 this->objectPropertyValueOnReset(property);
840 ,
ZF_IN const void *oldValue
849 zffinal void _ZFP_ZFObject_zfAllocCacheRelease(
ZF_IN _ZFP_zfAllocCacheReleaseCallback callback);
850 zffinal _ZFP_zfAllocCacheReleaseCallback _ZFP_ZFObject_zfAllocCacheRelease(
void);
851 zffinal ZFObject *_ZFP_ZFObject_ZFImplementDynamicOwnerOrSelf(
void);
852 zffinal ZFObject *_ZFP_ZFObject_ZFImplementDynamicHolder(
ZF_IN const ZFClass *clsToImplement);
858 template<
typename T_ZFObject,
int val
id>
860 friend void _ZFP_zfRetainAction(
ZF_IN ZFObject *obj);
861 friend void _ZFP_zfReleaseAction(
ZF_IN ZFObject *obj);
863 const ZFClass *_ZFP_ZFObject_classDynamic;
865 _ZFP_ZFObjectPrivate *d;
866 zfuint _objectRetainCount;
871 : _ZFP_ZFObject_classDynamic(
zfnull)
873 , _objectRetainCount(1)
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define ZFCoreAssertWithMessageTrim(exp, fmt,...)
see ZFCoreAssertWithMessage
Definition ZFCoreLog_CommonLog.h:81
zfbool zfsFromPointerT(zfstring &s, const void *p)
convert pointer value to string
Definition ZFCoreStringConvert.h:327
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:192
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_OUT
dummy macro that shows the param used as required output
Definition ZFCoreTypeDef_ClassType.h:188
#define zfclassNotPOD
shows the class is not a POD type, you should not memset it or declare it in stack or copy value by c...
Definition ZFCoreTypeDef_ClassType.h:48
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
_zft_zfidentity zfidentity
identity type, ensured at least 32 bit, ensured unsigned
Definition ZFCoreTypeDef_CoreType.h:225
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
_ZFT_t_zfuint zfuint
same as unsigned int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:169
ZFCompareResult
compare result of two ZFObjects
Definition ZFCoreTypeDef_OtherType.h:28
@ ZFCompareUncomparable
Definition ZFCoreTypeDef_OtherType.h:29
@ ZFCompareEqual
Definition ZFCoreTypeDef_OtherType.h:31
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
zfidentity zfidentityCalc(T_Type const &v)
calculate identity from POD object
Definition ZFIdentityUtil.h:92
ZFLevel
level for logic which depends on order
Definition ZFLevel.h:17
@ ZFLevelAppNormal
app
Definition ZFLevel.h:26
reflectable method definination for ZFFramework
#define ZFMP_DEF()
mark the object as default param
Definition ZFMethodGenericInvoker.h:30
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
zfany ZFObjectCast(const ZFClass *cls, const zfany &obj)
generic version of object cast
#define ZFTOKEN_ZFObjectInfoLeft
left bracket when output ZFObject's info
Definition ZFObjectCore.h:24
ZFObjectInstanceState
object instance state for ZFObject
Definition ZFObjectCore.h:35
@ ZFObjectInstanceStateOnInit
object is under ZFObject::objectOnInit
Definition ZFObjectCore.h:36
@ ZFObjectInstanceStateIdle
object is constructed successfully
Definition ZFObjectCore.h:38
@ ZFObjectInstanceStateOnDealloc
object is under ZFObject::objectOnDealloc
Definition ZFObjectCore.h:40
@ ZFObjectInstanceStateOnInitFinish
object is under ZFObject::objectOnInitFinish
Definition ZFObjectCore.h:37
@ ZFObjectInstanceStateOnDeallocPrepare
object is under ZFObject::objectOnDeallocPrepare
Definition ZFObjectCore.h:39
#define ZFTOKEN_ZFObjectInfoRight
right bracket when output ZFObject's info
Definition ZFObjectCore.h:29
observer types for ZFObject
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
property for ZFObject type
listener data used by ZFListener
Definition ZFArgs.h:20
ZFObject's class info.
Definition ZFClass.h:67
light weight array
Definition ZFCoreArray.h:331
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
base class of all objects
Definition ZFObjectCore.h:209
ZFCompareResult objectCompareValue(ZFObject *anotherObj)
explicitly compare object by logical value, see objectCompare
virtual zfbool invokeT(zfauto &ret, zfstring *errorHint, const zfstring &methodName, ZFObject *param0=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF))
util method to perform ZFDI_invoke, do nothing if fail
void observerRemoveAll(zfidentity eventId)
see observerNotify
virtual zfauto invokeDetail(const zfstring &methodName, const ZFCoreArray< zfauto > ¶ms, zfbool *success=zft_zfnull, zfstring *errorHint=zft_zfnull)
util method to perform ZFDI_invoke, do nothing if fail
virtual void objectOnInit(void)
override this to init your object
void observerNotifyWithSender(ZFObject *customSender, zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
see observerNotify
virtual ZFCompareResult objectCompareValueImpl(ZFObject *anotherObj)
see objectCompareValue
Definition ZFObjectCore.h:400
virtual zfbool objectIsInternal(void)
whether this object is internal object or its class is ZFClass::classIsInternal
void observerAdd(zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
see observerNotify
virtual void observerOnEvent(const ZFArgs &zfargs)
notified when observerNotify
Definition ZFObjectCore.h:672
void observerNotifyReversely(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
see observerNotify
zfidentity objectHash(void)
get hash of this object
virtual void objectOnRetain(void)
called to retain object
Definition ZFObjectCore.h:776
void observerAddForOnce(zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
see observerNotify
zfauto objectTagRemoveAndGet(const zfstring &key)
remove tag, return removed tag or null if not exist
void objectInfoOfInstanceT(zfstring &ret)
see objectInfoOfInstance
Definition ZFObjectCore.h:286
virtual zfidentity objectHashImpl(void)
see objectHash
Definition ZFObjectCore.h:392
virtual void observerOnRemove(zfidentity eventId)
called when remove last observer
zfstring objectInfo(void)
return object info
Definition ZFObjectCore.h:314
virtual void objectOnRelease(void)
called to release object
Definition ZFObjectCore.h:787
void objectTag(const zfstring &key, ZFObject *tag)
used to hold a object for app's use, auto retained
void onDealloc(const ZFListener &impl)
util for script to achieve chained call
Definition ZFObjectCore.h:654
zfindex objectRetainCount(void)
return the object's retain count
Definition ZFObjectCore.h:279
zfbool objectInstanceStateCheck(ZFObjectInstanceState state)
object instance's state
virtual void objectInfoImplAppend(zfstring &ret)
see objectInfo
Definition ZFObjectCore.h:331
ZFObserver & observerHolder(void)
access the internal observer holder
ZFCompareResult objectCompare(ZFObject *anotherObj)
compare with anotherObj
void objectTagRemove(const zfstring &key)
remove tag, same as set tag to null
Definition ZFObjectCore.h:485
void onInit(const ZFListener &impl)
util for script to achieve chained call
Definition ZFObjectCore.h:648
virtual void objectOnDealloc(void)
override this to destroy your object
virtual const ZFClass * classData(void)
get instance's class info
Definition ZFObjectCore.h:210
virtual zfbool objectIsInternalPrivate(void)
whether this object is internal private object or its class is ZFClass::classIsInternalPrivate
zfany objectTag(const zfstring &key)
see objectTag
void objectTagGetAllKeyValue(ZFCoreArray< zfstring > &allKey, ZFCoreArray< zfauto > &allValue)
get all key value
virtual void observerOnAdd(zfidentity eventId)
called when add first observer
virtual zfauto invoke(const zfstring &methodName, ZFObject *param0, ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF))
util method to perform ZFDI_invoke, do nothing if fail
void on(const zfstring &eventName, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
util to observerAdd
zfbool objectTagExist(void)
see objectTag, true if this object has tag, and tag can be checked by objectTagGetAllKeyValue
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
Definition ZFObjectCore.h:758
zfbool objectInitRunning(void)
util method to check whether ZFObjectInstanceStateOnInit or ZFObjectInstanceStateOnInitFinish running
virtual void objectOnInitFinish(void)
called after objectOnInit, safe to call virtual functions here
Definition ZFObjectCore.h:749
void objectTagRemoveAll(void)
remove all tag
virtual zfauto invoke(const zfstring &methodName)
util method to perform ZFDI_invoke, do nothing if fail
virtual void objectPropertyValueOnUpdate(const ZFProperty *property, const void *oldValue)
see E_ObjectPropertyValueOnUpdate
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
Definition ZFObjectCore.h:325
virtual void objectPropertyValueOnReset(const ZFProperty *property)
see E_ObjectPropertyValueOnReset
void observerRemoveAll(void)
see observerNotify
void on(zfidentity eventId, const ZFListener &observer, ZFLevel observerLevel=ZFLevelAppNormal)
util to observerAdd
Definition ZFObjectCore.h:638
zfbool objectDeallocRunning(void)
util method to check whether ZFObjectInstanceStateOnDeallocPrepare or ZFObjectInstanceStateOnDealloc ...
static zfidentity E_ObjectBeforeDealloc(void)
see ZFObject::observerNotify
void observerNotifyReverselyWithSender(ZFObject *customSender, zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
see observerNotify
zfstring objectInfoOfInstance(void)
return a short string describe the object instance
Definition ZFObjectCore.h:299
zfbool observerHasAdd(void)
true if any observer has been added
void observerNotify(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
notify the observer with eventId
void observerRemove(zfidentity eventId, const ZFListener &callback)
see observerNotify
zfbool observerHasAdd(zfidentity eventId)
true if any observer with eventId has been added
virtual ZFCompareResult objectCompareImpl(ZFObject *anotherObj)
see objectCompare
Definition ZFObjectCore.h:396
void objectInfoT(zfstring &ret)
see objectInfo
info for a property for ZFObject, see ZFPROPERTY_RETAIN for more info
Definition ZFProperty.h:28
util method to cast ZFObject types freely
Definition zfany.h:35
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
util class to cast ZFObject types freely