ZFFramework
Loading...
Searching...
No Matches
Macros | Functions
ZFObjectDeclare.h File Reference

ZFObject declaration. More...

#include "zfany.h"

Go to the source code of this file.

Macros

#define zfsuperI(T_SuperType)
 class ref to proper super type, see ZFObject for more info
 
#define ZFOBJECT_DECLARE(ChildClass, SuperClass, ...)
 necessary for every class inherit from ZFObject
 
#define ZFOBJECT_DECLARE_WITH_CUSTOM_CTOR(ChildClass, SuperClass, ...)
 declare object which allow custom constructor
 
#define ZFOBJECT_DECLARE_ABSTRACT(ChildClass, SuperClass, ...)
 necessary for every abstract class inherit from ZFObject
 
#define ZFOBJECT_DECLARE_ABSTRACT_WITH_CUSTOM_CTOR(ChildClass, SuperClass, ...)
 see ZFOBJECT_DECLARE_WITH_CUSTOM_CTOR
 
#define ZFOBJECT_REGISTER(T_ZFObject, ...)
 register ZFObject to ZFClass map
 
#define ZFOBJECT_PRIVATE_ALLOC(...)
 mark this object can not be allocated directly
 
#define ZFOBJECT_ON_INIT_INLINE_1(ZFMP_0)
 util macro for subclass to declare ZFObject::objectOnInit as ZFMethod
 
#define ZFOBJECT_ON_INIT_DECLARE_1(ZFMP_0)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_1(OwnerClass, ZFMP_0)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_INLINE_2(ZFMP_0, ZFMP_1)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DECLARE_2(ZFMP_0, ZFMP_1)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_2(OwnerClass, ZFMP_0, ZFMP_1)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_INLINE_3(ZFMP_0, ZFMP_1, ZFMP_2)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DECLARE_3(ZFMP_0, ZFMP_1, ZFMP_2)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_3(OwnerClass, ZFMP_0, ZFMP_1, ZFMP_2)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_INLINE_4(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DECLARE_4(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_4(OwnerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_INLINE_5(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DECLARE_5(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_5(OwnerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_INLINE_6(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DECLARE_6(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_6(OwnerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_INLINE_7(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DECLARE_7(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_7(OwnerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_INLINE_8(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6, ZFMP_7)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DECLARE_8(ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6, ZFMP_7)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_DEFINE_8(OwnerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6, ZFMP_7)
 see ZFOBJECT_ON_INIT_INLINE_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_1(methodInvokerAction, ownerClassSig, ZFMP_0)
 util macro to declare ZFObject::objectOnInit as ZFMETHOD_USER_REGISTER_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_2(methodInvokerAction, ownerClassSig, ZFMP_0, ZFMP_1)
 see ZFOBJECT_ON_INIT_USER_REGISTER_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_3(methodInvokerAction, ownerClassSig, ZFMP_0, ZFMP_1, ZFMP_2)
 see ZFOBJECT_ON_INIT_USER_REGISTER_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_4(methodInvokerAction, ownerClassSig, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3)
 see ZFOBJECT_ON_INIT_USER_REGISTER_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_5(methodInvokerAction, ownerClassSig, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4)
 see ZFOBJECT_ON_INIT_USER_REGISTER_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_6(methodInvokerAction, ownerClassSig, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5)
 see ZFOBJECT_ON_INIT_USER_REGISTER_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_7(methodInvokerAction, ownerClassSig, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6)
 see ZFOBJECT_ON_INIT_USER_REGISTER_1
 
#define ZFOBJECT_ON_INIT_USER_REGISTER_8(methodInvokerAction, ownerClassSig, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6, ZFMP_7)
 see ZFOBJECT_ON_INIT_USER_REGISTER_1
 
#define ZFObjectOnInitUserRegister_1(resultMethod, methodInvokerAction, ownerClass, ZFMP_0)
 util macro to declare ZFObject::objectOnInit as ZFMethodUserRegister_1
 
#define ZFObjectOnInitUserRegister_2(resultMethod, methodInvokerAction, ownerClass, ZFMP_0, ZFMP_1)
 see ZFObjectOnInitUserRegister_1
 
#define ZFObjectOnInitUserRegister_3(resultMethod, methodInvokerAction, ownerClass, ZFMP_0, ZFMP_1, ZFMP_2)
 see ZFObjectOnInitUserRegister_1
 
#define ZFObjectOnInitUserRegister_4(resultMethod, methodInvokerAction, ownerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3)
 see ZFObjectOnInitUserRegister_1
 
#define ZFObjectOnInitUserRegister_5(resultMethod, methodInvokerAction, ownerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4)
 see ZFObjectOnInitUserRegister_1
 
#define ZFObjectOnInitUserRegister_6(resultMethod, methodInvokerAction, ownerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5)
 see ZFObjectOnInitUserRegister_1
 
#define ZFObjectOnInitUserRegister_7(resultMethod, methodInvokerAction, ownerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6)
 see ZFObjectOnInitUserRegister_1
 
#define ZFObjectOnInitUserRegister_8(resultMethod, methodInvokerAction, ownerClass, ZFMP_0, ZFMP_1, ZFMP_2, ZFMP_3, ZFMP_4, ZFMP_5, ZFMP_6, ZFMP_7)
 see ZFObjectOnInitUserRegister_1
 

Functions

const ZFMethodZFObjectOnInitDynamicRegister (const ZFClass *cls, const ZFMP &methodParam, const ZFListener &methodImpl, zfstring *errorHint=0)
 util to declare ZFObject::objectOnInit as ZFMethodDynamicRegister
 
const ZFMethodZFObjectOnInitDynamicRegister (const ZFClass *cls, const ZFMethodDynamicRegisterParam &param, zfstring *errorHint=0)
 util to declare ZFObject::objectOnInit as ZFMethodDynamicRegister
 

Detailed Description

ZFObject declaration.

Macro Definition Documentation

◆ ZFOBJECT_DECLARE

#define ZFOBJECT_DECLARE ( ChildClass,
SuperClass,
... )

necessary for every class inherit from ZFObject

for more information, please refer to ZFObject

See also
ZFObject, ZFOBJECT_REGISTER, ZFOBJECT_DECLARE_ABSTRACT

◆ ZFOBJECT_DECLARE_WITH_CUSTOM_CTOR

#define ZFOBJECT_DECLARE_WITH_CUSTOM_CTOR ( ChildClass,
SuperClass,
... )

declare object which allow custom constructor

by default, ZFObject declare constructor as protected so that app can't construct ZFObject on stack, you may use this macro instead of ZFOBJECT_DECLARE to allow user defined constructor

NOTE: never abuse this macro, and strongly recommended not to allow ZFObject create on stack (i.e. public constructors)

◆ ZFOBJECT_DECLARE_ABSTRACT

#define ZFOBJECT_DECLARE_ABSTRACT ( ChildClass,
SuperClass,
... )

necessary for every abstract class inherit from ZFObject

for more information, please refer to ZFObject

See also
ZFObject, ZFOBJECT_REGISTER, ZFOBJECT_DECLARE

◆ ZFOBJECT_REGISTER

#define ZFOBJECT_REGISTER ( T_ZFObject,
... )

register ZFObject to ZFClass map

usage:

// in something.h:
zfclass YourClass : zfextend BaseClass {
ZFOBJECT_DECLARE(YourClass, BaseClass)
};
// in something.cpp:
#include "something.h"
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#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 ZFOBJECT_REGISTER(T_ZFObject,...)
register ZFObject to ZFClass map
Definition ZFObjectDeclare.h:204

you only need this if you want to use reflection, such as ZFClass::classForName

detailed:
ZFClass map is set up when YourClass::ClassData is called, which may occurred when:

  • YourClass::ClassData or subclass's ClassData, is explicitly called
  • ever created a instance of YourClass or subclass
  • ZFOBJECT_REGISTER(YourClass) is added to a certain h or cpp file

this macro actually do only one thing: declare a static global variable to make sure YourClass::ClassData is called
so if you add it to cpp file, only one dummy global variable is defined
on the other hand, if you add it to h file, multiple dummy variables are defined, as more as the cpp files which include the h file

See also
ZFOBJECT_DECLARE, ZFClass



all ZFMethod and ZFProperty would also be registered automatically when it's owner class registered, for only one exception:

  • the method or property's owner class is abstract and no other class inherit the class, typically this has no other side effect, since you can't alloc abstract class by reflection

◆ ZFOBJECT_PRIVATE_ALLOC

#define ZFOBJECT_PRIVATE_ALLOC ( ...)

mark this object can not be allocated directly

usage:

ZFOBJECT_PRIVATE_ALLOC("hint about why it's private")
};
#define ZFOBJECT_PRIVATE_ALLOC(...)
mark this object can not be allocated directly
Definition ZFObjectDeclare.h:240
base class of all objects
Definition ZFObjectCore.h:209

when declared, the object can not be allocated by zfAlloc series directly, and can only be allocated by reflection (ZFClass::newInstance)

◆ ZFOBJECT_ON_INIT_INLINE_1

#define ZFOBJECT_ON_INIT_INLINE_1 ( ZFMP_0)

util macro for subclass to declare ZFObject::objectOnInit as ZFMethod

note: you must call this->objectOnInit(); before anything

◆ ZFOBJECT_ON_INIT_USER_REGISTER_1

#define ZFOBJECT_ON_INIT_USER_REGISTER_1 ( methodInvokerAction,
ownerClassSig,
ZFMP_0 )

util macro to declare ZFObject::objectOnInit as ZFMETHOD_USER_REGISTER_1

note: you must not call this->objectOnInit();

◆ ZFObjectOnInitUserRegister_1

#define ZFObjectOnInitUserRegister_1 ( resultMethod,
methodInvokerAction,
ownerClass,
ZFMP_0 )

util macro to declare ZFObject::objectOnInit as ZFMethodUserRegister_1

note: you must not call this->objectOnInit();

Function Documentation

◆ ZFObjectOnInitDynamicRegister() [1/2]

const ZFMethod * ZFObjectOnInitDynamicRegister ( const ZFClass * cls,
const ZFMP & methodParam,
const ZFListener & methodImpl,
zfstring * errorHint = 0 )
extern

util to declare ZFObject::objectOnInit as ZFMethodDynamicRegister

note: you have no need to call invokerObject->objectOnInit();

◆ ZFObjectOnInitDynamicRegister() [2/2]

const ZFMethod * ZFObjectOnInitDynamicRegister ( const ZFClass * cls,
const ZFMethodDynamicRegisterParam & param,
zfstring * errorHint = 0 )
extern

util to declare ZFObject::objectOnInit as ZFMethodDynamicRegister

note: you have no need to call invokerObject->objectOnInit();