CMExamples/datatype/collection/ResourceManagerTest.cpp

77 lines
1.5 KiB
C++
Raw Normal View History

/**
*
*
*
*
*
*
*
*/
#include<hgl/type/LifetimeCallback.h>
#include<hgl/type/object/ObjectBaseInfo.h>
#include<hgl/type/object/ObjectManager.h>
#include<hgl/type/List.h>
using namespace hgl;
struct RefRecord;
struct RefUser;
struct ResObject;
/**
*
*/
struct RefRecord
{
constexpr const static unsigned int ACTION_INC=1; ///<增加引用
constexpr const static unsigned int ACTION_DEC=2; ///<减少引用
public:
ObjectSimpleInfo user_osi; ///<引用者对象简单信息
uint action; ///<动作
int new_ref_count; ///<新的引用计数
};
/**
*
*/
struct RefUser
{
ObjectSimpleInfo user_osi; ///<对象简单信息
};
/**
*
*/
class ResObject:public ObjectSimpleInfo
{
int ref_count; ///<引用计数
List<RefRecord> ref_record_list; ///<引用记录列表
public:
const int GetRefCount()const noexcept{return ref_count;}
/**
*
*/
virtual void IncRef() noexcept
{
++ref_count;
}
public:
};//class ResObject
class ResManager:public ObjectManager
{
public:
};