rename to KVObject instead of ResItem

This commit is contained in:
hyzboy 2023-07-14 23:40:28 +08:00
parent c26c55f0be
commit 404acf8f58
No known key found for this signature in database
GPG Key ID: 067EE4525D4FB6D3

View File

@ -20,11 +20,14 @@ namespace hgl
*/ */
template<typename K,typename V> class ObjectManage template<typename K,typename V> class ObjectManage
{ {
public:
using KVObject=RefKeyValue<K,V>;
protected: protected:
using ResItem=RefKeyValue<K,V>;
_Map<K,V *,ResItem> items; _Map<K,V *,KVObject> items;
protected: protected:
@ -43,7 +46,7 @@ namespace hgl
while(n--) while(n--)
{ {
ResItem *obj=items.GetItem(n); KVObject *obj=items.GetItem(n);
Clear(obj->value); Clear(obj->value);
} }
@ -57,7 +60,7 @@ namespace hgl
while(n--) while(n--)
{ {
ResItem *obj=items.GetItem(n); KVObject *obj=items.GetItem(n);
if(obj->ref_count<=0) if(obj->ref_count<=0)
{ {
@ -87,7 +90,7 @@ namespace hgl
if(index==-1) if(index==-1)
return(nullptr); return(nullptr);
ResItem *obj=items.GetItem(index); KVObject *obj=items.GetItem(index);
return obj->value; return obj->value;
} }
@ -98,7 +101,7 @@ namespace hgl
if(index!=-1) if(index!=-1)
{ {
ResItem *obj=items.GetItem(index); KVObject *obj=items.GetItem(index);
++obj->ref_count; ++obj->ref_count;
@ -126,7 +129,7 @@ namespace hgl
if(index==-1)return(false); if(index==-1)return(false);
ResItem *obj=items.GetItem(index); KVObject *obj=items.GetItem(index);
if(inc_ref_count) if(inc_ref_count)
++obj->ref_count; ++obj->ref_count;
@ -155,7 +158,7 @@ namespace hgl
return(-1); return(-1);
} }
ResItem *obj=items.GetItem(index); KVObject *obj=items.GetItem(index);
--obj->ref_count; --obj->ref_count;