move "data collection <>" to new folder.
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
struct Person
|
||||
{
|
||||
char name[128];
|
||||
bool sex;
|
||||
int age;
|
||||
};
|
||||
|
||||
template<typename T> Table
|
@@ -30,7 +30,9 @@ void out_data_chain(DataChain *dc)
|
||||
|
||||
int os_main(int,os_char **)
|
||||
{
|
||||
DataChain dc(100); ///数据链管理器(预定100个块)
|
||||
DataChain dc;
|
||||
|
||||
dc.Init(100); ///数据链管理器(预定100个块)
|
||||
|
||||
cout<<"DataChain Test"<<endl;
|
||||
|
@@ -33,7 +33,9 @@ int os_main(int,os_char **)
|
||||
{
|
||||
constexpr const int BLOCK_SIZE=100;
|
||||
|
||||
DataChain dc(BLOCK_SIZE); ///数据链管理器
|
||||
DataChain dc;
|
||||
|
||||
dc.Init(BLOCK_SIZE); ///数据链管理器
|
||||
|
||||
cout<<"DataChain Test"<<endl;
|
||||
|
@@ -80,13 +80,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> class TestRawArray:public TestArray<T,DataLifetimeCallback<T>>
|
||||
template<typename T> class TestRawArray:public TestArray<T,DataLifecycleManager<T>>
|
||||
{
|
||||
DataLifetimeCallback<T> life_cb;
|
||||
DataLifecycleManager<T> life_cb;
|
||||
|
||||
public:
|
||||
|
||||
TestRawArray():TestArray<T,DataLifetimeCallback<T>>(&life_cb){}
|
||||
TestRawArray():TestArray<T,DataLifecycleManager<T>>(&life_cb){}
|
||||
~TestRawArray()=default;
|
||||
};
|
||||
|
||||
@@ -124,13 +124,13 @@ public:
|
||||
int Get()const{return value;}
|
||||
};
|
||||
|
||||
template<typename T> class TestObjectArray:public TestArray<T *,ObjectLifetimeCallback<T>>
|
||||
template<typename T> class TestObjectArray:public TestArray<T *,ObjectLifecycleManager<T>>
|
||||
{
|
||||
DefaultObjectLifetimeCallback<T> life_cb;
|
||||
|
||||
public:
|
||||
|
||||
TestObjectArray():TestArray<T *,ObjectLifetimeCallback<T>>(&life_cb){}
|
||||
TestObjectArray():TestArray<T *,ObjectLifecycleManager<T>>(&life_cb){}
|
||||
virtual ~TestObjectArray()
|
||||
{
|
||||
for(T *p:*this)
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
if(!life_cb.Create(&p))
|
||||
return nullptr;
|
||||
|
||||
TestArray<T *,ObjectLifetimeCallback<T>>::Add(p);
|
||||
TestArray<T *,ObjectLifecycleManager<T>>::Add(p);
|
||||
|
||||
return p;
|
||||
}
|
23
datatype/collection/MultiMapTest.cpp
Normal file
23
datatype/collection/MultiMapTest.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
//多重map测试
|
||||
|
||||
//多重map指的是一套数据,含有多个关键字,每个关键字都可以用来查找数据,这样的数据结构称为多重map。
|
||||
|
||||
struct Person
|
||||
{
|
||||
char name[128];
|
||||
bool sex;
|
||||
int age;
|
||||
};
|
||||
|
||||
template<typename T> class MultiMapIndex
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T> class MultiMap
|
||||
{
|
||||
List<T> data_list;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
};
|
76
datatype/collection/ResourceManagerTest.cpp
Normal file
76
datatype/collection/ResourceManagerTest.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* 资源管理器
|
||||
*
|
||||
* 资源管理器并非一个简单的模块,而是一个成套的组件。
|
||||
*
|
||||
* 由一个统一的管理器管理所有的资源,并提供多种索引获取方式,对资源同时提供引用计数。
|
||||
*
|
||||
* 同时,对引用和释放可以产生详细的日志供开发者调试分析。
|
||||
*/
|
||||
|
||||
#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:
|
||||
|
||||
|
||||
};
|
Reference in New Issue
Block a user