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
 
 ZFDynamic (const zfstring &regTag)
 construct with regTag
 
ZFDynamicregTag (const zfstring &regTag)
 util to make the registration able to be called more than once
 
const zfstringregTag (void) const
 see regTag
 
void removeAll (void)
 see ZFDynamic
 
const ZFCoreArray< const ZFClass * > & allClass (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< zfidentity > & allEvent (void) const
 see ZFDynamic
 
ZFDynamicclassBegin (const zfstring &className, const zfstring &parentClassName, ZFObject *classDynamicRegisterUserData=zft_zfnull)
 see ZFDynamic
 
ZFDynamicclassBegin (const zfstring &className, const ZFClass *classParent=ZFObject::ClassData(), ZFObject *classDynamicRegisterUserData=zft_zfnull)
 see ZFDynamic
 
ZFDynamicclassBegin (const ZFClass *cls)
 see ZFDynamic
 
ZFDynamicclassEnd (void)
 see ZFDynamic
 
ZFDynamicclassImplement (const ZFClass *clsToImplement)
 see ZFImplementDynamicRegister
 
ZFDynamicclassCanAllocPublic (zfbool value)
 see ZFClass::classCanAllocPublic
 
ZFDynamiconEvent (zfidentity eventId, const ZFListener &callback, ZFLevel level=ZFLevelAppNormal)
 see ZFDynamic
 
ZFDynamiconInit (const ZFListener &callback)
 see ZFDynamic and onEvent
 
ZFDynamiconInitFinish (const ZFListener &callback)
 see ZFDynamic and onEvent
 
ZFDynamiconDeallocPrepare (const ZFListener &callback)
 see ZFDynamic and onEvent
 
ZFDynamiconDealloc (const ZFListener &callback)
 see ZFDynamic and onEvent
 
ZFDynamiconInit (const ZFMP &mp, const ZFListener &impl=zft_zfnull)
 util to register custom constructor
 
ZFDynamicobjectInfoImplByProp (void)
 util to implement ZFObject::objectInfoImpl by ZFObjectPrettyInfo
 
ZFDynamicobjectInfoImplByStruct (void)
 util to implement ZFObject::objectInfoImpl by ZFObjectShortInfo
 
ZFDynamicobjectHashImplByProp (void)
 util to implement ZFObject::objectHashImpl by hash all properties
 
ZFDynamicobjectCompareImplByProp (void)
 util to implement ZFObject::objectCompareImpl by ZFPropertyAllEqual
 
ZFDynamicobjectCompareValueImplByProp (void)
 util to implement ZFObject::objectCompareValueImpl by ZFPropertyAllEqual
 
ZFDynamicNSBegin (const zfstring &methodNamespace)
 see ZFDynamic
 
ZFDynamicNSEnd (void)
 see ZFDynamic
 
ZFDynamicenumBegin (const zfstring &enumClassName)
 see ZFDynamic
 
ZFDynamicenumBeginFlags (const zfstring &enumClassName)
 see ZFDynamic
 
ZFDynamicenumValue (const zfstring &enumName, zfuint enumValue=((zfuint) -1))
 see ZFDynamic
 
ZFDynamicenumEnd (zfuint enumDefault=((zfuint) -1))
 see ZFDynamic
 
ZFDynamicevent (const zfstring &name)
 register a event, see also ZFEVENT ZFEVENT_GLOBAL
 
ZFDynamicmethod (const zfstring &returnTypeId, const zfstring &methodName, const ZFMP &methodParam, const ZFListener &methodImpl, ZFMethodType methodType=ZFMethodTypeVirtual, ZFMethodAccessType methodAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
 
ZFDynamicmethod (const ZFMethodDynamicRegisterParam &param)
 see ZFDynamic
 
ZFDynamicstaticMethod (const zfstring &returnTypeId, const zfstring &methodName, const ZFMP &methodParam, const ZFListener &methodImpl)
 see ZFDynamic
 
ZFDynamicsingleton (const zfstring &methodName=zfstring::shared("instance"))
 util to register a static method that holds singleton instance
 
ZFDynamicproperty (const zfstring &propertyTypeId, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
 
ZFDynamicproperty (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
 
ZFDynamicpropertyWithInit (const zfstring &propertyTypeId, const zfstring &propertyName, const ZFListener &propertyInitValue, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see property
 
ZFDynamicpropertyWithInit (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, const ZFListener &propertyInitValue, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see ZFDynamic
 
ZFDynamicproperty (const ZFPropertyDynamicRegisterParam &param)
 see ZFDynamic
 
ZFDynamicpropertyOnInit (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
 
ZFDynamicpropertyOnUpdate (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
 
ZFDynamicpropertyOnAttach (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
 
ZFDynamicpropertyOnDetach (const zfstring &propertyName, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
 
ZFDynamicpropertyLifeCycle (const zfstring &propertyName, ZFPropertyLifeCycle lifeCycle, const ZFListener &callback)
 util to ZFPropertyDynamicRegisterLifeCycle
 
ZFDynamicstaticProperty (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
 
ZFDynamicstaticProperty (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, ZFObject *propertyInitValue=zft_zfnull, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see staticProperty
 
ZFDynamicstaticPropertyWithInit (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
 
ZFDynamicstaticPropertyWithInit (const ZFClass *propertyClassOfRetainProperty, const zfstring &propertyName, const ZFListener &propertyInitValue, ZFMethodAccessType setterAccessType=ZFMethodAccessTypePublic, ZFMethodAccessType getterAccessType=ZFMethodAccessTypePublic)
 see staticPropertyWithInit
 
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:197
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
to make it more convenient for script language, you may also use regTag to make the registration looks like singleton registration

Member Function Documentation

◆ exportTag()

static 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

◆ regTag()

ZFDynamic & ZFDynamic::regTag ( const zfstring & regTag)

util to make the registration able to be called more than once

by default, dynamic register would fail if contents already exists, that's not very convenient for script languages
to solve this, you may use this method to mark the registration, which would automatically unregister old ones if exists, identified by that regTag

◆ 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:158
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:157

◆ 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()

static 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: