ResManage模板Release函数增加返回值
This commit is contained in:
parent
0552be7754
commit
0786f4c611
@ -122,36 +122,41 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename F,typename T>
|
template<typename F,typename T>
|
||||||
void ResManage<F,T>::ReleaseBySerial(int index,bool zero_clear)
|
uint ResManage<F,T>::ReleaseBySerial(int index,bool zero_clear)
|
||||||
{
|
{
|
||||||
if(index==-1)
|
if(index==-1)
|
||||||
{
|
{
|
||||||
// ErrorHint(u"所释放的资源不存在");
|
// ErrorHint(u"所释放的资源不存在");
|
||||||
return;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResItem *obj=items.GetItem(index);
|
ResItem *obj=items.GetItem(index);
|
||||||
|
|
||||||
--obj->count;
|
--obj->count;
|
||||||
|
|
||||||
if(zero_clear&&obj->count==0)
|
if(obj->count>0)
|
||||||
|
return obj->count;
|
||||||
|
|
||||||
|
if(zero_clear)
|
||||||
{
|
{
|
||||||
Clear(obj->right);
|
Clear(obj->right);
|
||||||
|
|
||||||
items.DeleteBySerial(index);
|
items.DeleteBySerial(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F,typename T>
|
template<typename F,typename T>
|
||||||
void ResManage<F,T>::Release(const F &flag,bool zero_clear)
|
uint ResManage<F,T>::Release(const F &flag,bool zero_clear)
|
||||||
{
|
{
|
||||||
ReleaseBySerial(items.Find(flag),zero_clear);
|
return ReleaseBySerial(items.Find(flag),zero_clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F,typename T>
|
template<typename F,typename T>
|
||||||
void ResManage<F,T>::Release(T *td,bool zero_clear)
|
uint ResManage<F,T>::Release(T *td,bool zero_clear)
|
||||||
{
|
{
|
||||||
ReleaseBySerial(items.FindByValue(td),zero_clear);
|
return ReleaseBySerial(items.FindByValue(td),zero_clear);
|
||||||
}
|
}
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_RES_MANAGE_CPP
|
#endif//HGL_RES_MANAGE_CPP
|
||||||
|
@ -27,7 +27,7 @@ namespace hgl
|
|||||||
|
|
||||||
_Map<F,T *,ResItem> items;
|
_Map<F,T *,ResItem> items;
|
||||||
|
|
||||||
void ReleaseBySerial(int,bool);
|
uint ReleaseBySerial(int,bool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ namespace hgl
|
|||||||
virtual bool ValueExist(T *); ///<确认这个数据是否存在
|
virtual bool ValueExist(T *); ///<确认这个数据是否存在
|
||||||
virtual bool GetKeyByValue(T *,F *,uint *,bool inc_ref_count=false); ///<取得一个数据的Key和引用次数
|
virtual bool GetKeyByValue(T *,F *,uint *,bool inc_ref_count=false); ///<取得一个数据的Key和引用次数
|
||||||
|
|
||||||
virtual void Release(const F &,bool zero_clear=false); ///<释放一个数据
|
virtual uint Release(const F &,bool zero_clear=false); ///<释放一个数据
|
||||||
virtual void Release(T *,bool zero_clear=false); ///<释放一个数据
|
virtual uint Release(T *,bool zero_clear=false); ///<释放一个数据
|
||||||
};//template<typename F,typename T> class ResManage
|
};//template<typename F,typename T> class ResManage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user