diff --git a/datatype/collection/LifetimeTest.cpp b/datatype/collection/LifetimeTest.cpp index 64ea697..fc0b633 100644 --- a/datatype/collection/LifetimeTest.cpp +++ b/datatype/collection/LifetimeTest.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/datatype/collection/MultiMapTest.cpp b/datatype/collection/MultiMapTest.cpp index ef0c5b6..81f96bf 100644 --- a/datatype/collection/MultiMapTest.cpp +++ b/datatype/collection/MultiMapTest.cpp @@ -2,22 +2,29 @@ //多重map指的是一套数据,含有多个关键字,每个关键字都可以用来查找数据,这样的数据结构称为多重map。 -struct Person +#include"UserInfo.h" +#include + +using namespace hgl; + +template class IndexAccess { - char name[128]; - bool sex; - int age; + DataArray *data_pool; + + DataArray data_index; + +public: + + const int Comp(const T &a,const T &b)const; + + }; -template class MultiMapIndex +template class MultiIndexMap { -}; - -template class MultiMap -{ - List data_list; + DataArray data_pool; public: -}; +}; \ No newline at end of file diff --git a/datatype/collection/ResourceManagerTest.cpp b/datatype/collection/ResourceManagerTest.cpp index 337afa6..42c130c 100644 --- a/datatype/collection/ResourceManagerTest.cpp +++ b/datatype/collection/ResourceManagerTest.cpp @@ -8,69 +8,76 @@ * 同时,对引用和释放可以产生详细的日志供开发者调试分析。 */ -#include +#include #include -#include -#include 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 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("< 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; +using TOB=GraphResObject; + +int main() +{ + TOA *toa=new TOA; + TOB *tob=new TOB; + + cout<<"toa->GetRefCount():"<GetRefCount()<GetRefCount():"<GetRefCount()<