6#ifndef _ZFI_ZFPropertyUserRegister_h_
7#define _ZFI_ZFPropertyUserRegister_h_
19 ,
ZF_IN const void *propertyValueOld
31 typedef void (*DeleteCallback)(
ZF_IN void *v);
33 DeleteCallback deleteCallback;
38 ,
ZF_IN DeleteCallback deleteCallback
43 virtual void objectOnDealloc(
void) {
45 this->deleteCallback(this->v);
47 zfsuper::objectOnDealloc();
52template<
typename T_Type>
55 static void _deleteCallback(
ZF_IN void *p) {
56 T_Type *t = (T_Type *)p;
65 ,
ZF_IN T_Type
const &v
68 const ZFProperty *
property = method->ownerProperty();
70 property = method->ownerClass()->propertyForName(method->methodName());
73 key += method->methodName();
74 _ZFP_I_PropUR *holder = ownerObj->objectTag(key);
76 zfauto oldValue = holder ? holder->retainValueHolder :
zfnull;
77 ownerObj->objectTag(key, _ZFP_I_PropUR::create(
80 , v ? v->toObject() :
zfnull
90 const ZFProperty *
property = method->ownerProperty();
92 property = method->ownerClass()->propertyForName(method->methodName());
95 key += method->methodName();
96 _ZFP_I_PropUR *holder = ownerObj->objectTag(key);
99 if(property->callbackUserRegisterInitValueSetup) {
100 property->callbackUserRegisterInitValueSetup(property, (
void *)&tmp);
102 zfauto holderTmp = _ZFP_I_PropUR::create(
107 ownerObj->objectTag(key, holderTmp);
111 return *(T_Type *)holder->v;
119 key +=
property->propertyName();
120 return (ownerObj->objectTag(key) !=
zfnull);
133 if(property->callbackUserRegisterInitValueSetup) {
134 property->callbackUserRegisterInitValueSetup(property, (
void *)&tmp);
136 if(outInitValue !=
zfnull) {
139 T_Type cur =
getterInvoker(property->getterMethod(), ownerObj);
140 T_Type initValueTmp = tmp;
141 if(cur == initValueTmp) {
148 return (cur->toObject()->objectCompare(initValueTmp->toObject()) ==
ZFCompareEqual);
161 key +=
property->propertyName();
162 ownerObj->objectTagRemove(key);
168template<
typename T_Type>
171 static void _deleteCallback(
ZF_IN void *p) {
172 T_Type *t = (T_Type *)p;
180 ,
ZF_IN T_Type
const &v
183 const ZFProperty *
property = method->ownerProperty();
185 property = method->ownerClass()->propertyForName(method->methodName());
188 key += method->methodName();
189 _ZFP_I_PropUR *holder = ownerObj->objectTag(key);
191 T_Type oldValue = holder ? (*(T_Type *)holder->v) : T_Type();
192 ownerObj->objectTag(key, _ZFP_I_PropUR::create(
204 const ZFProperty *
property = method->ownerProperty();
206 property = method->ownerClass()->propertyForName(method->methodName());
209 key += method->methodName();
210 _ZFP_I_PropUR *holder = ownerObj->objectTag(key);
212 T_Type tmp = T_Type();
213 if(property->callbackUserRegisterInitValueSetup) {
214 property->callbackUserRegisterInitValueSetup(property, (
void *)&tmp);
216 zfauto holderTmp = _ZFP_I_PropUR::create(
220 ownerObj->objectTag(key, holderTmp);
224 return *(T_Type *)holder->v;
232 key +=
property->propertyName();
233 return (ownerObj->objectTag(key) !=
zfnull);
245 T_Type tmp = T_Type();
246 if(property->callbackUserRegisterInitValueSetup) {
247 property->callbackUserRegisterInitValueSetup(property, (
void *)&tmp);
249 if(outInitValue !=
zfnull) {
252 return (
getterInvoker(property->getterMethod(), ownerObj) == tmp);
264 key +=
property->propertyName();
265 ownerObj->objectTagRemove(key);
270#define _ZFP_ZFPropertyUserRegister_PropInit_Retain(registerSig, Type, InitValueOrEmpty) \
271 zfclassNotPOD _ZFP_PropURInit_##registerSig { \
274 ZF_IN const ZFProperty *property \
275 , ZF_IN_OUT void *p \
277 *(zfauto *)p = zfauto(InitValueOrEmpty); \
280#define _ZFP_ZFPropertyUserRegister_PropInit_Assign(registerSig, Type, InitValueOrEmpty) \
281 zfclassNotPOD _ZFP_PropURInit_##registerSig { \
284 ZF_IN const ZFProperty *property \
285 , ZF_IN_OUT void *p \
287 typedef Type T_Type; \
288 T_Type *valueTmp = zfpoolNew(T_Type, InitValueOrEmpty); \
289 *(T_Type *)p = *valueTmp; \
290 zfpoolDelete(valueTmp); \
294#define _ZFP_ZFPropertyUserRegister_ParamExpand_Retain( \
297 Type, propertyNameString, \
298 ZFTypeId_noneOrType, \
299 setterMethod, getterMethod, \
300 propertyClassOfRetainProperty \
301 , Func_ZFPropertyCallbackIsValueAccessed \
302 , Func_ZFPropertyCallbackIsInitValue \
303 , Func_ZFPropertyCallbackValueReset \
312 , propertyNameString \
314 , ZFTypeId_noneOrType \
317 , propertyClassOfRetainProperty \
318 , Func_ZFPropertyCallbackIsValueAccessed \
319 , Func_ZFPropertyCallbackIsInitValue \
320 , Func_ZFPropertyCallbackValueReset \
321 , _ZFP_PropURInit_##registerSig::I \
326#define _ZFP_ZFPropertyUserRegister_ParamExpand_Assign( \
329 Type, propertyNameString, \
330 ZFTypeId_noneOrType, \
333 propertyClassOfRetainProperty \
334 , Func_ZFPropertyCallbackIsValueAccessed \
335 , Func_ZFPropertyCallbackIsInitValue \
336 , Func_ZFPropertyCallbackValueReset \
345 , propertyNameString \
347 , ZFTypeId_noneOrType \
350 , propertyClassOfRetainProperty \
351 , Func_ZFPropertyCallbackIsValueAccessed \
352 , Func_ZFPropertyCallbackIsInitValue \
353 , Func_ZFPropertyCallbackValueReset \
354 , _ZFP_PropURInit_##registerSig::I \
361#define _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
362 Type, propertyNameString, InitValueOrEmpty, \
363 SetterAccessType, GetterAccessType, \
365 ZFTypeId_noneOrType, \
366 propertyClassOfRetainProperty \
367 , Func_ZFPropertySetterInvoker \
368 , Func_ZFPropertyGetterInvoker \
369 , Func_ZFPropertyCallbackIsValueAccessed \
370 , Func_ZFPropertyCallbackIsInitValue \
371 , Func_ZFPropertyCallbackValueReset \
373 const ZFProperty *resultProperty = zfnull; \
375 ZFCoreMutexLocker(); \
376 const ZFClass *_ownerClass = ownerClass; \
377 zfstring _propertyName(propertyNameString); \
379 ZFMethodUserRegisterDetail_1(setterMethod, { \
380 Func_ZFPropertySetterInvoker(invokerMethod, invokerObject, value); \
381 }, _ownerClass, SetterAccessType, ZFMethodTypeVirtual, \
382 void, _propertyName, \
383 ZFMP_IN(Type const &, value)); \
384 ZFMethodUserRegisterDetail_0(getterMethod, { \
385 return Func_ZFPropertyGetterInvoker(invokerMethod, invokerObject); \
386 }, _ownerClass, GetterAccessType, ZFMethodTypeVirtual, \
387 Type const &, _propertyName); \
388 _ZFP_ZFPropertyUserRegister_PropInit_##RetainOrAssign(_, Type, InitValueOrEmpty) \
389 resultProperty = ZFProperty::_ZFP_ZFPropertyRegister _ZFP_ZFPropertyUserRegister_ParamExpand_##RetainOrAssign( \
391 Type, _propertyName, \
392 ZFTypeId_noneOrType, \
393 setterMethod, getterMethod, \
394 propertyClassOfRetainProperty \
395 , Func_ZFPropertyCallbackIsValueAccessed \
396 , Func_ZFPropertyCallbackIsInitValue \
397 , Func_ZFPropertyCallbackValueReset \
400 ZFUNUSED(resultProperty)
402#define _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
403 Type, propertyNameSig, InitValueOrEmpty, \
404 SetterAccessType, GetterAccessType, \
406 ZFTypeId_noneOrType, \
407 propertyClassOfRetainProperty \
408 , Func_ZFPropertySetterInvoker \
409 , Func_ZFPropertyGetterInvoker \
410 , Func_ZFPropertyCallbackIsValueAccessed \
411 , Func_ZFPropertyCallbackIsInitValue \
412 , Func_ZFPropertyCallbackValueReset \
414 zfclassNotPOD _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig { \
416 static const ZFMethod *S(void) { \
417 ZFMethodUserRegisterDetail_1(setterMethod, { \
418 Func_ZFPropertySetterInvoker(invokerMethod, invokerObject, value); \
419 }, ownerClassSig::ClassData(), SetterAccessType, ZFMethodTypeVirtual, \
420 void, zftext(#propertyNameSig), \
421 ZFMP_IN(Type const &, value)); \
422 return setterMethod; \
424 static const ZFMethod *G(void) { \
425 ZFMethodUserRegisterDetail_0(getterMethod, { \
426 return Func_ZFPropertyGetterInvoker(invokerMethod, invokerObject); \
427 }, ownerClassSig::ClassData(), GetterAccessType, ZFMethodTypeVirtual, \
428 Type const &, zftext(#propertyNameSig)); \
429 return getterMethod; \
432 _ZFP_ZFPropertyUserRegister_PropInit_##RetainOrAssign(ownerClassSig##_##propertyNameSig, Type, InitValueOrEmpty) \
433 static _ZFP_ZFPropertyRegisterHolder _ZFP_PropURH_##ownerClassSig##_##propertyNameSig \
434 _ZFP_ZFPropertyUserRegister_ParamExpand_##RetainOrAssign( \
435 ownerClassSig##_##propertyNameSig, ownerClassSig::ClassData(), \
436 Type, zftext(#propertyNameSig), \
437 ZFTypeId_noneOrType, \
438 _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig::S(), \
439 _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig::G(), \
440 propertyClassOfRetainProperty \
441 , Func_ZFPropertyCallbackIsValueAccessed \
442 , Func_ZFPropertyCallbackIsInitValue \
443 , Func_ZFPropertyCallbackValueReset \
545#define ZFPropertyUserRegisterRetain(resultProperty, ownerClass, \
546 Type, propertyNameString, InitValueOrEmpty, \
547 SetterAccessType, GetterAccessType \
549 ZFPropertyUserRegisterRetainDetail(resultProperty, ownerClass, \
550 Type, propertyNameString, InitValueOrEmpty, \
551 SetterAccessType, GetterAccessType \
552 , ZFPropertyUserRegisterDefaultImplRetain<Type>::setterInvoker \
553 , ZFPropertyUserRegisterDefaultImplRetain<Type>::getterInvoker \
554 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsValueAccessed \
555 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsInitValue \
556 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackValueReset \
559#define ZFPropertyUserRegisterRetainDetail(resultProperty, ownerClass, \
560 Type, propertyNameString, InitValueOrEmpty, \
561 SetterAccessType, GetterAccessType \
562 , Func_ZFPropertySetterInvoker \
563 , Func_ZFPropertyGetterInvoker \
564 , Func_ZFPropertyCallbackIsValueAccessed \
565 , Func_ZFPropertyCallbackIsInitValue \
566 , Func_ZFPropertyCallbackValueReset \
568 _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
569 Type, propertyNameString, InitValueOrEmpty, \
570 SetterAccessType, GetterAccessType, \
572 zftTraits<Type>::TrType::ClassData()->classNameFull(), \
573 zftTraits<Type>::TrType::ClassData() \
574 , Func_ZFPropertySetterInvoker \
575 , Func_ZFPropertyGetterInvoker \
576 , Func_ZFPropertyCallbackIsValueAccessed \
577 , Func_ZFPropertyCallbackIsInitValue \
578 , Func_ZFPropertyCallbackValueReset \
581#define ZFPROPERTY_USER_REGISTER_RETAIN(ownerClassSig, \
582 Type, propertyNameSig, InitValueOrEmpty, \
583 SetterAccessType, GetterAccessType \
585 ZFPROPERTY_USER_REGISTER_RETAIN_DETAIL(ownerClassSig, \
586 Type, propertyNameSig, InitValueOrEmpty, \
587 SetterAccessType, GetterAccessType \
588 , ZFPropertyUserRegisterDefaultImplRetain<Type>::setterInvoker \
589 , ZFPropertyUserRegisterDefaultImplRetain<Type>::getterInvoker \
590 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsValueAccessed \
591 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsInitValue \
592 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackValueReset \
595#define ZFPROPERTY_USER_REGISTER_RETAIN_DETAIL(ownerClassSig, \
596 Type, propertyNameSig, InitValueOrEmpty, \
597 SetterAccessType, GetterAccessType \
598 , Func_ZFPropertySetterInvoker \
599 , Func_ZFPropertyGetterInvoker \
600 , Func_ZFPropertyCallbackIsValueAccessed \
601 , Func_ZFPropertyCallbackIsInitValue \
602 , Func_ZFPropertyCallbackValueReset \
604 _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
605 Type, propertyNameSig, InitValueOrEmpty, \
606 SetterAccessType, GetterAccessType, \
608 zftTraits<Type>::TrType::ClassData()->classNameFull(), \
609 zftTraits<Type>::TrType::ClassData() \
610 , Func_ZFPropertySetterInvoker \
611 , Func_ZFPropertyGetterInvoker \
612 , Func_ZFPropertyCallbackIsValueAccessed \
613 , Func_ZFPropertyCallbackIsInitValue \
614 , Func_ZFPropertyCallbackValueReset \
619#define ZFPropertyUserRegisterAssign(resultProperty, ownerClass, \
620 Type, propertyNameString, InitValueOrEmpty, \
621 SetterAccessType, GetterAccessType \
623 ZFPropertyUserRegisterAssignDetail(resultProperty, ownerClass, \
624 Type, propertyNameString, InitValueOrEmpty, \
625 SetterAccessType, GetterAccessType \
626 , ZFPropertyUserRegisterDefaultImplAssign<Type>::setterInvoker \
627 , ZFPropertyUserRegisterDefaultImplAssign<Type>::getterInvoker \
628 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsValueAccessed \
629 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsInitValue \
630 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackValueReset \
633#define ZFPropertyUserRegisterAssignDetail(resultProperty, ownerClass, \
634 Type, propertyNameString, InitValueOrEmpty, \
635 SetterAccessType, GetterAccessType \
636 , Func_ZFPropertySetterInvoker \
637 , Func_ZFPropertyGetterInvoker \
638 , Func_ZFPropertyCallbackIsValueAccessed \
639 , Func_ZFPropertyCallbackIsInitValue \
640 , Func_ZFPropertyCallbackValueReset \
642 _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
643 Type, propertyNameString, InitValueOrEmpty, \
644 SetterAccessType, GetterAccessType, \
646 ZFTypeId<zftTraits<Type>::TrNoRef>::TypeId(), \
648 , Func_ZFPropertySetterInvoker \
649 , Func_ZFPropertyGetterInvoker \
650 , Func_ZFPropertyCallbackIsValueAccessed \
651 , Func_ZFPropertyCallbackIsInitValue \
652 , Func_ZFPropertyCallbackValueReset \
655#define ZFPROPERTY_USER_REGISTER_ASSIGN(ownerClassSig, \
656 Type, propertyNameSig, InitValueOrEmpty, \
657 SetterAccessType, GetterAccessType \
659 ZFPROPERTY_USER_REGISTER_ASSIGN_DETAIL(ownerClassSig, \
660 Type, propertyNameSig, InitValueOrEmpty, \
661 SetterAccessType, GetterAccessType \
662 , ZFPropertyUserRegisterDefaultImplAssign<Type>::setterInvoker \
663 , ZFPropertyUserRegisterDefaultImplAssign<Type>::getterInvoker \
664 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsValueAccessed \
665 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsInitValue \
666 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackValueReset \
669#define ZFPROPERTY_USER_REGISTER_ASSIGN_DETAIL(ownerClassSig, \
670 Type, propertyNameSig, InitValueOrEmpty, \
671 SetterAccessType, GetterAccessType \
672 , Func_ZFPropertySetterInvoker \
673 , Func_ZFPropertyGetterInvoker \
674 , Func_ZFPropertyCallbackIsValueAccessed \
675 , Func_ZFPropertyCallbackIsInitValue \
676 , Func_ZFPropertyCallbackValueReset \
678 _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
679 Type, propertyNameSig, InitValueOrEmpty, \
680 SetterAccessType, GetterAccessType, \
682 ZFTypeId<zftTraits<Type>::TrNoRef>::TypeId(), \
684 , Func_ZFPropertySetterInvoker \
685 , Func_ZFPropertyGetterInvoker \
686 , Func_ZFPropertyCallbackIsValueAccessed \
687 , Func_ZFPropertyCallbackIsInitValue \
688 , Func_ZFPropertyCallbackValueReset \
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define ZFCoreMutexLocker()
util method to lock current block
Definition ZFCoreMutex.h:95
#define ZF_OUT_OPT
dummy macro that shows the param used as optional output
Definition ZFCoreTypeDef_ClassType.h:208
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:196
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:200
#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
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
#define zffalse
bool false type
Definition ZFCoreTypeDef_CoreType.h:111
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
@ ZFCompareEqual
Definition ZFCoreTypeDef_OtherType.h:31
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define zfpoolDelete(obj)
see zfnew
Definition ZFMemPool.h:81
#define zfpoolNew(T_Type,...)
see zfnew
Definition ZFMemPool.h:80
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
smart pointer for ZFObject
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:122
#define zfobjRetain(obj)
retain an object, see ZFObject
Definition ZFObjectRetain.h:125
#define zfobjRelease(obj)
release an object, see ZFObject
Definition ZFObjectRetain.h:145
void ZFPropertyUserUnregister(const ZFProperty *zfproperty)
see ZFPropertyUserRegisterRetain
void ZFPropertyUserRegisterNotifyReset(ZFObject *ownerObject, const ZFProperty *property)
see ZFPropertyUserRegisterRetain
void ZFPropertyUserRegisterNotifyUpdate(ZFObject *ownerObject, const ZFProperty *property, const void *propertyValueOld)
see ZFPropertyUserRegisterRetain, ZFObject::objectPropertyValueOnUpdate
reflectable method for ZFObject
Definition ZFMethod.h:252
base class of all objects
Definition ZFObjectCore.h:195
info for a property for ZFObject, see ZFPROPERTY_RETAIN for more info
Definition ZFProperty.h:27
default impl for ZFPropertyUserRegisterAssign
Definition ZFPropertyUserRegister.h:169
static void setterInvoker(const ZFMethod *method, ZFObject *ownerObj, T_Type const &v)
default impl for ZFPropertyUserRegisterAssign
Definition ZFPropertyUserRegister.h:177
static zfbool callbackIsInitValue(const ZFProperty *property, zfany const &ownerObj, zfauto *outInitValue)
default impl for ZFPropertyUserRegisterAssign
Definition ZFPropertyUserRegister.h:236
static void callbackValueReset(const ZFProperty *property, zfany const &ownerObj)
default impl for ZFPropertyUserRegisterRetain
Definition ZFPropertyUserRegister.h:255
static T_Type const & getterInvoker(const ZFMethod *method, ZFObject *ownerObj)
default impl for ZFPropertyUserRegisterAssign
Definition ZFPropertyUserRegister.h:199
static zfbool callbackIsValueAccessed(const ZFProperty *property, zfany const &ownerObj)
default impl for ZFPropertyUserRegisterAssign
Definition ZFPropertyUserRegister.h:227
default impl for ZFPropertyUserRegisterRetain
Definition ZFPropertyUserRegister.h:53
static void callbackValueReset(const ZFProperty *property, zfany const &ownerObj)
default impl for ZFPropertyUserRegisterRetain
Definition ZFPropertyUserRegister.h:152
static void setterInvoker(const ZFMethod *method, ZFObject *ownerObj, T_Type const &v)
default impl for ZFPropertyUserRegisterRetain
Definition ZFPropertyUserRegister.h:62
static T_Type const & getterInvoker(const ZFMethod *method, ZFObject *ownerObj)
default impl for ZFPropertyUserRegisterRetain
Definition ZFPropertyUserRegister.h:85
static zfbool callbackIsValueAccessed(const ZFProperty *property, zfany const &ownerObj)
default impl for ZFPropertyUserRegisterRetain
Definition ZFPropertyUserRegister.h:114
static zfbool callbackIsInitValue(const ZFProperty *property, zfany const &ownerObj, zfauto *outInitValue)
default impl for ZFPropertyUserRegisterRetain
Definition ZFPropertyUserRegister.h:123
static zfbool ValueStore(zfauto &obj, T_Type const &v)
store the value to wrapper object
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