Reflect class
all ZFObject class or ZFInterface class can be reflected if:
- any instance of the class have ever been created
- ClassData have ever been called
- ZFOBJECT_REGISTER have been declared
if matched any of the condition above, you may reflect the class's meta data:
MyObject *myObj = obj;
#define zfLog(...)
thread-safe log utility
Definition ZFLog.h:64
ZFObject's class info.
Definition ZFClass.h:66
zfauto newInstance(void) const
make a new instance of ZFObject dynamically, which is described by ZFClass
const zfchar * className(void) const
class name, e.g. "ZFObject"
Definition ZFClass.h:200
static const ZFClass * classForName(const zfchar *classNameOrFullName)
get class info by name
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
Reflect method
a method is reflectable if it's declared by ZFMETHOD_XXX_DECLARE_XXX series, you may reflect it like this:
method->
execute<ReturnType, ParamType0, ParamType1>(obj, param0, param1);
const ZFMethod * methodForName(const zfchar *methodName, const zfchar *methodParamTypeId0, const zfchar *methodParamTypeId1=0, const zfchar *methodParamTypeId2=0, const zfchar *methodParamTypeId3=0, const zfchar *methodParamTypeId4=0, const zfchar *methodParamTypeId5=0, const zfchar *methodParamTypeId6=0, const zfchar *methodParamTypeId7=0) const
get the method by name hierarchically from class inherit tree, or zfnull if not exists
reflectable method for ZFObject
Definition ZFMethod.h:237
T_ReturnType execute(ZFObject *obj) const
see ZFMethod
Definition ZFMethod.h:265
Reflect property
also, a property is reflectable if it's declared by ZFPROPERTY_XXX series, you may reflect it like this:
const ZFProperty * propertyForName(const zfchar *propertyName) const
get the property by name hierarchically from class inherit tree, or zfnull if not exists
info for a property for ZFObject, see ZFPROPERTY_RETAIN for more info
Definition ZFProperty.h:29
const ZFMethod * setterMethod(void) const
get the getter method
Definition ZFProperty.h:118
Existing class
any existing class can also be reflectable if you are able to supply some extra registration code:
class YourType {
public:
int yourProp;
};
v.yourProp = yourParser(src, srcLen);
}, {
yourPrinter(s, v);
})
#define ZFLIB_APP
used to export symbols
Definition ZFCoreEnvDef.h:35
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:62
_ZFT_t_zfint zfint
same as int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:121
#define ZFMETHOD_USER_REGISTER_FOR_WRAPPER_VAR(WrapperClass, VarType, VarName)
see ZFMethodUserRegister_0
Definition ZFMethodUserRegister_Wrapper.h:59
#define ZFTYPEID_DECLARE(ZFLIB_, TypeName, Type)
register a type
Definition ZFTypeIdCore.h:98
#define ZFTYPEID_DEFINE_BY_STRING_CONVERTER(TypeName, Type, convertFromStringAction, convertToStringAction)
see ZFTYPEID_DECLARE
Definition ZFTypeIdCore.h:291
once registered:
int yourProp = obj->classData()->propertyGetterForName(
"yourProp")->execute<
zfint const &>(obj);
or even for lua: (see also Automatically lua binding)
local obj = YourType();
local yourProp = obj:yourProp();