From 6d58e8e90b0173e750f16337d9ccfd4cb40197bd Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 27 Aug 2019 20:26:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=BC=95=E6=93=8E=E6=94=B9?= =?UTF-8?q?=E8=BF=9B(=E6=9C=AA=E5=AE=8C=E6=88=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/plugin/ExternalPlugIn.h | 2 +- inc/hgl/plugin/PlugIn.h | 10 ++++------ inc/hgl/plugin/PlugInInterface.h | 2 +- inc/hgl/plugin/PlugInManage.h | 16 ++++++++-------- inc/hgl/thread/Thread.h | 2 +- inc/hgl/type/LRUCache.cpp | 2 +- inc/hgl/type/Stack.cpp | 2 +- src/FileSystem/FileSystem.cpp | 2 +- src/IO/FileAccess.cpp | 2 +- src/Log/LogFile.cpp | 4 ++-- src/Log/Loginfo.cpp | 32 ++++++++++++++------------------ src/PlugIn/ExternalModule.cpp | 2 +- src/PlugIn/ExternalPlugIn.cpp | 2 +- src/PlugIn/PlugInManage.cpp | 19 +++++++++++++++---- 14 files changed, 52 insertions(+), 47 deletions(-) diff --git a/inc/hgl/plugin/ExternalPlugIn.h b/inc/hgl/plugin/ExternalPlugIn.h index acd6c19..e5ebb99 100644 --- a/inc/hgl/plugin/ExternalPlugIn.h +++ b/inc/hgl/plugin/ExternalPlugIn.h @@ -37,7 +37,7 @@ namespace hgl virtual ~ExternalPlugIn(); void Free(); ///<释放插件文件 - bool Load(const UTF16String &,const OSString &); ///<加载插件 + bool Load(const OSString &,const OSString &); ///<加载插件 };//class ExternalPlugIn:public PlugIn }//namespace hgl #endif//HGL_EXTERNAL_PLUG_IN_INCLUDE diff --git a/inc/hgl/plugin/PlugIn.h b/inc/hgl/plugin/PlugIn.h index fb025a4..cf8ecd1 100644 --- a/inc/hgl/plugin/PlugIn.h +++ b/inc/hgl/plugin/PlugIn.h @@ -2,7 +2,6 @@ #define HGL_PLUGIN_INCLUDE #include -#include namespace hgl { /** @@ -15,18 +14,16 @@ namespace hgl uint ref_count; uint ver; - UTF16String name; + OSString name; UTF16String intro; OSString filename; ///<插件文件名 - PlugInInterface *plugin_interface; - public: const uint GetVersion ()const{return ver;} ///<取得插件版本 + const OSString & GetName ()const{return name;} ///<取得插件名称 const UTF16String & GetIntro ()const{return intro;} ///<取得插件介绍 - const UTF16String & GetName ()const{return name;} ///<取得插件名称 public: @@ -34,13 +31,14 @@ namespace hgl { ref_count=0; ver=0; - plugin_interface=nullptr; } virtual ~PlugIn(); uint add_ref(){return ++ref_count;} uint release_ref(){return --ref_count;} + + virtual bool GetInterface(uint,void *)=0; };//class PlugIn }//namespace hgl #endif//HGL_PLUGIN_INCLUDE diff --git a/inc/hgl/plugin/PlugInInterface.h b/inc/hgl/plugin/PlugInInterface.h index ab86063..4a74de6 100644 --- a/inc/hgl/plugin/PlugInInterface.h +++ b/inc/hgl/plugin/PlugInInterface.h @@ -12,7 +12,7 @@ namespace hgl typedef bool (*GetPlugInInterfacePROC)(uint32,void *); ///<取得插件接口 typedef void (*SetPlugInInterfacePROC)(void *,void *); ///<设置插件接口 - typedef bool (*LoadInterfaceByNamePROC)(const u16char *,uint32,void *); ///<取得接口 + typedef bool (*LoadInterfaceByNamePROC)(const char *,uint32,void *); ///<取得接口 typedef bool (*LoadInterfaceByIndexPROC)(uint32,uint32,void *); ///<取得接口 struct PlugInInterface diff --git a/inc/hgl/plugin/PlugInManage.h b/inc/hgl/plugin/PlugInManage.h index 03e1e3d..c5ed464 100644 --- a/inc/hgl/plugin/PlugInManage.h +++ b/inc/hgl/plugin/PlugInManage.h @@ -9,15 +9,15 @@ namespace hgl /** * 插件管理 */ - class PlugInManage:public ResManage + class PlugInManage:public ResManage { - UTF16String name; ///<插件类目名称(必须符合代码名称规则) + OSString name; ///<插件类目名称(必须符合代码名称规则) - OSStringList findpath; ///<插件查找目录 + OSStringList findpath; ///<插件查找目录 public: - PlugInManage(const UTF16String &n) + PlugInManage(const OSString &n) { name=n; } @@ -25,13 +25,13 @@ namespace hgl virtual ~PlugInManage(); bool RegistryPlugin(PlugIn *); ///<注册一个内置插件 - uint UnregistryPlugin(const UTF16String &); ///<释放一个内置插件 + uint UnregistryPlugin(const OSString &); ///<释放一个内置插件 bool AddFindPath (const OSString &path); ///<添加一个插件查找目录 - PlugIn *LoadPlugin (const UTF16String &,const OSString &); ///<加载一个外部插件,明确指定全路径文件名 - PlugIn *LoadPlugin (const UTF16String &); ///<加载一个外部插件,自行查找 - bool UnloadPlugin(const UTF16String &); ///<释放一个外部插件 + PlugIn *LoadPlugin (const OSString &,const OSString &); ///<加载一个外部插件,明确指定全路径文件名 + PlugIn *LoadPlugin (const OSString &); ///<加载一个外部插件,自行查找 + bool UnloadPlugin(const OSString &); ///<释放一个外部插件 };//class PlugInManage:public ResManage /** diff --git a/inc/hgl/thread/Thread.h b/inc/hgl/thread/Thread.h index e8a07cc..6fb9449 100644 --- a/inc/hgl/thread/Thread.h +++ b/inc/hgl/thread/Thread.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include namespace hgl { diff --git a/inc/hgl/type/LRUCache.cpp b/inc/hgl/type/LRUCache.cpp index 74e969b..e856365 100644 --- a/inc/hgl/type/LRUCache.cpp +++ b/inc/hgl/type/LRUCache.cpp @@ -1,7 +1,7 @@ #ifndef HGL_TYPE_LRU_CACHE_CPP #define HGL_TYPE_LRU_CACHE_CPP -#include +#include namespace hgl { /** diff --git a/inc/hgl/type/Stack.cpp b/inc/hgl/type/Stack.cpp index 9126ba7..69db7e0 100644 --- a/inc/hgl/type/Stack.cpp +++ b/inc/hgl/type/Stack.cpp @@ -1,7 +1,7 @@ #ifndef HGL_STACK_CPP #define HGL_STACK_CPP -#include +#include namespace hgl { /** diff --git a/src/FileSystem/FileSystem.cpp b/src/FileSystem/FileSystem.cpp index 20c368c..6a6771d 100644 --- a/src/FileSystem/FileSystem.cpp +++ b/src/FileSystem/FileSystem.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/src/IO/FileAccess.cpp b/src/IO/FileAccess.cpp index 2d33cd8..5c9f899 100644 --- a/src/IO/FileAccess.cpp +++ b/src/IO/FileAccess.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #if HGL_OS != HGL_OS_Windows #include diff --git a/src/Log/LogFile.cpp b/src/Log/LogFile.cpp index d995f7c..4b0b913 100644 --- a/src/Log/LogFile.cpp +++ b/src/Log/LogFile.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include diff --git a/src/Log/Loginfo.cpp b/src/Log/Loginfo.cpp index 4a352bd..352b096 100644 --- a/src/Log/Loginfo.cpp +++ b/src/Log/Loginfo.cpp @@ -54,8 +54,7 @@ namespace hgl Date d; Time t; - d.Sync(); - t.Sync(); + ToDateTime(d,t); const OSString str= OS_TEXT("Create Log Date/Time: ")+ OSString(d.GetYear ())+OS_TEXT("-")+ @@ -119,17 +118,8 @@ namespace hgl WriteLog }; - bool GetLogInterface(uint32 ver,void *data) - { - if(ver!=3) - return(false); - - memcpy(data,&LogInterface3,sizeof(LogInterface)); - return(true); - } - /** - * 日志插件,一个模拟的接口 + * 日志插件 */ class LogPlugIn:public PlugIn ///日志插件 { @@ -137,12 +127,20 @@ namespace hgl LogPlugIn() { - type=pitLog; + ver=1; + name=OS_TEXT("Log"); + intro=U16_TEXT("unicode text log module."); - name=OS_TEXT("unicode text log module."); - filename=OS_TEXT("LogInfo.cpp"); + filename=OS_TEXT("Loginfo.cpp"); + } - GetInterface=GetLogInterface; + bool GetInterface(uint ver,void *data) override + { + if(ver!=3||!data) + return(false); + + memcpy(data,&LogInterface3,sizeof(LogInterface)); + return(true); } };//class LogPlugIn }//namespace logger @@ -164,8 +162,6 @@ namespace hgl delete li; li=nullptr; - UnloadPlugIn(pi); - return(nullptr); } diff --git a/src/PlugIn/ExternalModule.cpp b/src/PlugIn/ExternalModule.cpp index 7a5b350..549bf27 100644 --- a/src/PlugIn/ExternalModule.cpp +++ b/src/PlugIn/ExternalModule.cpp @@ -1,5 +1,5 @@ #include -#include +#include namespace hgl { diff --git a/src/PlugIn/ExternalPlugIn.cpp b/src/PlugIn/ExternalPlugIn.cpp index 0ca3235..59d23b0 100644 --- a/src/PlugIn/ExternalPlugIn.cpp +++ b/src/PlugIn/ExternalPlugIn.cpp @@ -26,7 +26,7 @@ namespace hgl status=PlugInStatus::NO_LOAD; } - bool ExternalPlugIn::Load(const UTF16String &pn,const OSString &fn) + bool ExternalPlugIn::Load(const OSString &pn,const OSString &fn) { if(pi_module) return(true); diff --git a/src/PlugIn/PlugInManage.cpp b/src/PlugIn/PlugInManage.cpp index a30dab2..2be4262 100644 --- a/src/PlugIn/PlugInManage.cpp +++ b/src/PlugIn/PlugInManage.cpp @@ -9,7 +9,7 @@ namespace hgl { if(!pi)return(false); - const UTF16String &pi_name=pi->GetName(); + const OSString &pi_name=pi->GetName(); if(this->Find(pi_name)) return(false); @@ -17,7 +17,7 @@ namespace hgl return this->Add(pi_name,pi); } - uint PlugInManage::UnregistryPlugin(const UTF16String &pi_name) + uint PlugInManage::UnregistryPlugin(const OSString &pi_name) { PlugIn *pi=this->Find(pi_name); @@ -42,7 +42,7 @@ namespace hgl return(true); } - PlugIn *PlugInManage::LoadPlugin(const UTF16String &pi_name,const OSString &filename) + PlugIn *PlugInManage::LoadPlugin(const OSString &pi_name,const OSString &filename) { if(pi_name.IsEmpty())return(nullptr); if(filename.IsEmpty())return(nullptr); @@ -64,7 +64,7 @@ namespace hgl return(nullptr); } - PlugIn *PlugInManage::LoadPlugin(const UTF16String &pi_name) + PlugIn *PlugInManage::LoadPlugin(const OSString &pi_name) { if(pi_name.IsEmpty())return(nullptr); @@ -99,5 +99,16 @@ namespace hgl epi->Free(); } + + delete epi; + return(nullptr); + } + + bool PlugInManage::UnloadPlugin(const OSString &pi_name) + { + if(pi_name.IsEmpty())return(nullptr); + + this->Release(pi_name); + return(true); } }//namespace hgl