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 \
310 , propertyNameString \
312 , ZFTypeId_noneOrType \
315 , _ZFP_ZFPropertyMethodCleanup_UserReg \
316 , _ZFP_ZFPropertyMethodCleanup_UserReg \
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 \
343 , propertyNameString \
345 , ZFTypeId_noneOrType \
348 , _ZFP_ZFPropertyMethodCleanup_UserReg \
349 , _ZFP_ZFPropertyMethodCleanup_UserReg \
350 , propertyClassOfRetainProperty \
351 , Func_ZFPropertyCallbackIsValueAccessed \
352 , Func_ZFPropertyCallbackIsInitValue \
353 , Func_ZFPropertyCallbackValueReset \
354 , _ZFP_PropURInit_##registerSig::I \
362#define _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
363 Type, propertyNameString, InitValueOrEmpty, \
364 SetterAccessType, GetterAccessType, \
366 ZFTypeId_noneOrType, \
367 propertyClassOfRetainProperty \
368 , Func_ZFPropertySetterInvoker \
369 , Func_ZFPropertyGetterInvoker \
370 , Func_ZFPropertyCallbackIsValueAccessed \
371 , Func_ZFPropertyCallbackIsInitValue \
372 , Func_ZFPropertyCallbackValueReset \
374 const ZFProperty *resultProperty = zfnull; \
376 ZFCoreMutexLocker(); \
377 const ZFClass *_ownerClass = ownerClass; \
378 zfstring _propertyName(propertyNameString); \
380 ZFMethodUserRegisterDetail_1(setterMethod, { \
381 Func_ZFPropertySetterInvoker(invokerMethod, invokerObject, value); \
382 }, _ownerClass, SetterAccessType, ZFMethodTypeVirtual, \
383 void, _propertyName, \
384 ZFMP_IN(Type const &, value)); \
385 ZFMethodUserRegisterDetail_0(getterMethod, { \
386 return Func_ZFPropertyGetterInvoker(invokerMethod, invokerObject); \
387 }, _ownerClass, GetterAccessType, ZFMethodTypeVirtual, \
388 Type const &, _propertyName); \
389 _ZFP_ZFPropertyUserRegister_PropInit_##RetainOrAssign(_, Type, InitValueOrEmpty) \
390 resultProperty = _ZFP_ZFPropertyRegister _ZFP_ZFPropertyUserRegister_ParamExpand_##RetainOrAssign( \
392 Type, _propertyName, \
393 ZFTypeId_noneOrType, \
394 setterMethod, getterMethod, \
395 propertyClassOfRetainProperty \
396 , Func_ZFPropertyCallbackIsValueAccessed \
397 , Func_ZFPropertyCallbackIsInitValue \
398 , Func_ZFPropertyCallbackValueReset \
401 ZFUNUSED(resultProperty)
403#define _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
404 Type, propertyNameSig, InitValueOrEmpty, \
405 SetterAccessType, GetterAccessType, \
407 ZFTypeId_noneOrType, \
408 propertyClassOfRetainProperty \
409 , Func_ZFPropertySetterInvoker \
410 , Func_ZFPropertyGetterInvoker \
411 , Func_ZFPropertyCallbackIsValueAccessed \
412 , Func_ZFPropertyCallbackIsInitValue \
413 , Func_ZFPropertyCallbackValueReset \
415 zfclassNotPOD _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig { \
417 static const ZFMethod *S(void) { \
418 ZFMethodUserRegisterDetail_1(setterMethod, { \
419 Func_ZFPropertySetterInvoker(invokerMethod, invokerObject, value); \
420 }, ownerClassSig::ClassData(), SetterAccessType, ZFMethodTypeVirtual, \
421 void, zftext(#propertyNameSig), \
422 ZFMP_IN(Type const &, value)); \
423 return setterMethod; \
425 static const ZFMethod *G(void) { \
426 ZFMethodUserRegisterDetail_0(getterMethod, { \
427 return Func_ZFPropertyGetterInvoker(invokerMethod, invokerObject); \
428 }, ownerClassSig::ClassData(), GetterAccessType, ZFMethodTypeVirtual, \
429 Type const &, zftext(#propertyNameSig)); \
430 return getterMethod; \
433 _ZFP_ZFPropertyUserRegister_PropInit_##RetainOrAssign(ownerClassSig##_##propertyNameSig, Type, InitValueOrEmpty) \
434 static _ZFP_ZFPropertyRegisterHolder _ZFP_PropURH_##ownerClassSig##_##propertyNameSig \
435 _ZFP_ZFPropertyUserRegister_ParamExpand_##RetainOrAssign( \
436 ownerClassSig##_##propertyNameSig, ownerClassSig::ClassData(), \
437 Type, zftext(#propertyNameSig), \
438 ZFTypeId_noneOrType, \
439 _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig::S(), \
440 _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig::G(), \
441 propertyClassOfRetainProperty \
442 , Func_ZFPropertyCallbackIsValueAccessed \
443 , Func_ZFPropertyCallbackIsInitValue \
444 , Func_ZFPropertyCallbackValueReset \
546#define ZFPropertyUserRegisterRetain(resultProperty, ownerClass, \
547 Type, propertyNameString, InitValueOrEmpty, \
548 SetterAccessType, GetterAccessType \
550 ZFPropertyUserRegisterRetainDetail(resultProperty, ownerClass, \
551 Type, propertyNameString, InitValueOrEmpty, \
552 SetterAccessType, GetterAccessType \
553 , ZFPropertyUserRegisterDefaultImplRetain<Type>::setterInvoker \
554 , ZFPropertyUserRegisterDefaultImplRetain<Type>::getterInvoker \
555 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsValueAccessed \
556 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsInitValue \
557 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackValueReset \
560#define ZFPropertyUserRegisterRetainDetail(resultProperty, ownerClass, \
561 Type, propertyNameString, InitValueOrEmpty, \
562 SetterAccessType, GetterAccessType \
563 , Func_ZFPropertySetterInvoker \
564 , Func_ZFPropertyGetterInvoker \
565 , Func_ZFPropertyCallbackIsValueAccessed \
566 , Func_ZFPropertyCallbackIsInitValue \
567 , Func_ZFPropertyCallbackValueReset \
569 _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
570 Type, propertyNameString, InitValueOrEmpty, \
571 SetterAccessType, GetterAccessType, \
573 zftTraits<Type>::TrType::ClassData()->classNameFull(), \
574 zftTraits<Type>::TrType::ClassData() \
575 , Func_ZFPropertySetterInvoker \
576 , Func_ZFPropertyGetterInvoker \
577 , Func_ZFPropertyCallbackIsValueAccessed \
578 , Func_ZFPropertyCallbackIsInitValue \
579 , Func_ZFPropertyCallbackValueReset \
582#define ZFPROPERTY_USER_REGISTER_RETAIN(ownerClassSig, \
583 Type, propertyNameSig, InitValueOrEmpty, \
584 SetterAccessType, GetterAccessType \
586 ZFPROPERTY_USER_REGISTER_RETAIN_DETAIL(ownerClassSig, \
587 Type, propertyNameSig, InitValueOrEmpty, \
588 SetterAccessType, GetterAccessType \
589 , ZFPropertyUserRegisterDefaultImplRetain<Type>::setterInvoker \
590 , ZFPropertyUserRegisterDefaultImplRetain<Type>::getterInvoker \
591 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsValueAccessed \
592 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsInitValue \
593 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackValueReset \
596#define ZFPROPERTY_USER_REGISTER_RETAIN_DETAIL(ownerClassSig, \
597 Type, propertyNameSig, InitValueOrEmpty, \
598 SetterAccessType, GetterAccessType \
599 , Func_ZFPropertySetterInvoker \
600 , Func_ZFPropertyGetterInvoker \
601 , Func_ZFPropertyCallbackIsValueAccessed \
602 , Func_ZFPropertyCallbackIsInitValue \
603 , Func_ZFPropertyCallbackValueReset \
605 _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
606 Type, propertyNameSig, InitValueOrEmpty, \
607 SetterAccessType, GetterAccessType, \
609 zftTraits<Type>::TrType::ClassData()->classNameFull(), \
610 zftTraits<Type>::TrType::ClassData() \
611 , Func_ZFPropertySetterInvoker \
612 , Func_ZFPropertyGetterInvoker \
613 , Func_ZFPropertyCallbackIsValueAccessed \
614 , Func_ZFPropertyCallbackIsInitValue \
615 , Func_ZFPropertyCallbackValueReset \
620#define ZFPropertyUserRegisterAssign(resultProperty, ownerClass, \
621 Type, propertyNameString, InitValueOrEmpty, \
622 SetterAccessType, GetterAccessType \
624 ZFPropertyUserRegisterAssignDetail(resultProperty, ownerClass, \
625 Type, propertyNameString, InitValueOrEmpty, \
626 SetterAccessType, GetterAccessType \
627 , ZFPropertyUserRegisterDefaultImplAssign<Type>::setterInvoker \
628 , ZFPropertyUserRegisterDefaultImplAssign<Type>::getterInvoker \
629 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsValueAccessed \
630 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsInitValue \
631 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackValueReset \
634#define ZFPropertyUserRegisterAssignDetail(resultProperty, ownerClass, \
635 Type, propertyNameString, InitValueOrEmpty, \
636 SetterAccessType, GetterAccessType \
637 , Func_ZFPropertySetterInvoker \
638 , Func_ZFPropertyGetterInvoker \
639 , Func_ZFPropertyCallbackIsValueAccessed \
640 , Func_ZFPropertyCallbackIsInitValue \
641 , Func_ZFPropertyCallbackValueReset \
643 _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
644 Type, propertyNameString, InitValueOrEmpty, \
645 SetterAccessType, GetterAccessType, \
647 ZFTypeId<zftTraits<Type>::TrNoRef>::TypeId(), \
649 , Func_ZFPropertySetterInvoker \
650 , Func_ZFPropertyGetterInvoker \
651 , Func_ZFPropertyCallbackIsValueAccessed \
652 , Func_ZFPropertyCallbackIsInitValue \
653 , Func_ZFPropertyCallbackValueReset \
656#define ZFPROPERTY_USER_REGISTER_ASSIGN(ownerClassSig, \
657 Type, propertyNameSig, InitValueOrEmpty, \
658 SetterAccessType, GetterAccessType \
660 ZFPROPERTY_USER_REGISTER_ASSIGN_DETAIL(ownerClassSig, \
661 Type, propertyNameSig, InitValueOrEmpty, \
662 SetterAccessType, GetterAccessType \
663 , ZFPropertyUserRegisterDefaultImplAssign<Type>::setterInvoker \
664 , ZFPropertyUserRegisterDefaultImplAssign<Type>::getterInvoker \
665 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsValueAccessed \
666 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsInitValue \
667 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackValueReset \
670#define ZFPROPERTY_USER_REGISTER_ASSIGN_DETAIL(ownerClassSig, \
671 Type, propertyNameSig, InitValueOrEmpty, \
672 SetterAccessType, GetterAccessType \
673 , Func_ZFPropertySetterInvoker \
674 , Func_ZFPropertyGetterInvoker \
675 , Func_ZFPropertyCallbackIsValueAccessed \
676 , Func_ZFPropertyCallbackIsInitValue \
677 , Func_ZFPropertyCallbackValueReset \
679 _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
680 Type, propertyNameSig, InitValueOrEmpty, \
681 SetterAccessType, GetterAccessType, \
683 ZFTypeId<zftTraits<Type>::TrNoRef>::TypeId(), \
685 , Func_ZFPropertySetterInvoker \
686 , Func_ZFPropertyGetterInvoker \
687 , Func_ZFPropertyCallbackIsValueAccessed \
688 , Func_ZFPropertyCallbackIsInitValue \
689 , 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:192
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfdelete(instance)
same as delete defined for future use
Definition ZFCoreTypeDef_ClassType.h:91
#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:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#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 zfnew(Type,...)
same as new defined for future use
Definition ZFCoreTypeDef_ClassType.h:89
_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 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:126
#define zfRelease(obj)
release an object, see ZFObject
Definition ZFObjectRetain.h:148
#define zfRetain(obj)
retain an object, see ZFObject
Definition ZFObjectRetain.h:128
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:209
info for a property for ZFObject, see ZFPROPERTY_RETAIN for more info
Definition ZFProperty.h:28
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