improved PlugInManage

This commit is contained in:
hyzboy 2022-03-31 21:59:14 +08:00
parent e17d3d6b9f
commit 0862db3d03
5 changed files with 32 additions and 8 deletions

View File

@ -47,7 +47,6 @@ namespace hgl
bool GetLocalAppdataPath(OSString &); ///<取得当前用户应用程序数据存放路径
bool GetOSLibararyPath(OSString &); ///<取得操作系统共用动态库路径
/**
* @param filename

View File

@ -17,12 +17,8 @@ namespace hgl
public:
PlugInManage(const OSString &n)
{
name=n;
}
virtual ~PlugInManage();
PlugInManage(const OSString &n);
virtual ~PlugInManage()=default;
bool RegistryPlugin(PlugIn *); ///<注册一个内置插件
uint UnregistryPlugin(const OSString &); ///<释放一个内置插件

View File

@ -204,6 +204,7 @@ namespace hgl
}
T * get ()const{return sd?sd->data:0;}
const T * const_get ()const{return sd?sd->data:0;}
virtual bool valid ()const{return sd;}
int use_count ()const{return sd?sd->count:-1;}
bool only ()const{return sd?sd->count==1:true;}

View File

@ -19,7 +19,9 @@ namespace hgl
{
if(!pi_module)return;
plugin_interface->Close();
if(plugin_interface->Close)
plugin_interface->Close();
plugin_interface=nullptr;
delete pi_module;
@ -74,6 +76,9 @@ namespace hgl
{
if(!plugin_interface)return(false);
if(!plugin_interface->GetInterface)
return(false);
return plugin_interface->GetInterface(ver,interface_data);
}
}//namespace hgl

View File

@ -5,6 +5,29 @@ namespace hgl
{
using namespace filesystem;
PlugInManage::PlugInManage(const OSString &n)
{
name=OS_TEXT("CMP.")+n;
OSString pn;
if(filesystem::GetCurrentPath(pn))
{
AddFindPath(pn);
pn=MergeFilename(pn,OS_TEXT("Plug-ins"));
AddFindPath(pn);
}
if(filesystem::GetCurrentProgramPath(pn))
{
AddFindPath(pn);
pn=MergeFilename(pn,OS_TEXT("Plug-ins"));
AddFindPath(pn);
}
}
bool PlugInManage::RegistryPlugin(PlugIn *pi)
{
if(!pi)return(false);