插件接口更新

This commit is contained in:
hyzboy 2019-08-29 15:28:49 +08:00
parent 6d58e8e90b
commit bc0475fd9d
4 changed files with 32 additions and 14 deletions

View File

@ -22,14 +22,15 @@ namespace hgl
protected: protected:
LogLevel min_level; ///<最小输出级别 LogLevel min_level; ///<最小输出级别
UTF16String project_code; Logger *parent; ///<上级输出器
public: public:
Logger(LogLevel l){min_level=l;} Logger(LogLevel l,Logger *pl=nullptr){min_level=l;parent=pl;}
virtual ~Logger()=default; virtual ~Logger()=default;
const LogLevel GetLevel()const{return min_level;} ///<取得最小输出级别 const LogLevel GetLevel ()const{return min_level;} ///<取得最小输出级别
Logger * GetParent (){return parent;} ///<取得上级日志输出器
virtual void Close()=0; ///<关闭日志 virtual void Close()=0; ///<关闭日志

View File

@ -5,6 +5,8 @@
#include<hgl/platform/ExternalModule.h> #include<hgl/platform/ExternalModule.h>
namespace hgl namespace hgl
{ {
struct PlugInInterface;
/** /**
* *
*/ */
@ -27,6 +29,8 @@ namespace hgl
ExternalModule *pi_module; ExternalModule *pi_module;
PlugInInterface *plugin_interface;
public: public:
PlugInStatus GetStatus()const{return status;} PlugInStatus GetStatus()const{return status;}
@ -36,8 +40,10 @@ namespace hgl
ExternalPlugIn(); ExternalPlugIn();
virtual ~ExternalPlugIn(); virtual ~ExternalPlugIn();
void Free(); ///<释放插件文件 void Free(); ///<释放插件文件
bool Load(const OSString &,const OSString &); ///<加载插件 bool Load(const OSString &,const OSString &); ///<加载插件
virtual bool GetInterface(uint,void *) override;
};//class ExternalPlugIn:public PlugIn };//class ExternalPlugIn:public PlugIn
}//namespace hgl }//namespace hgl
#endif//HGL_EXTERNAL_PLUG_IN_INCLUDE #endif//HGL_EXTERNAL_PLUG_IN_INCLUDE

View File

@ -167,12 +167,11 @@ namespace hgl
void CloseLog() void CloseLog()
{ {
if(li) if(!li)return;
{
li->Close(); li->Close();
delete li; delete li;
li=nullptr; li=nullptr;
}
} }
void Log(LogLevel level,const u16char *str,int size) void Log(LogLevel level,const u16char *str,int size)

View File

@ -7,6 +7,7 @@ namespace hgl
{ {
status=PlugInStatus::NONE; status=PlugInStatus::NONE;
pi_module=nullptr; pi_module=nullptr;
plugin_interface=nullptr;
} }
ExternalPlugIn::~ExternalPlugIn() ExternalPlugIn::~ExternalPlugIn()
@ -19,6 +20,7 @@ namespace hgl
if(!pi_module)return; if(!pi_module)return;
plugin_interface->Close(); plugin_interface->Close();
plugin_interface=nullptr;
delete pi_module; delete pi_module;
pi_module=nullptr; pi_module=nullptr;
@ -44,7 +46,10 @@ namespace hgl
{ {
plugin_interface=init_proc(); plugin_interface=init_proc();
if(plugin_interface) if(plugin_interface
&&plugin_interface->GetVersion
&&plugin_interface->GetIntro
&&plugin_interface->GetInterface)
{ {
status=PlugInStatus::COMPLETE; status=PlugInStatus::COMPLETE;
@ -64,4 +69,11 @@ namespace hgl
status=PlugInStatus::LOAD_FAILED; status=PlugInStatus::LOAD_FAILED;
return(false); return(false);
} }
bool ExternalPlugIn::GetInterface(uint ver,void *interface_data)
{
if(!plugin_interface)return(false);
return plugin_interface->GetInterface(ver,interface_data);
}
}//namespace hgl }//namespace hgl