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

util to import resource or class More...

#include "ZFObjectIO.h"

Go to the source code of this file.

Namespaces

namespace  ZFGlobalEvent
 

 

Functions

zfidentity ZFGlobalEvent::E_ZFImportBegin (void)
 see ZFObject::observerNotify
 
zfidentity ZFGlobalEvent::E_ZFImportEnd (void)
 see ZFObject::observerNotify
 
zfauto zfimport (const zfstring &path, const ZFPathInfo &pathInfo=(zft_zfnull))
 util to import resource or class
 
zfauto zfimportCacheRemove (const zfstring &callbackId)
 remove the cache created by zfimport
 
void zfimportCacheRemoveAll ()
 remove all cache created by zfimport
 

Detailed Description

util to import resource or class

Function Documentation

◆ zfimport()

zfauto zfimport ( const zfstring & path,
const ZFPathInfo & pathInfo = (zft_zfnull) )
extern

util to import resource or class

this method is useful for script to achieve "import" or "require" of other script language such as Javascript

what the path and pathInfo means:

  • when path can be parsed as ZFPathInfoFromString, it would used to detect target
  • when pathInfo is not specified, the path would be used as ZFInputForRes
  • when pathInfo is specified, the path is the relative path to pathInfo, and would be used as ZFInputForLocal


how the import works:

  • when pathInfo/path points to a file
    • ZFObjectIOLoad would be called to load the content, and return the result
    • when load failed, nothing happen, and null would be returned
  • when pathInfo/path points to a directory
    • ZFObjectIOLoad would be called for each file under the directory, and a ZFMap would be returned, contains all the result, key is a v_zfstring holds the relative path name to pathInfo/path, and value is the result returned by ZFObjectIOLoad
    • when any content load failed, nothing happen, and a ZFMap would be returned contains all successful loaded item


about cache logic: