ZFFramework
 
Loading...
Searching...
No Matches
ZFProperty.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFProperty_h_
7#define _ZFI_ZFProperty_h_
8
9#include "ZFPropertyFwd.h"
10#include "ZFMethod.h"
11#include "zfany.h"
13
14// ============================================================
16typedef void (*_ZFP_ZFPropertyCallbackEnsureInit)(
17 ZF_IN const ZFProperty *property
18 , ZF_IN zfany const &owner
19 );
20typedef void (*_ZFP_ZFPropertyCallbackDealloc)(
21 ZF_IN const ZFProperty *property
22 , ZF_IN zfany const &owner
23 );
24typedef void (*_ZFP_ZFPropertyMethodCleanup)(ZF_IN const ZFMethod *method);
30
31public:
33 void objectInfoT(ZF_IN_OUT zfstring &ret) const;
37 zfstring objectInfo(void) const {
38 zfstring ret;
39 this->objectInfoT(ret);
40 return ret;
41 }
42
43public:
47 inline zfidentity propertyId(void) const {
48 return this->_ZFP_ZFProperty_propertyId.sigId();
49 }
50
53 inline zfbool isUserRegister(void) const {
54 return this->_ZFP_ZFProperty_isUserRegister;
55 }
56
59 inline zfbool isDynamicRegister(void) const {
60 return this->_ZFP_ZFProperty_isDynamicRegister;
61 }
62
65 inline zfany dynamicRegisterUserData(void) const {
66 return this->_ZFP_ZFProperty_dynamicRegisterUserData;
67 }
68
83 inline const ZFClass *ownerClass(void) const {
84 return this->_ZFP_ZFProperty_ownerClass;
85 }
86
89 inline const zfstring &propertyName(void) const {
90 return this->_ZFP_ZFProperty_name;
91 }
92
100 inline const zfstring &propertyTypeName(void) const {
101 return this->_ZFP_ZFProperty_typeName ? this->_ZFP_ZFProperty_typeName : this->_ZFP_ZFProperty_typeId;
102 }
103
111 inline const zfstring &propertyTypeId(void) const {
112 return this->_ZFP_ZFProperty_typeId;
113 }
114
117 inline const ZFMethod *setterMethod(void) const {
118 return this->_ZFP_ZFProperty_setterMethod;
119 }
120
123 inline const ZFMethod *getterMethod(void) const {
124 return this->_ZFP_ZFProperty_getterMethod;
125 }
126
133 inline zfbool isRetainProperty(void) const {
134 return (this->_ZFP_ZFProperty_propertyClassOfRetainProperty != zfnull);
135 }
136
141 inline const ZFClass *propertyClassOfRetainProperty(void) const {
142 return this->_ZFP_ZFProperty_propertyClassOfRetainProperty;
143 }
144
145public:
156 inline zfbool isInternal(void) const {return _ZFP_ZFProperty_isInternal;}
167 inline zfbool isInternalPrivate(void) const {return _ZFP_ZFProperty_isInternalPrivate;}
168
169public:
180
181public:
183 ZFProperty(void);
184 ~ZFProperty(void);
186 void _ZFP_ZFPropertyInit(
190 , ZF_IN const ZFClass *ownerClass
191 , ZF_IN const zfstring &name
192 , ZF_IN const zfstring &typeName
193 , ZF_IN const zfstring &typeIdName
196 , ZF_IN _ZFP_ZFPropertyMethodCleanup setterMethodCleanup
197 , ZF_IN _ZFP_ZFPropertyMethodCleanup getterMethodCleanup
199 );
200 ZFProperty *_ZFP_ZFProperty_removeConst(void) const {
201 return const_cast<ZFProperty *>(this);
202 }
203public:
204 zfuint _ZFP_ZFProperty_refCount;
205 zfbool _ZFP_ZFProperty_isInternal;
206 zfbool _ZFP_ZFProperty_isInternalPrivate;
207 zfbool _ZFP_ZFProperty_isUserRegister;
208 zfbool _ZFP_ZFProperty_isDynamicRegister;
209 ZFSigName _ZFP_ZFProperty_propertyId;
210 ZFObject *_ZFP_ZFProperty_dynamicRegisterUserData;
211 ZFObject *_ZFP_ZFProperty_dynamicRegisterUserDataWrapper;
212 const ZFClass *_ZFP_ZFProperty_ownerClass;
213 ZFSigName _ZFP_ZFProperty_name;
214 ZFSigName _ZFP_ZFProperty_typeName;
215 ZFSigName _ZFP_ZFProperty_typeId;
216 const ZFMethod *_ZFP_ZFProperty_setterMethod;
217 const ZFMethod *_ZFP_ZFProperty_getterMethod;
218 _ZFP_ZFPropertyMethodCleanup _ZFP_ZFProperty_setterMethodCleanup;
219 _ZFP_ZFPropertyMethodCleanup _ZFP_ZFProperty_getterMethodCleanup;
220 const ZFClass *_ZFP_ZFProperty_propertyClassOfRetainProperty;
221 _ZFP_ZFPropertyCallbackEnsureInit _ZFP_ZFProperty_callbackEnsureInit;
222 _ZFP_ZFPropertyCallbackDealloc _ZFP_ZFProperty_callbackDealloc;
223 ZFCoreArray<_ZFP_PropLifeCycleData> _ZFP_ZFPropertyLifeCycle_OnInit; // ordered from parent to child
224 ZFCoreArray<_ZFP_PropLifeCycleData> _ZFP_ZFPropertyLifeCycle_OnUpdate;
225 ZFCoreArray<_ZFP_PropLifeCycleData> _ZFP_ZFPropertyLifeCycle_OnAttach;
226 ZFCoreArray<_ZFP_PropLifeCycleData> _ZFP_ZFPropertyLifeCycle_OnDetach;
227};
228
229// ============================================================
240
241// ============================================================
242extern ZFLIB_ZFCore ZFProperty *_ZFP_ZFPropertyRegister(
243 ZF_IN zfbool isUserRegister
244 , ZF_IN zfbool isDynamicRegister
245 , ZF_IN ZFObject *dynamicRegisterUserData
246 , ZF_IN const ZFClass *ownerClass
247 , ZF_IN const zfstring &name
248 , ZF_IN const zfstring &typeName
249 , ZF_IN const zfstring &typeIdName
250 , ZF_IN const ZFMethod *setterMethod
251 , ZF_IN const ZFMethod *getterMethod
252 , ZF_IN _ZFP_ZFPropertyMethodCleanup setterMethodCleanup
253 , ZF_IN _ZFP_ZFPropertyMethodCleanup getterMethodCleanup
254 , ZF_IN const ZFClass *propertyClassOfRetainProperty
255 , ZF_IN ZFPropertyCallbackIsValueAccessed callbackIsValueAccessed
256 , ZF_IN ZFPropertyCallbackIsInitValue callbackIsInitValue
257 , ZF_IN ZFPropertyCallbackValueReset callbackValueReset
258 , ZF_IN ZFPropertyCallbackUserRegisterInitValueSetup callbackUserRegisterInitValueSetup
259 , ZF_IN ZFPropertyCallbackDynamicRegisterInitValueGetter callbackDynamicRegisterInitValueGetter
260 , ZF_IN _ZFP_ZFPropertyCallbackEnsureInit callbackEnsureInit
261 , ZF_IN _ZFP_ZFPropertyCallbackDealloc callbackDealloc
262 );
263extern ZFLIB_ZFCore void _ZFP_ZFPropertyUnregister(ZF_IN const ZFProperty *propertyInfo);
264
265zfclassLikePOD ZFLIB_ZFCore _ZFP_ZFPropertyRegisterHolder {
266public:
267 _ZFP_ZFPropertyRegisterHolder(
268 ZF_IN zfbool isUserRegister
269 , ZF_IN zfbool isDynamicRegister
270 , ZF_IN ZFObject *dynamicRegisterUserData
271 , ZF_IN const ZFClass *ownerClass
272 , ZF_IN const zfstring &name
273 , ZF_IN const zfstring &typeName
274 , ZF_IN const zfstring &typeIdName
275 , ZF_IN const ZFMethod *setterMethod
276 , ZF_IN const ZFMethod *getterMethod
277 , ZF_IN _ZFP_ZFPropertyMethodCleanup setterMethodCleanup
278 , ZF_IN _ZFP_ZFPropertyMethodCleanup getterMethodCleanup
279 , ZF_IN const ZFClass *propertyClassOfRetainProperty
280 , ZF_IN ZFPropertyCallbackIsValueAccessed callbackIsValueAccessed
281 , ZF_IN ZFPropertyCallbackIsInitValue callbackIsInitValue
282 , ZF_IN ZFPropertyCallbackValueReset callbackValueReset
283 , ZF_IN ZFPropertyCallbackUserRegisterInitValueSetup callbackUserRegisterInitValueSetup
284 , ZF_IN ZFPropertyCallbackDynamicRegisterInitValueGetter callbackDynamicRegisterInitValueGetter
285 , ZF_IN _ZFP_ZFPropertyCallbackEnsureInit callbackEnsureInit
286 , ZF_IN _ZFP_ZFPropertyCallbackDealloc callbackDealloc
287 )
288 : propertyInfo(_ZFP_ZFPropertyRegister(
289 isUserRegister
290 , isDynamicRegister
291 , dynamicRegisterUserData
292 , ownerClass
293 , name
294 , typeName
295 , typeIdName
296 , setterMethod
297 , getterMethod
298 , setterMethodCleanup
299 , getterMethodCleanup
300 , propertyClassOfRetainProperty
301 , callbackIsValueAccessed
302 , callbackIsInitValue
303 , callbackValueReset
304 , callbackUserRegisterInitValueSetup
305 , callbackDynamicRegisterInitValueGetter
306 , callbackEnsureInit
307 , callbackDealloc
308 )) {
309 }
310 ~_ZFP_ZFPropertyRegisterHolder(void) {
311 _ZFP_ZFPropertyUnregister(this->propertyInfo);
312 }
313public:
314 ZFProperty *propertyInfo;
315};
316
318#endif // #ifndef _ZFI_ZFProperty_h_
319
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#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 ZFCLASS_DISALLOW_COPY_CONSTRUCTOR(ClassName)
a macro to show that a class doesn't allow copy constructor
Definition ZFCoreTypeDef_ClassType.h:81
#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_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
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
reflectable method definination for ZFFramework
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
ZFCoreArray< const ZFProperty * > ZFPropertyGetAll(void)
get all property currently registered, for debug use only
Definition ZFProperty.h:235
void ZFPropertyGetAllT(ZFCoreArray< const ZFProperty * > &ret)
see ZFPropertyGetAll
property for ZFObject type
zfauto(* ZFPropertyCallbackDynamicRegisterInitValueGetter)(const ZFProperty *property)
callback to setup init value for ZFPropertyDynamicRegister
Definition ZFPropertyFwd.h:86
zfbool(* ZFPropertyCallbackIsValueAccessed)(const ZFProperty *property, zfany const &ownerObj)
used to check whether the property has been accessed
Definition ZFPropertyFwd.h:27
void(* ZFPropertyCallbackValueReset)(const ZFProperty *property, zfany const &ownerObj)
used to reset the property to its init state
Definition ZFPropertyFwd.h:63
zfbool(* ZFPropertyCallbackIsInitValue)(const ZFProperty *property, zfany const &ownerObj, zfauto *outInitValue)
used to check whether the property is in init value state
Definition ZFPropertyFwd.h:48
void(* ZFPropertyCallbackUserRegisterInitValueSetup)(const ZFProperty *property, void *v)
for user registered property only, used to setup a property's init value
Definition ZFPropertyFwd.h:77
ZFObject's class info.
Definition ZFClass.h:67
light weight array
Definition ZFCoreArray.h:331
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
const ZFMethod * getterMethod(void) const
get the getter method
Definition ZFProperty.h:123
void objectInfoT(zfstring &ret) const
see objectInfo
const ZFMethod * setterMethod(void) const
get the getter method
Definition ZFProperty.h:117
zfstring objectInfo(void) const
get info about this property
Definition ZFProperty.h:37
ZFPropertyCallbackValueReset callbackValueReset
see ZFPropertyCallbackValueReset
Definition ZFProperty.h:175
const zfstring & propertyTypeId(void) const
type id string declared in ZFPROPERTY_XXX
Definition ZFProperty.h:111
ZFPropertyCallbackIsValueAccessed callbackIsValueAccessed
see ZFPropertyCallbackIsValueAccessed
Definition ZFProperty.h:171
zfbool isUserRegister(void) const
true if this property is registered by ZFPropertyUserRegisterRetain
Definition ZFProperty.h:53
zfbool isInternalPrivate(void) const
whether the property is internal private property
Definition ZFProperty.h:167
ZFPropertyCallbackDynamicRegisterInitValueGetter callbackDynamicRegisterInitValueGetter
see ZFPropertyDynamicRegister
Definition ZFProperty.h:179
zfbool isRetainProperty(void) const
true if the property is retain property
Definition ZFProperty.h:133
ZFPropertyCallbackUserRegisterInitValueSetup callbackUserRegisterInitValueSetup
see ZFPropertyUserRegisterAssign
Definition ZFProperty.h:177
const zfstring & propertyTypeName(void) const
type string for the property
Definition ZFProperty.h:100
const ZFClass * ownerClass(void) const
get the property's owner class
Definition ZFProperty.h:83
ZFPropertyCallbackIsInitValue callbackIsInitValue
see ZFPropertyCallbackIsInitValue
Definition ZFProperty.h:173
zfbool propertySerializable(void) const
true if the property is serializable
zfany dynamicRegisterUserData(void) const
see ZFPropertyDynamicRegister
Definition ZFProperty.h:65
const ZFClass * propertyClassOfRetainProperty(void) const
for retain property only, get the retain property's declared class
Definition ZFProperty.h:141
zfbool isInternal(void) const
whether the property is internal property
Definition ZFProperty.h:156
const zfstring & propertyName(void) const
name for the property
Definition ZFProperty.h:89
zfbool isDynamicRegister(void) const
true if this property is registered by ZFPropertyDynamicRegister
Definition ZFProperty.h:59
zfidentity propertyId(void) const
internal property id, for debug use only
Definition ZFProperty.h:47
readonly string container for internal use only
Definition ZFSigName.h:17
util method to cast ZFObject types freely
Definition zfany.h:35
util class to cast ZFObject types freely