ZFFramework
Loading...
Searching...
No Matches
ZFDynamic Class Reference

util class to dynamic register class/method/property More...

#include <ZFDynamicRegisterUtil.h>

Public Member Functions

 ZFDynamic (void)
 main constructor
void removeAll (void)
 see ZFDynamic
const ZFCoreArray< const ZFClass * > & allClass (void) const
 see ZFDynamic
const ZFCoreArray< ZFDynamicImplementInfo > & allImplement (void) const
 see ZFDynamic
const ZFCoreArray< const ZFClass * > & allEnum (void) const
 see ZFDynamic
const ZFCoreArray< const ZFMethod * > & allMethod (void) const
 see ZFDynamic
const ZFCoreArray< const ZFProperty * > & allProperty (void) const
 see ZFDynamic
const ZFCoreArray< ZFDynamicPropLifeCycleInfo > & allPropertyLifeCycle (void) const
 see ZFDynamic
const ZFCoreArray< zfidentity > & allEvent (void) const
 see ZFDynamic
const ZFCoreArray< ZFDynamicEventImplInfo > & allEventImpl (void) const
 see ZFDynamic
ZFDynamic & classBegin (const zfstring &className, const zfstring &parentClassName, ZFObject *classDynamicRegisterUserData=zft_zfnull)
 see ZFDynamic
ZFDynamic & classBegin (const zfstring &className, const ZFClass *classParent=ZFObject::ClassData(), ZFObject *classDynamicRegisterUserData=zft_zfnull)
 see ZFDynamic
ZFDynamic & classBegin (const ZFClass *cls)
 see ZFDynamic
ZFDynamic & classEnd (void)
 see ZFDynamic
ZFDynamic & classImplement (const ZFClass *clsToImplement)
 see ZFImplementDynamicRegister
ZFDynamic & classCanAllocPublic (zfbool value)
 see ZFClass::classCanAllocPublic
ZFDynamic & onEvent (zfidentity eventId, const ZFListener &callback, ZFLevel level=ZFLevelAppNormal)
 see ZFDynamic
ZFDynamic & onInit (const ZFListener &callback)
 see ZFDynamic and onEvent
ZFDynamic & onInitFinish (const ZFListener &callback)
 see ZFDynamic and onEvent
ZFDynamic & onDeallocPrepare (const ZFListener &callback)
 see ZFDynamic and onEvent
ZFDynamic & onDealloc (const ZFListener &callback)
 see ZFDynamic and onEvent
ZFDynamic & onInit (const ZFMP &mp, const ZFListener &impl=zft_zfnull)
 util to register custom constructor
ZFDynamic & objectInfoImplByProp (void)
 util to implement ZFObject::objectInfoImpl by ZFObjectPrettyInfo
ZFDynamic & objectInfoImplByStruct (void)
 util to implement ZFObject::objectInfoImpl by ZFObjectShortInfo
ZFDynamic & objectHashImplByProp (void)
 util to implement ZFObject::objectHashImpl by hash all properties
ZFDynamic & objectCompareImplByProp (void)
 util to implement ZFObject::objectCompareImpl by ZFPropertyAllEqual
ZFDynamic & objectCompareValueImplByProp (void)
 util to implement ZFObject::objectCompareValueImpl by ZFPropertyAllEqual
ZFDynamic & NSBegin (const zfstring &methodNamespace)
 see ZFDynamic
ZFDynamic & NSEnd (void)
 see ZFDynamic
ZFDynamic & enumBegin (const zfstring &enumClassName)
 see ZFDynamic
ZFDynamic & enumBeginFlags (const zfstring &enumClassName)
 see ZFDynamic
ZFDynamic & enumValue (const zfstring &enumName, zfuint enumValue=((zfuint) -1))
 see ZFDynamic
ZFDynamic & enumEnd (zfuint enumDefault=((zfuint) -1))
 see ZFDynamic
ZFDynamic & event (const zfstring &name)
 register a event, see also ZFEVENT ZFEVENT_GLOBAL
ZFDynamic & method (const zfstring &returnTypeId, const zfstring &methodName, const ZFMP &methodParam, const ZFListener &methodImpl, ZFMethodType methodType=ZFMethodTypeVirtual, ZFMethodAccessType methodAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
ZFDynamic & method (const ZFMethodDynamicRegisterParam &param)
 see ZFDynamic
ZFDynamic & staticMethod (const zfstring &returnTypeId, const zfstring &methodName, const ZFMP &methodParam, const ZFListener &methodImpl)
 see ZFDynamic
ZFDynamic & singleton (const zfstring &methodName=zfstring::shared("instance",))
 util to register a static method that holds singleton instance
ZFDynamic & property (const zfstring &propertyTypeId, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
ZFDynamic & property (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
ZFDynamic & propertyWithInit (const zfstring &propertyTypeId, const zfstring &propertyName, const ZFListener &propertyInitValue, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see property
ZFDynamic & propertyWithInit (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, const ZFListener &propertyInitValue, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
ZFDynamic & property (const ZFPropertyDynamicRegisterParam &param)
 see ZFDynamic
ZFDynamic & propertyOnInit (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
ZFDynamic & propertyOnUpdate (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
ZFDynamic & propertyOnAttach (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
ZFDynamic & propertyOnDetach (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
ZFDynamic & propertyLifeCycle (const zfstring &propertyName, ZFPropertyLifeCycle lifeCycle, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
ZFDynamic & staticProperty (const zfstring &propertyTypeId, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 util to register setter and getter static method to simulate static property
ZFDynamic & staticProperty (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see staticProperty
ZFDynamic & staticPropertyWithInit (const zfstring &propertyTypeId, const zfstring &propertyName, const ZFListener &propertyInitValue, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 util to register setter and getter static method to simulate static property
ZFDynamic & staticPropertyWithInit (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, const ZFListener &propertyInitValue, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see staticPropertyWithInit
zfstring currentScope (void) const
 return fully namespace or class names for current scope
void objectInfoT (zfstring &ret) const
 see objectInfo
zfstring objectInfo (void) const
 return object info

Static Public Member Functions

static void exportTag (const ZFOutput &output, zfbool exportScope=_ZFT_t_zffalse, zfbool exportInternal=_ZFT_t_zftrue)
 util method to export all symbols to a tag file
static void onInitImpl (const ZFArgs &zfargs)
 util for impl to implement default behavior of onInit
static ZFCoreArray< ZFOutput > & errorCallbacks (void)
 callbacks which would be called when error occurred

Detailed Description

util class to dynamic register class/method/property

usage:

.classBegin(className [, parent, classDynamicRegisterUserData])
.event(name)
.method(returnTypeId, methodName, ZFMP()
.mp(paramTypeId0 [, paramName0, paramDefault0])
, methodImpl
)
.property(typeIdOrRetainClass, propertyName [, propertyInitValue])
.onEvent(ZFObject::E_ObjectAfterAlloc(), callback)
.onInit(callback)
.onDealloc(callback)
.singleton()
.classEnd()
.NSBegin(methodNamespace)
.event(name)
.method(returnTypeId, methodName, ZFMP()
.mp(paramTypeId0 [, paramName0, paramDefault0])
, methodImpl
)
.NSEnd()
.enumBegin(enumClassName) // or enumBeginFlags()
.enumValue(enumName [, enumValue])
.enumValue(enumName [, enumValue])
.enumEnd([enumDefault])
;
ZFDynamic & enumValue(const zfstring &enumName, zfuint enumValue=((zfuint) -1))
see ZFDynamic
ZFDynamic(void)
main constructor
util for ZFDynamic::method
Definition ZFMethodDynamicRegister.h:203
static zfidentity E_ObjectAfterAlloc(void)
see ZFObject::observerNotify

when any steps failed, errorCallbacks would be notified, and all further call would be ignored

you may store the returned ZFDynamic object, and use removeAll to remove all registered items at once, but you must ensure it's safe to do so, for example, no dynamic object depends on dynamic class or method

also, all contents registered by ZFDynamic would be unregistered during ZFLevelZFFrameworkNormal

Member Function Documentation

◆ exportTag()

void ZFDynamic::exportTag ( const ZFOutput & output,
zfbool exportScope = _ZFT_t_zffalse,
zfbool exportInternal = _ZFT_t_zftrue )
static

util method to export all symbols to a tag file

the tag file contains all of these in plain text format, one line for each:

  • class name
  • method namespace
  • method name (including property)
  • type id name

output ensured unique, while order are not ensured
anything that starts with "_ZFP_" would be ignored

this is useful to use ZFFramework in some script language which has no semantic completion, so that you can use keyword completion by using the tag file

◆ onEvent()

ZFDynamic & ZFDynamic::onEvent ( zfidentity eventId,
const ZFListener & callback,
ZFLevel level = ZFLevelAppNormal )

see ZFDynamic

attach observer to instance of current classBegin, by ZFClass::instanceObserverAdd

Note
only affect classes that are allocated after this method called

◆ onInit()

ZFDynamic & ZFDynamic::onInit ( const ZFMP & mp,
const ZFListener & impl = zft_zfnull )

util to register custom constructor

when impl valid, the impl would be used to init the object, otherwise, each init param would be treated as property to init the object

:classBegin('MyClass')
:property('zfstring', 'myProp')
:mp('zfstring', 'myProp')
, function(zfargs) -- when no impl supplied, this is the default behavior
zfargs:sender():myProp(zfargs:param0())
end)
ZFDynamic & onInit(const ZFListener &callback)
see ZFDynamic and onEvent
Definition ZFDynamicRegisterUtil.h:192
ZFDynamic & classEnd(void)
see ZFDynamic
ZFDynamic & classBegin(const zfstring &className, const zfstring &parentClassName, ZFObject *classDynamicRegisterUserData=zft_zfnull)
see ZFDynamic
ZFDynamic & property(const zfstring &propertyTypeId, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
see ZFDynamic

◆ event()

ZFDynamic & ZFDynamic::event ( const zfstring & name)

register a event, see also ZFEVENT ZFEVENT_GLOBAL

if within class scope (classBegin), YourClassName::E_YourEvent would be registered, otherwise, YourNamespace::E_YourEvent would be registered
registered event would include:

◆ method()

ZFDynamic & ZFDynamic::method ( const zfstring & returnTypeId,
const zfstring & methodName,
const ZFMP & methodParam,
const ZFListener & methodImpl,
ZFMethodType methodType = ZFMethodTypeVirtual,
ZFMethodAccessType methodAccessType = ZFMethodAccessTypePublic )

see ZFDynamic

util method to register method (global method or class member method)

usage:

.method("void", "myMethod", ZFMP()
.mp("zfint", "p0")
.mp("zfint", "p1", zfobj<v_zfint>(123))
, methodImpl);
util class to alloc and hold ZFObject type
Definition ZFObjectAutoPtr.h:72

◆ propertyWithInit()

ZFDynamic & ZFDynamic::propertyWithInit ( const zfstring & propertyTypeId,
const zfstring & propertyName,
const ZFListener & propertyInitValue,
ZFMethodAccessType setterAccessType = ZFMethodAccessTypePublic,
ZFMethodAccessType getterAccessType = ZFMethodAccessTypePublic )

see property

the propertyInitValue callback's sender would be the v_ZFProperty

◆ staticPropertyWithInit()

ZFDynamic & ZFDynamic::staticPropertyWithInit ( const zfstring & propertyTypeId,
const zfstring & propertyName,
const ZFListener & propertyInitValue,
ZFMethodAccessType setterAccessType = ZFMethodAccessTypePublic,
ZFMethodAccessType getterAccessType = ZFMethodAccessTypePublic )

util to register setter and getter static method to simulate static property

the propertyInitValue callback's sender would be the v_ZFMethod of owner getter or setter method

◆ errorCallbacks()

ZFCoreArray< ZFOutput > & ZFDynamic::errorCallbacks ( void )
static

callbacks which would be called when error occurred

by default, ZFOutputDefault would be attached during ZFFrameworkInit with ZFLevelZFFrameworkNormal


The documentation for this class was generated from the following file: