renamed to ObjectManage instead of ResManage
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
#define HGL_PLUG_IN_MANAGE_INCLUDE
|
||||
|
||||
#include<hgl/plugin/ExternalPlugIn.h>
|
||||
#include<hgl/type/ResManage.h>
|
||||
#include<hgl/type/ObjectManage.h>
|
||||
#include<hgl/type/StringList.h>
|
||||
namespace hgl
|
||||
{
|
||||
/**
|
||||
* 插件管理
|
||||
*/
|
||||
class PlugInManage:public ResManage<OSString,PlugIn>
|
||||
class PlugInManage:public ObjectManage<OSString,PlugIn>
|
||||
{
|
||||
OSString name; ///<插件类目名称(必须符合代码名称规则)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace hgl
|
||||
PlugIn *LoadPlugin (const OSString &,const OSString &); ///<加载一个外部插件,明确指定全路径文件名
|
||||
PlugIn *LoadPlugin (const OSString &); ///<加载一个外部插件,自行查找
|
||||
bool UnloadPlugin(const OSString &); ///<释放一个外部插件
|
||||
};//class PlugInManage:public ResManage<UTF16String,PlugIn>
|
||||
};//class PlugInManage:public ObjectManage<UTF16String,PlugIn>
|
||||
|
||||
/**
|
||||
* 插件注册模板
|
||||
|
@@ -1,17 +1,17 @@
|
||||
#ifndef HGL_RES_MANAGE_CPP
|
||||
#define HGL_RES_MANAGE_CPP
|
||||
#ifndef HGL_OBJECT_MANAGE_CPP
|
||||
#define HGL_OBJECT_MANAGE_CPP
|
||||
|
||||
#include<hgl/type/ResManage.h>
|
||||
#include<hgl/type/ObjectManage.h>
|
||||
namespace hgl
|
||||
{
|
||||
template<typename K,typename V>
|
||||
ResManage<K,V>::~ResManage()
|
||||
ObjectManage<K,V>::~ObjectManage()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
void ResManage<K,V>::Clear()
|
||||
void ObjectManage<K,V>::Clear()
|
||||
{
|
||||
int n=items.GetCount();
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace hgl
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
void ResManage<K,V>::ClearFree()
|
||||
void ObjectManage<K,V>::ClearFree()
|
||||
{
|
||||
int n=items.GetCount();
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace hgl
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
bool ResManage<K,V>::Add(const K &flag,V *obj)
|
||||
bool ObjectManage<K,V>::Add(const K &flag,V *obj)
|
||||
{
|
||||
if(!obj)return(false);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace hgl
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
V *ResManage<K,V>::Find(const K &flag)
|
||||
V *ObjectManage<K,V>::Find(const K &flag)
|
||||
{
|
||||
int index=items.Find(flag);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace hgl
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
V *ResManage<K,V>::Get(const K &flag)
|
||||
V *ObjectManage<K,V>::Get(const K &flag)
|
||||
{
|
||||
int index=items.Find(flag);
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace hgl
|
||||
* 确认指定数据是否存在
|
||||
*/
|
||||
template<typename K,typename V>
|
||||
bool ResManage<K,V>::ValueExist(V *value)
|
||||
bool ObjectManage<K,V>::ValueExist(V *value)
|
||||
{
|
||||
return(items.FindByValue(value)!=-1);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace hgl
|
||||
* @param 是否增加引用计数
|
||||
*/
|
||||
template<typename K,typename V>
|
||||
bool ResManage<K,V>::GetKeyByValue(V *value,K *key,uint *ref_count,bool inc_ref_count)
|
||||
bool ObjectManage<K,V>::GetKeyByValue(V *value,K *key,uint *ref_count,bool inc_ref_count)
|
||||
{
|
||||
int index=items.FindByValue(value);
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace hgl
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
int ResManage<K,V>::ReleaseBySerial(int index,bool zero_clear)
|
||||
int ObjectManage<K,V>::ReleaseBySerial(int index,bool zero_clear)
|
||||
{
|
||||
if(index==-1)
|
||||
{
|
||||
@@ -148,15 +148,15 @@ namespace hgl
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
int ResManage<K,V>::Release(const K &flag,bool zero_clear)
|
||||
int ObjectManage<K,V>::Release(const K &flag,bool zero_clear)
|
||||
{
|
||||
return ReleaseBySerial(items.Find(flag),zero_clear);
|
||||
}
|
||||
|
||||
template<typename K,typename V>
|
||||
int ResManage<K,V>::Release(V *td,bool zero_clear)
|
||||
int ObjectManage<K,V>::Release(V *td,bool zero_clear)
|
||||
{
|
||||
return ReleaseBySerial(items.FindByValue(td),zero_clear);
|
||||
}
|
||||
}//namespace hgl
|
||||
#endif//HGL_RES_MANAGE_CPP
|
||||
#endif//HGL_OBJECT_MANAGE_CPP
|
@@ -1,5 +1,4 @@
|
||||
#ifndef HGL_RES_MANAGE_INCLUDE
|
||||
#define HGL_RES_MANAGE_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/type/Map.h>
|
||||
namespace hgl
|
||||
@@ -17,9 +16,9 @@ namespace hgl
|
||||
};
|
||||
|
||||
/**
|
||||
* 资源管理器,它没有缓冲管理,仅仅是管理数据,并保证不会被重复加载
|
||||
* 对象管理器,它没有缓冲管理,仅仅是管理数据,并保证不会被重复加载
|
||||
*/
|
||||
template<typename K,typename V> class ResManage
|
||||
template<typename K,typename V> class ObjectManage
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -31,11 +30,11 @@ namespace hgl
|
||||
|
||||
protected:
|
||||
|
||||
virtual void Clear(V *obj){delete obj;} ///<资源释放虚拟函数(缺省为直接delete对象)
|
||||
virtual void Clear(V *obj){delete obj;} ///<对象释放虚拟函数(缺省为直接delete对象)
|
||||
|
||||
public:
|
||||
|
||||
virtual ~ResManage();
|
||||
virtual ~ObjectManage();
|
||||
|
||||
virtual void Clear(); ///<清除所有数据
|
||||
virtual void ClearFree(); ///<清除所有引用计数为0的数据
|
||||
@@ -51,19 +50,19 @@ namespace hgl
|
||||
|
||||
virtual int Release(const K &,bool zero_clear=false); ///<释放一个数据
|
||||
virtual int Release(V *,bool zero_clear=false); ///<释放一个数据
|
||||
};//template<typename K,typename V> class ResManage
|
||||
};//template<typename K,typename V> class ObjectManage
|
||||
|
||||
/**
|
||||
* 使用int类做数标致的资源管理器
|
||||
* 使用整型数据类做数标识的对象管理器
|
||||
*/
|
||||
template<typename K,typename V> class IDResManage:public ResManage<K,V>
|
||||
template<typename K,typename V> class IDObjectManage:public ObjectManage<K,V>
|
||||
{
|
||||
K id_count=0;
|
||||
|
||||
public:
|
||||
|
||||
using ResManage<K,V>::ResManage;
|
||||
virtual ~IDResManage()=default;
|
||||
using ObjectManage<K,V>::ObjectManage;
|
||||
virtual ~IDObjectManage()=default;
|
||||
|
||||
virtual K Add(V *value)
|
||||
{
|
||||
@@ -73,19 +72,19 @@ namespace hgl
|
||||
K key;
|
||||
uint count;
|
||||
|
||||
if(ResManage<K,V>::GetKeyByValue(value,&key,&count,true))
|
||||
if(ObjectManage<K,V>::GetKeyByValue(value,&key,&count,true))
|
||||
return key;
|
||||
}
|
||||
|
||||
if(!ResManage<K,V>::Add(id_count,value))
|
||||
if(!ObjectManage<K,V>::Add(id_count,value))
|
||||
return(-1);
|
||||
|
||||
return id_count++;
|
||||
}
|
||||
};//template<typename K,typename V> class IDResManage:public ResManage<K,V>
|
||||
};//template<typename K,typename V> class IDObjectManage:public ObjectManage<K,V>
|
||||
|
||||
template<typename V> using ID32ResManage=IDResManage<uint32,V>;
|
||||
template<typename V> using ID64ResManage=IDResManage<uint64,V>;
|
||||
template<typename V> using U32ObjectManage=IDObjectManage<uint32,V>;
|
||||
template<typename V> using U64ObjectManage=IDObjectManage<uint64,V>;
|
||||
}//namespace hgl
|
||||
#include<hgl/type/ResManage.cpp>
|
||||
#endif//HGL_RES_MANAGE_INCLUDE
|
||||
|
||||
#include<hgl/type/ObjectManage.cpp>
|
@@ -2,11 +2,11 @@
|
||||
#define HGL_RES_POOL_MANAGE_INCLUDE
|
||||
|
||||
#include<hgl/type/Pool.h>
|
||||
#include<hgl/type/ResManage.h>
|
||||
#include<hgl/type/ObjectManage.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
template <typename K,typename V,typename OP> class _ResPoolManage:public ResManage<K,V>
|
||||
template <typename K,typename V,typename OP> class _ResPoolManage:public ObjectManage<K,V>
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace hgl
|
||||
|
||||
_ResPoolManage(OP *op):data_pool(op){}
|
||||
virtual ~_ResPoolManage()=default;
|
||||
};//template <typename K,typename V,typename OP> class _ResPoolManage:public ResManage<K,V>
|
||||
};//template <typename K,typename V,typename OP> class _ResPoolManage:public ObjectManage<K,V>
|
||||
|
||||
/**
|
||||
* 资源池是Pool/ResManage两个模板的组合应用
|
||||
|
Reference in New Issue
Block a user