ZFFramework
 
Loading...
Searching...
No Matches
ZFClass.h File Reference

meta data for ZFObject More...

#include "zfautoFwd.h"
#include "ZFObjectObserver.h"

Go to the source code of this file.

Classes

class  ZFClassInstanceObserverAddParam
 see ZFClass::instanceObserverAdd More...
 
class  ZFClass
 ZFObject's class info. More...
 

Namespaces

namespace  ZFGlobalEvent
 

 

Macros

#define ZFObjectTagKeyword_newInstanceGenericFailed
 used to mark object allocation failed for ZFClass::newInstanceGenericCheck
 
#define ZFClassDataUpdateObserver()
 see ZFGlobalEvent::E_ClassDataUpdate
 
#define ZFCoreCriticalClassNotTypeOf(cls, desired)
 log that likes "[file function (line)] class xxx not type of xxx"
 
#define ZFCoreCriticalClassNotTypeOfDetail(callerInfo, cls, desired)
 see ZFCoreCriticalClassNotTypeOf
 
#define ZFCONV_REG(dstCls, srcCls)
 see zfconv
 

Typedefs

typedef zfbool(* zfconvImpl) (zfauto &ret, ZFObject *obj)
 see zfconv
 

Functions

void ZFClassGetAllT (ZFCoreArray< const ZFClass * > &ret)
 see ZFClassGetAll
 
ZFCoreArray< const ZFClass * > ZFClassGetAll (void)
 get all class currently registered, for debug use only
 
zfidentity ZFGlobalEvent::E_ClassDataUpdate (void)
 see ZFObject::observerNotify
 
void ZFClassAlias (const ZFClass *cls, const zfstring &aliasNameFull)
 alias class to a new name
 
void ZFClassAliasRemove (const ZFClass *cls, const zfstring &aliasNameFull)
 see ZFClassAlias
 
zfauto zfconv (const zfstring &cls, ZFObject *obj, zfbool implicitConv=_ZFT_t_zftrue)
 object conversion
 
zfauto zfconv (const ZFClass *cls, ZFObject *obj, zfbool implicitConv=_ZFT_t_zftrue)
 see zfconv
 
zfbool zfconvT (zfauto &ret, const zfstring &cls, ZFObject *obj, zfbool implicitConv=_ZFT_t_zftrue)
 see zfconv
 
zfbool zfconvT (zfauto &ret, const ZFClass *cls, ZFObject *obj, zfbool implicitConv=_ZFT_t_zftrue)
 see zfconv
 

Detailed Description

meta data for ZFObject

Macro Definition Documentation

◆ ZFObjectTagKeyword_newInstanceGenericFailed

#define ZFObjectTagKeyword_newInstanceGenericFailed

used to mark object allocation failed for ZFClass::newInstanceGenericCheck

when object created by ZFClass::newInstanceGenericBegin, it's possible to have mismatch param for generic invoke of objectOnInit, you may set an error message to the allocated object by ZFObject::objectTag with this as key and the error message (v_zfstring) as value, to tell ZFClass::newInstanceGenericCheck that the allocation failed

◆ ZFClassDataUpdateObserver

#define ZFClassDataUpdateObserver ( )

see ZFGlobalEvent::E_ClassDataUpdate

Warning
app code can add observer to this event, but must not manually notify this event
also, take care of performance

Function Documentation

◆ ZFClassAlias()

void ZFClassAlias ( const ZFClass * cls,
const zfstring & aliasNameFull )
extern

alias class to a new name

class alias only affects reflection, typically used for script binding
you can alias more than one name to same class, all of the aliased class points to same original ZFClass

// the aliased class is exactly same of the original,
// so the reflected class name still prints "ZFObject"
void ZFClassAlias(const ZFClass *cls, const zfstring &aliasNameFull)
alias class to a new name
#define ZFLogTrim(...)
see ZFLog
Definition ZFLog.h:80
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:180
static const ZFClass * ClassData(void)
get class info
Definition ZFObjectCore.h:207
See also
ZFMethodAlias

◆ zfconv()

zfauto zfconv ( const zfstring & cls,
ZFObject * obj,
zfbool implicitConv = _ZFT_t_zftrue )
extern

object conversion

some objects can be cast implicitly, zfstring to const void * for example, this method was designed for this, usage:

// register once
ret = zfobj<v_zfptr>(obj->zfv.cString());
// usually, the result object should retain the obj,
// to prevent unsafe pointer reference
ret->objectTag("zfconv", obj);
return zftrue;
}
// use, return converted object, or null if not available or convert failed
// or use with explicit check
zfauto ret;
// conversion was success
}
#define ZFCONV_REG(dstCls, srcCls)
see zfconv
Definition ZFClass.h:963
zfbool zfconvT(zfauto &ret, const zfstring &cls, ZFObject *obj, zfbool implicitConv=_ZFT_t_zftrue)
see zfconv
zfauto zfconv(const zfstring &cls, ZFObject *obj, zfbool implicitConv=_ZFT_t_zftrue)
object conversion
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
const zfstring & ZFTypeId_zfptr(void)
Definition ZFTypeId_spec.h:82
type wrapper for ZFTypeId::Value
Definition ZFTypeId_spec.h:82
type wrapper for ZFTypeId::Value
Definition ZFTypeId_CoreType.h:194
a ZFObject holder which would release content object automatically when destroyed
Definition zfautoFwd.h:34
util class to alloc and hold ZFObject type
Definition ZFObjectAutoPtr.h:79

possible returns:

  • original object, if can be cast by zfcast
  • empty object, if cls is ZFTypeIdWrapper and obj is null
  • null, if obj is null
  • new object converted by ZFCONV_REG

extra possible returns if implicitConv is true:

  • new object by invoking constructor of desired class with source object as param
  • new object by ZFDI_objectFromString