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:77
ZFObject's class info.
Definition ZFClass.h:67
zfauto newInstance(void) const
make a new instance of ZFObject dynamically, which is described by ZFClass
static const ZFClass * classForName(const zfstring &classNameOrFullName)
get class info by name
const zfstring & className(void) const
class name, e.g. "ZFObject"
Definition ZFClass.h:181
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->
executeExact<ReturnType, ParamType0, ParamType1>(obj, param0, param1);
const ZFMethod * methodForName(const zfstring &methodName, const zfchar *paramTypeId0, const zfchar *paramTypeId1=zft_zfnull, const zfchar *paramTypeId2=zft_zfnull, const zfchar *paramTypeId3=zft_zfnull, const zfchar *paramTypeId4=zft_zfnull, const zfchar *paramTypeId5=zft_zfnull, const zfchar *paramTypeId6=zft_zfnull, const zfchar *paramTypeId7=zft_zfnull) const
get the method by name hierarchically from class inherit tree, or zfnull if not exists
reflectable method for ZFObject
Definition ZFMethod.h:252
T_ReturnType executeExact(ZFObject *obj) const
see ZFMethod
Definition ZFMethod.h:278
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 zfstring &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:28
const ZFMethod * setterMethod(void) const
get the getter method
Definition ZFProperty.h:117
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:107
_ZFT_t_zfint zfint
same as int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:165
#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 for reflection
Definition ZFTypeIdDeclare.h:137
#define ZFTYPEID_DEFINE_BY_STRING_CONVERTER(TypeName, Type, convertFromStringAction, convertToStringAction)
see ZFTYPEID_DECLARE
Definition ZFTypeIdDeclare.h:166
once registered:
int yourProp = obj->classData()->propertyGetterForName(
"yourProp")->executeExact<
zfint const &>(obj);
or even for lua: (see also Automatically lua binding)
local obj = YourType();
local yourProp = obj:yourProp();