few update

This commit is contained in:
hyzboy 2024-11-01 01:13:43 +08:00
parent f4800fe7bf
commit c4b7f7a5e8
3 changed files with 72 additions and 58 deletions

View File

@ -1,4 +1,4 @@
#include<hgl/type/LifetimeCallback.h>
#include<hgl/type/LifecycleManager.h>
#include<iostream>
#include<stdlib.h>

View File

@ -2,20 +2,27 @@
//多重map指的是一套数据含有多个关键字每个关键字都可以用来查找数据这样的数据结构称为多重map。
struct Person
#include"UserInfo.h"
#include<hgl/type/DataArray.h>
using namespace hgl;
template<typename T> class IndexAccess
{
char name[128];
bool sex;
int age;
DataArray<T> *data_pool;
DataArray<int> data_index;
public:
const int Comp(const T &a,const T &b)const;
};
template<typename T> class MultiMapIndex
template<typename T> class MultiIndexMap
{
};
template<typename T> class MultiMap
{
List<T> data_list;
DataArray<T> data_pool;
public:

View File

@ -8,69 +8,76 @@
*
*/
#include<hgl/type/LifetimeCallback.h>
#include<iostream>
#include<hgl/type/object/ObjectBaseInfo.h>
#include<hgl/type/object/ObjectManager.h>
#include<hgl/type/List.h>
using namespace hgl;
using namespace std;
struct RefRecord;
struct RefUser;
struct ResObject;
/**
*
*/
struct RefRecord
class IGraphResObject
{
constexpr const static unsigned int ACTION_INC=1; ///<增加引用
constexpr const static unsigned int ACTION_DEC=2; ///<减少引用
ObjectSimpleInfo osi;
int ref_count;
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 size_t GetTypeHash()const noexcept{return osi.hash_code;} ///<获取数据类型的HASH值
const size_t GetSerial()const noexcept{return osi.serial_number;} ///<获取数据序列号
const int GetRefCount()const noexcept{return ref_count;}
/**
*
*/
virtual void IncRef() noexcept
public:
IGraphResObject(const ObjectSimpleInfo &info)
{
++ref_count;
osi=info;
ref_count=0;
cout<<"type("<<info.hash_code<<") serial("<<info.serial_number<<") create."<<endl;
}
public:
};//class ResObject
virtual ~IGraphResObject()
{
cout<<"type("<<osi.hash_code<<") serial("<<osi.serial_number<<") destroy."<<endl;
}
};//class IGraphResObject
class ResManager:public ObjectManager
template<typename T> class GraphResObject:public IGraphResObject
{
static size_t SerialCount=0;
public:
GraphResObject():IGraphResObject({typeid(T).hash_code,SerialCount++}){}
virtual ~GraphResObject()=default;
};//class GraphResObject
class IGraphResManager
{
size_t SerialCount;
public:
};
class TestObjectA{};
class TestObjectB{};
using TOA=GraphResObject<TestObjectA>;
using TOB=GraphResObject<TestObjectB>;
int main()
{
TOA *toa=new TOA;
TOB *tob=new TOB;
cout<<"toa->GetRefCount():"<<toa->GetRefCount()<<endl;
cout<<"tob->GetRefCount():"<<tob->GetRefCount()<<endl;
delete toa;
delete tob;
return(0);
}