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 , propertyClassOfRetainProperty \
316 , Func_ZFPropertyCallbackIsValueAccessed \
317 , Func_ZFPropertyCallbackIsInitValue \
318 , Func_ZFPropertyCallbackValueReset \
319 , _ZFP_PropURInit_##registerSig::I \
324#define _ZFP_ZFPropertyUserRegister_ParamExpand_Assign( \
327 Type, propertyNameString, \
328 ZFTypeId_noneOrType, \
331 propertyClassOfRetainProperty \
332 , Func_ZFPropertyCallbackIsValueAccessed \
333 , Func_ZFPropertyCallbackIsInitValue \
334 , Func_ZFPropertyCallbackValueReset \
341 , propertyNameString \
343 , ZFTypeId_noneOrType \
346 , propertyClassOfRetainProperty \
347 , Func_ZFPropertyCallbackIsValueAccessed \
348 , Func_ZFPropertyCallbackIsInitValue \
349 , Func_ZFPropertyCallbackValueReset \
350 , _ZFP_PropURInit_##registerSig::I \
357#define _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
358 Type, propertyNameString, InitValueOrEmpty, \
359 SetterAccessType, GetterAccessType, \
361 ZFTypeId_noneOrType, \
362 propertyClassOfRetainProperty \
363 , Func_ZFPropertySetterInvoker \
364 , Func_ZFPropertyGetterInvoker \
365 , Func_ZFPropertyCallbackIsValueAccessed \
366 , Func_ZFPropertyCallbackIsInitValue \
367 , Func_ZFPropertyCallbackValueReset \
369 const ZFProperty *resultProperty = zfnull; \
371 ZFCoreMutexLocker(); \
372 const ZFClass *_ownerClass = ownerClass; \
373 zfstring _propertyName(propertyNameString); \
375 ZFMethodUserRegisterDetail_1(setterMethod, { \
376 Func_ZFPropertySetterInvoker(invokerMethod, invokerObject, value); \
377 }, _ownerClass, SetterAccessType, ZFMethodTypeVirtual, \
378 void, _propertyName, \
379 ZFMP_IN(Type const &, value)); \
380 ZFMethodUserRegisterDetail_0(getterMethod, { \
381 return Func_ZFPropertyGetterInvoker(invokerMethod, invokerObject); \
382 }, _ownerClass, GetterAccessType, ZFMethodTypeVirtual, \
383 Type const &, _propertyName); \
384 _ZFP_ZFPropertyUserRegister_PropInit_##RetainOrAssign(_, Type, InitValueOrEmpty) \
385 resultProperty = ZFProperty::_ZFP_ZFPropertyRegister _ZFP_ZFPropertyUserRegister_ParamExpand_##RetainOrAssign( \
387 Type, _propertyName, \
388 ZFTypeId_noneOrType, \
389 setterMethod, getterMethod, \
390 propertyClassOfRetainProperty \
391 , Func_ZFPropertyCallbackIsValueAccessed \
392 , Func_ZFPropertyCallbackIsInitValue \
393 , Func_ZFPropertyCallbackValueReset \
396 ZFUNUSED(resultProperty)
398#define _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
399 Type, propertyNameSig, InitValueOrEmpty, \
400 SetterAccessType, GetterAccessType, \
402 ZFTypeId_noneOrType, \
403 propertyClassOfRetainProperty \
404 , Func_ZFPropertySetterInvoker \
405 , Func_ZFPropertyGetterInvoker \
406 , Func_ZFPropertyCallbackIsValueAccessed \
407 , Func_ZFPropertyCallbackIsInitValue \
408 , Func_ZFPropertyCallbackValueReset \
410 zfclassNotPOD _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig { \
412 static const ZFMethod *S(void) { \
413 ZFMethodUserRegisterDetail_1(setterMethod, { \
414 Func_ZFPropertySetterInvoker(invokerMethod, invokerObject, value); \
415 }, ownerClassSig::ClassData(), SetterAccessType, ZFMethodTypeVirtual, \
416 void, zftext(#propertyNameSig), \
417 ZFMP_IN(Type const &, value)); \
418 return setterMethod; \
420 static const ZFMethod *G(void) { \
421 ZFMethodUserRegisterDetail_0(getterMethod, { \
422 return Func_ZFPropertyGetterInvoker(invokerMethod, invokerObject); \
423 }, ownerClassSig::ClassData(), GetterAccessType, ZFMethodTypeVirtual, \
424 Type const &, zftext(#propertyNameSig)); \
425 return getterMethod; \
428 _ZFP_ZFPropertyUserRegister_PropInit_##RetainOrAssign(ownerClassSig##_##propertyNameSig, Type, InitValueOrEmpty) \
429 static _ZFP_ZFPropertyRegisterHolder _ZFP_PropURH_##ownerClassSig##_##propertyNameSig \
430 _ZFP_ZFPropertyUserRegister_ParamExpand_##RetainOrAssign( \
431 ownerClassSig##_##propertyNameSig, ownerClassSig::ClassData(), \
432 Type, zftext(#propertyNameSig), \
433 ZFTypeId_noneOrType, \
434 _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig::S(), \
435 _ZFP_PropURMH_##ownerClassSig##_##propertyNameSig::G(), \
436 propertyClassOfRetainProperty \
437 , Func_ZFPropertyCallbackIsValueAccessed \
438 , Func_ZFPropertyCallbackIsInitValue \
439 , Func_ZFPropertyCallbackValueReset \
541#define ZFPropertyUserRegisterRetain(resultProperty, ownerClass, \
542 Type, propertyNameString, InitValueOrEmpty, \
543 SetterAccessType, GetterAccessType \
545 ZFPropertyUserRegisterRetainDetail(resultProperty, ownerClass, \
546 Type, propertyNameString, InitValueOrEmpty, \
547 SetterAccessType, GetterAccessType \
548 , ZFPropertyUserRegisterDefaultImplRetain<Type>::setterInvoker \
549 , ZFPropertyUserRegisterDefaultImplRetain<Type>::getterInvoker \
550 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsValueAccessed \
551 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsInitValue \
552 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackValueReset \
555#define ZFPropertyUserRegisterRetainDetail(resultProperty, ownerClass, \
556 Type, propertyNameString, InitValueOrEmpty, \
557 SetterAccessType, GetterAccessType \
558 , Func_ZFPropertySetterInvoker \
559 , Func_ZFPropertyGetterInvoker \
560 , Func_ZFPropertyCallbackIsValueAccessed \
561 , Func_ZFPropertyCallbackIsInitValue \
562 , Func_ZFPropertyCallbackValueReset \
564 _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
565 Type, propertyNameString, InitValueOrEmpty, \
566 SetterAccessType, GetterAccessType, \
568 zftTraits<Type>::TrType::ClassData()->classNameFull(), \
569 zftTraits<Type>::TrType::ClassData() \
570 , Func_ZFPropertySetterInvoker \
571 , Func_ZFPropertyGetterInvoker \
572 , Func_ZFPropertyCallbackIsValueAccessed \
573 , Func_ZFPropertyCallbackIsInitValue \
574 , Func_ZFPropertyCallbackValueReset \
577#define ZFPROPERTY_USER_REGISTER_RETAIN(ownerClassSig, \
578 Type, propertyNameSig, InitValueOrEmpty, \
579 SetterAccessType, GetterAccessType \
581 ZFPROPERTY_USER_REGISTER_RETAIN_DETAIL(ownerClassSig, \
582 Type, propertyNameSig, InitValueOrEmpty, \
583 SetterAccessType, GetterAccessType \
584 , ZFPropertyUserRegisterDefaultImplRetain<Type>::setterInvoker \
585 , ZFPropertyUserRegisterDefaultImplRetain<Type>::getterInvoker \
586 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsValueAccessed \
587 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackIsInitValue \
588 , ZFPropertyUserRegisterDefaultImplRetain<Type>::callbackValueReset \
591#define ZFPROPERTY_USER_REGISTER_RETAIN_DETAIL(ownerClassSig, \
592 Type, propertyNameSig, InitValueOrEmpty, \
593 SetterAccessType, GetterAccessType \
594 , Func_ZFPropertySetterInvoker \
595 , Func_ZFPropertyGetterInvoker \
596 , Func_ZFPropertyCallbackIsValueAccessed \
597 , Func_ZFPropertyCallbackIsInitValue \
598 , Func_ZFPropertyCallbackValueReset \
600 _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
601 Type, propertyNameSig, InitValueOrEmpty, \
602 SetterAccessType, GetterAccessType, \
604 zftTraits<Type>::TrType::ClassData()->classNameFull(), \
605 zftTraits<Type>::TrType::ClassData() \
606 , Func_ZFPropertySetterInvoker \
607 , Func_ZFPropertyGetterInvoker \
608 , Func_ZFPropertyCallbackIsValueAccessed \
609 , Func_ZFPropertyCallbackIsInitValue \
610 , Func_ZFPropertyCallbackValueReset \
615#define ZFPropertyUserRegisterAssign(resultProperty, ownerClass, \
616 Type, propertyNameString, InitValueOrEmpty, \
617 SetterAccessType, GetterAccessType \
619 ZFPropertyUserRegisterAssignDetail(resultProperty, ownerClass, \
620 Type, propertyNameString, InitValueOrEmpty, \
621 SetterAccessType, GetterAccessType \
622 , ZFPropertyUserRegisterDefaultImplAssign<Type>::setterInvoker \
623 , ZFPropertyUserRegisterDefaultImplAssign<Type>::getterInvoker \
624 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsValueAccessed \
625 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsInitValue \
626 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackValueReset \
629#define ZFPropertyUserRegisterAssignDetail(resultProperty, ownerClass, \
630 Type, propertyNameString, InitValueOrEmpty, \
631 SetterAccessType, GetterAccessType \
632 , Func_ZFPropertySetterInvoker \
633 , Func_ZFPropertyGetterInvoker \
634 , Func_ZFPropertyCallbackIsValueAccessed \
635 , Func_ZFPropertyCallbackIsInitValue \
636 , Func_ZFPropertyCallbackValueReset \
638 _ZFP_ZFPropertyUserRegister(resultProperty, ownerClass, \
639 Type, propertyNameString, InitValueOrEmpty, \
640 SetterAccessType, GetterAccessType, \
642 ZFTypeId<zftTraits<Type>::TrNoRef>::TypeId(), \
644 , Func_ZFPropertySetterInvoker \
645 , Func_ZFPropertyGetterInvoker \
646 , Func_ZFPropertyCallbackIsValueAccessed \
647 , Func_ZFPropertyCallbackIsInitValue \
648 , Func_ZFPropertyCallbackValueReset \
651#define ZFPROPERTY_USER_REGISTER_ASSIGN(ownerClassSig, \
652 Type, propertyNameSig, InitValueOrEmpty, \
653 SetterAccessType, GetterAccessType \
655 ZFPROPERTY_USER_REGISTER_ASSIGN_DETAIL(ownerClassSig, \
656 Type, propertyNameSig, InitValueOrEmpty, \
657 SetterAccessType, GetterAccessType \
658 , ZFPropertyUserRegisterDefaultImplAssign<Type>::setterInvoker \
659 , ZFPropertyUserRegisterDefaultImplAssign<Type>::getterInvoker \
660 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsValueAccessed \
661 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackIsInitValue \
662 , ZFPropertyUserRegisterDefaultImplAssign<Type>::callbackValueReset \
665#define ZFPROPERTY_USER_REGISTER_ASSIGN_DETAIL(ownerClassSig, \
666 Type, propertyNameSig, InitValueOrEmpty, \
667 SetterAccessType, GetterAccessType \
668 , Func_ZFPropertySetterInvoker \
669 , Func_ZFPropertyGetterInvoker \
670 , Func_ZFPropertyCallbackIsValueAccessed \
671 , Func_ZFPropertyCallbackIsInitValue \
672 , Func_ZFPropertyCallbackValueReset \
674 _ZFP_ZFPROPERTY_USER_REGISTER(ownerClassSig, \
675 Type, propertyNameSig, InitValueOrEmpty, \
676 SetterAccessType, GetterAccessType, \
678 ZFTypeId<zftTraits<Type>::TrNoRef>::TypeId(), \
680 , Func_ZFPropertySetterInvoker \
681 , Func_ZFPropertyGetterInvoker \
682 , Func_ZFPropertyCallbackIsValueAccessed \
683 , Func_ZFPropertyCallbackIsInitValue \
684 , 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:196
#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:184
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
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
_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 zfpoolNew
Definition ZFMemPool.h:38
#define zfpoolNew(T_Type,...)
internal use only, for allocating internal types for performance
Definition ZFMemPool.h:37
#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 zfobjRetain(obj)
retain an object, see ZFObject
Definition ZFObjectRetain.h:128
#define zfobjRelease(obj)
release an object, see ZFObject
Definition ZFObjectRetain.h:148
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:196
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