From 768004d109e9f5497980bf3f3bc21770eb228764 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 31 Oct 2024 01:49:20 +0800 Subject: [PATCH] move "data collection <>" to new folder. --- CMakeLists.txt | 182 ++++++------------- datatype/MultiMapTest.cpp | 8 - datatype/{ => collection}/CollectionTest.cpp | 0 datatype/{ => collection}/DataArrayTest.cpp | 0 datatype/{ => collection}/DataChainTest.cpp | 4 +- datatype/{ => collection}/DataChainTest2.cpp | 4 +- datatype/{ => collection}/LifetimeTest.cpp | 12 +- datatype/{ => collection}/LinkedListTest.cpp | 0 datatype/{ => collection}/MapTest.cpp | 0 datatype/collection/MultiMapTest.cpp | 23 +++ datatype/{ => collection}/PoolTest.cpp | 0 datatype/{ => collection}/QueueTest.cpp | 0 datatype/collection/ResourceManagerTest.cpp | 76 ++++++++ datatype/{ => collection}/StackPoolTest.cpp | 0 datatype/{ => collection}/StackTest.cpp | 0 math/DirectMatrix.cpp | 24 +++ 16 files changed, 186 insertions(+), 147 deletions(-) delete mode 100644 datatype/MultiMapTest.cpp rename datatype/{ => collection}/CollectionTest.cpp (100%) rename datatype/{ => collection}/DataArrayTest.cpp (100%) rename datatype/{ => collection}/DataChainTest.cpp (95%) rename datatype/{ => collection}/DataChainTest2.cpp (97%) rename datatype/{ => collection}/LifetimeTest.cpp (93%) rename datatype/{ => collection}/LinkedListTest.cpp (100%) rename datatype/{ => collection}/MapTest.cpp (100%) create mode 100644 datatype/collection/MultiMapTest.cpp rename datatype/{ => collection}/PoolTest.cpp (100%) rename datatype/{ => collection}/QueueTest.cpp (100%) create mode 100644 datatype/collection/ResourceManagerTest.cpp rename datatype/{ => collection}/StackPoolTest.cpp (100%) rename datatype/{ => collection}/StackTest.cpp (100%) create mode 100644 math/DirectMatrix.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index faec0f6..3123863 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ macro(cm_example_project sub_folder project_name) + + add_executable(${project_name} ${ARGN}) + target_link_libraries(${project_name} PRIVATE CMCore CMPlatform CMUtil tsl::robin_map) if(UNIX) @@ -22,164 +25,81 @@ set_property(TARGET ${project_name} PROPERTY FOLDER "CM/Examples/${sub_folder}") endmacro() -macro(set_example_project_folder sub_folder project_name) - set_property(TARGET ${project_name} PROPERTY FOLDER "CM/Examples/${sub_folder}") -endmacro() +#################################################################################################### +cm_example_project("Debug" DebugObject debug/DebugObject.cpp) #################################################################################################### -add_executable(DebugObject debug/DebugObject.cpp) -CM_EXAMPLE_PROJECT("Debug" DebugObject) +cm_example_project("DataType/RAM" RuntimeAssetManagerTest datatype/ram/RuntimeAssetManagerTest.cpp + datatype/ram/RuntimeAssetManager.h + datatype/ram/RAM_TestClass.h + datatype/ram/RAM_TestClass.cpp) #################################################################################################### -add_executable(TypeSizeof datatype/TypeSizeof.cpp) -CM_EXAMPLE_PROJECT("DataType" TypeSizeof) +cm_example_project("DataType" TypeSizeof datatype/TypeSizeof.cpp) +cm_example_project("DataType" TypeCastTest datatype/TypeCastTest.cpp) +cm_example_project("DataType" HalfFloatTest datatype/HalfFloatTest.cpp) +cm_example_project("DataType" SplitStringTest datatype/SplitStringTest.cpp) +cm_example_project("DataType" StrChrTest datatype/strchr_test.cpp) +cm_example_project("DataType" Uint2StrTest datatype/utos_test.cpp) +cm_example_project("DataType" Size2Test datatype/Size2Test.cpp) +cm_example_project("DataType" Uint2HexStrTest datatype/Uint2HexStrTest.cpp) -add_executable(TypeCastTest datatype/TypeCastTest.cpp) -cm_example_project("DataType" TypeCastTest) - -add_executable(HalfFloatTest datatype/HalfFloatTest.cpp) -cm_example_project("DataType" HalfFloatTest) - -add_executable(SplitStringTest datatype/SplitStringTest.cpp) -cm_example_project("DataType" SplitStringTest ${CM_NATVIS}) - -add_executable(StrChrTest datatype/strchr_test.cpp) -cm_example_project("DataType" StrChrTest) - -add_executable(Uint2StrTest datatype/utos_test.cpp) -cm_example_project("DataType" Uint2StrTest) - -add_executable(RuntimeAssetManagerTest datatype/ram/RuntimeAssetManagerTest.cpp - datatype/ram/RuntimeAssetManager.h - datatype/ram/RAM_TestClass.h - datatype/ram/RAM_TestClass.cpp) - -cm_example_project("DataType/RAM" RuntimeAssetManagerTest) - -add_executable(Size2Test datatype/Size2Test.cpp) -cm_example_project("DataType" Size2Test) - -add_executable(Uint2HexStrTest datatype/Uint2HexStrTest.cpp) -cm_example_project("DataType" Uint2HexStrTest) - -add_executable(ConstStringSetTest datatype/ConstStringSetTest.cpp) -cm_example_project("DataType" ConstStringSetTest) - -add_executable(IDNameTest datatype/IDNameTest.cpp) -cm_example_project("DataType" IDNameTest) +cm_example_project("DataType" ConstStringSetTest datatype/ConstStringSetTest.cpp) +cm_example_project("DataType" IDNameTest datatype/IDNameTest.cpp) #################################################################################################### - -add_executable(OutputEpsilon math/OutputEpsilon.cpp) -CM_EXAMPLE_PROJECT("Math" OutputEpsilon) - -add_executable(TransformBenchmark math/TransformBenchmark.cpp) -CM_EXAMPLE_PROJECT("Math" TransformBenchmark) +cm_example_project("Math" OutputEpsilon math/OutputEpsilon.cpp) +cm_example_project("Math" TransformBenchmark math/TransformBenchmark.cpp) #################################################################################################### - -add_executable(LifetimeTest datatype/LifetimeTest.cpp) -set_example_project_folder("DataType/DataArray" LifetimeTest) - -add_executable(CollectionTest datatype/CollectionTest.cpp) -cm_example_project("DataType/DataArray" CollectionTest) - -add_executable(DataArrayTest datatype/DataArrayTest.cpp) -set_example_project_folder("DataType/DataArray" DataArrayTest) - -add_executable(StackTest datatype/StackTest.cpp) -set_example_project_folder("DataType/DataArray" StackTest) - -add_executable(QueueTest datatype/QueueTest.cpp) -set_example_project_folder("DataType/DataArray" QueueTest) - -add_executable(PoolTest datatype/PoolTest.cpp) -set_example_project_folder("DataType/DataArray" PoolTest) - -add_executable(MapTest datatype/MapTest.cpp) -set_example_project_folder("DataType/DataArray" MapTest) - -add_executable(StackPoolTest datatype/StackPoolTest.cpp) -set_example_project_folder("DataType/DataArray" StackPoolTest) - -add_executable(DataChainTest datatype/DataChainTest.cpp) -cm_example_project("DataType/DataArray" DataChainTest) - -add_executable(DataChainTest2 datatype/DataChainTest2.cpp) -cm_example_project("DataType/DataArray" DataChainTest2) +cm_example_project("DataType/Collection" LifetimeTest datatype/collection/LifetimeTest.cpp) +cm_example_project("DataType/Collection" CollectionTest datatype/collection/CollectionTest.cpp) +cm_example_project("DataType/Collection" DataArrayTest datatype/collection/DataArrayTest.cpp) +cm_example_project("DataType/Collection" StackTest datatype/collection/StackTest.cpp) +cm_example_project("DataType/Collection" QueueTest datatype/collection/QueueTest.cpp) +cm_example_project("DataType/Collection" PoolTest datatype/collection/PoolTest.cpp) +cm_example_project("DataType/Collection" MapTest datatype/collection/MapTest.cpp) +cm_example_project("DataType/Collection" MultiMapTest datatype/collection/MultiMapTest.cpp) +cm_example_project("DataType/Collection" StackPoolTest datatype/collection/StackPoolTest.cpp) +cm_example_project("DataType/Collection" DataChainTest datatype/collection/DataChainTest.cpp) +cm_example_project("DataType/Collection" DataChainTest2 datatype/collection/DataChainTest2.cpp) +cm_example_project("DataType/Collection" ResManagerTest datatype/collection/ResourceManagerTest.cpp) #################################################################################################### -add_executable(Pick2DTest pick/Pick2DTest.cpp) -cm_example_project("Pick" Pick2DTest) +cm_example_project("Pick" Pick2DTest pick/Pick2DTest.cpp) target_link_libraries(Pick2DTest PRIVATE CM2D) #################################################################################################### - -add_executable(1_ActiveIDManagerTest datatype/ActiveIDManagerTest.cpp) -cm_example_project("DataType/ActiveManager" 1_ActiveIDManagerTest) - -add_executable(2_ActiveMemoryBlockManagerTest datatype/ActiveMemoryBlockManagerTest.cpp) -cm_example_project("DataType/ActiveManager" 2_ActiveMemoryBlockManagerTest) - -add_executable(3_ActiveDataManagerTest datatype/ActiveDataManagerTest.cpp) -cm_example_project("DataType/ActiveManager" 3_ActiveDataManagerTest) +cm_example_project("DataType/ActiveManager" 1_ActiveIDManagerTest datatype/ActiveIDManagerTest.cpp) +cm_example_project("DataType/ActiveManager" 2_ActiveMemoryBlockManagerTest datatype/ActiveMemoryBlockManagerTest.cpp) +cm_example_project("DataType/ActiveManager" 3_ActiveDataManagerTest datatype/ActiveDataManagerTest.cpp) #################################################################################################### - -add_executable(FixFilenameTest filesystem/FixFilenameTest.cpp) -cm_example_project("File System" FixFilenameTest) - -add_executable(EnumFileTest filesystem/EnumFileTest.cpp) -cm_example_project("File System" EnumFileTest) +cm_example_project("File System" FixFilenameTest filesystem/FixFilenameTest.cpp) +cm_example_project("File System" EnumFileTest filesystem/EnumFileTest.cpp) IF(WIN32) - - add_executable(EnumVolumeTest filesystem/EnumVolumeTest.cpp) - cm_example_project("File System" EnumVolumeTest) - +cm_example_project("File System" EnumVolumeTest filesystem/EnumVolumeTest.cpp) ENDIF(WIN32) #################################################################################################### - -add_executable(GetCpuInfo GetCpuInfo.cpp) -cm_example_project("Hareware" GetCpuInfo) - -add_executable(CreateBinaryH CreateBinaryH.cpp) -cm_example_project("" CreateBinaryH) - -add_executable(NormalCompressTest NormalCompressTest.cpp) -CM_EXAMPLE_PROJECT("" NormalCompressTest) - -add_executable(OSFontList OSFontList.cpp) -cm_example_project("os" OSFontList) -target_link_libraries(OSFontList PRIVATE CMUtil) - -add_executable(TimeCount time/time_count.cpp) -cm_example_project("time" TimeCount) +cm_example_project("Hareware" GetCpuInfo GetCpuInfo.cpp) +cm_example_project("Source" CreateBinaryH CreateBinaryH.cpp) +cm_example_project("Image" NormalCompressTest NormalCompressTest.cpp) +cm_example_project("os" OSFontList OSFontList.cpp) +cm_example_project("time" TimeCount time/time_count.cpp) #################################################################################################### - -add_executable(DistributionChart2D DistributionChart2D.cpp BitmapFont.cpp BitmapFont.h) -cm_example_project("chart" DistributionChart2D) +cm_example_project("chart" DistributionChart2D DistributionChart2D.cpp BitmapFont.cpp BitmapFont.h) target_link_libraries(DistributionChart2D PRIVATE CM2D) - -add_executable(PlayerTraceChart2D PlayerTraceChart2D.cpp BitmapFont.cpp BitmapFont.h) -cm_example_project("chart" PlayerTraceChart2D) +cm_example_project("chart" PlayerTraceChart2D PlayerTraceChart2D.cpp BitmapFont.cpp BitmapFont.h) target_link_libraries(PlayerTraceChart2D PRIVATE CM2D) #################################################################################################### - -add_executable(PAttribTest utils/PAttribTest.cpp) -cm_example_project("utils" PAttribTest) - -add_executable(Base64Test utils/base64test.cpp) -cm_example_project("utils" Base64Test) - -add_executable(HashTest utils/HashTest.cpp) -cm_example_project("utils" HashTest) - -add_executable(SeriesPoolTest utils/SeriesPoolTest.cpp) -cm_example_project("utils" SeriesPoolTest) +cm_example_project("utils" PAttribTest utils/PAttribTest.cpp) +cm_example_project("utils" Base64Test utils/base64test.cpp) +cm_example_project("utils" HashTest utils/HashTest.cpp) +cm_example_project("utils" SeriesPoolTest utils/SeriesPoolTest.cpp) #################################################################################################### OPTION(CM_EXAMPLES_ABOUT_ANDROID OFF) diff --git a/datatype/MultiMapTest.cpp b/datatype/MultiMapTest.cpp deleted file mode 100644 index a61e8e4..0000000 --- a/datatype/MultiMapTest.cpp +++ /dev/null @@ -1,8 +0,0 @@ -struct Person -{ - char name[128]; - bool sex; - int age; -}; - -template Table \ No newline at end of file diff --git a/datatype/CollectionTest.cpp b/datatype/collection/CollectionTest.cpp similarity index 100% rename from datatype/CollectionTest.cpp rename to datatype/collection/CollectionTest.cpp diff --git a/datatype/DataArrayTest.cpp b/datatype/collection/DataArrayTest.cpp similarity index 100% rename from datatype/DataArrayTest.cpp rename to datatype/collection/DataArrayTest.cpp diff --git a/datatype/DataChainTest.cpp b/datatype/collection/DataChainTest.cpp similarity index 95% rename from datatype/DataChainTest.cpp rename to datatype/collection/DataChainTest.cpp index 5ddbd2e..1d184d0 100644 --- a/datatype/DataChainTest.cpp +++ b/datatype/collection/DataChainTest.cpp @@ -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"< class TestRawArray:public TestArray> +template class TestRawArray:public TestArray> { - DataLifetimeCallback life_cb; + DataLifecycleManager life_cb; public: - TestRawArray():TestArray>(&life_cb){} + TestRawArray():TestArray>(&life_cb){} ~TestRawArray()=default; }; @@ -124,13 +124,13 @@ public: int Get()const{return value;} }; -template class TestObjectArray:public TestArray> +template class TestObjectArray:public TestArray> { DefaultObjectLifetimeCallback life_cb; public: - TestObjectArray():TestArray>(&life_cb){} + TestObjectArray():TestArray>(&life_cb){} virtual ~TestObjectArray() { for(T *p:*this) @@ -144,7 +144,7 @@ public: if(!life_cb.Create(&p)) return nullptr; - TestArray>::Add(p); + TestArray>::Add(p); return p; } diff --git a/datatype/LinkedListTest.cpp b/datatype/collection/LinkedListTest.cpp similarity index 100% rename from datatype/LinkedListTest.cpp rename to datatype/collection/LinkedListTest.cpp diff --git a/datatype/MapTest.cpp b/datatype/collection/MapTest.cpp similarity index 100% rename from datatype/MapTest.cpp rename to datatype/collection/MapTest.cpp diff --git a/datatype/collection/MultiMapTest.cpp b/datatype/collection/MultiMapTest.cpp new file mode 100644 index 0000000..ef0c5b6 --- /dev/null +++ b/datatype/collection/MultiMapTest.cpp @@ -0,0 +1,23 @@ +//多重map测试 + +//多重map指的是一套数据,含有多个关键字,每个关键字都可以用来查找数据,这样的数据结构称为多重map。 + +struct Person +{ + char name[128]; + bool sex; + int age; +}; + +template class MultiMapIndex +{ +}; + +template class MultiMap +{ + List data_list; + +public: + + +}; diff --git a/datatype/PoolTest.cpp b/datatype/collection/PoolTest.cpp similarity index 100% rename from datatype/PoolTest.cpp rename to datatype/collection/PoolTest.cpp diff --git a/datatype/QueueTest.cpp b/datatype/collection/QueueTest.cpp similarity index 100% rename from datatype/QueueTest.cpp rename to datatype/collection/QueueTest.cpp diff --git a/datatype/collection/ResourceManagerTest.cpp b/datatype/collection/ResourceManagerTest.cpp new file mode 100644 index 0000000..337afa6 --- /dev/null +++ b/datatype/collection/ResourceManagerTest.cpp @@ -0,0 +1,76 @@ +/** +* 资源管理器 +* +* 资源管理器并非一个简单的模块,而是一个成套的组件。 +* +* 由一个统一的管理器管理所有的资源,并提供多种索引获取方式,对资源同时提供引用计数。 +* +* 同时,对引用和释放可以产生详细的日志供开发者调试分析。 +*/ + +#include +#include +#include +#include + +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 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: + + +}; diff --git a/datatype/StackPoolTest.cpp b/datatype/collection/StackPoolTest.cpp similarity index 100% rename from datatype/StackPoolTest.cpp rename to datatype/collection/StackPoolTest.cpp diff --git a/datatype/StackTest.cpp b/datatype/collection/StackTest.cpp similarity index 100% rename from datatype/StackTest.cpp rename to datatype/collection/StackTest.cpp diff --git a/math/DirectMatrix.cpp b/math/DirectMatrix.cpp new file mode 100644 index 0000000..59fd090 --- /dev/null +++ b/math/DirectMatrix.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +const hgl::Matrix4f DirectTranslate(const hgl::Vector3f &off) +{ + hgl::Matrix4f result; + + result[0][0]=1; result[1][0]=0; result[2][0]=0; result[3][0]=off.x; + result[0][1]=0; result[1][1]=1; result[2][1]=0; result[3][1]=off.y; + result[0][2]=0; result[1][2]=0; result[2][2]=1; result[3][2]=off.z; + result[0][3]=0; result[1][3]=0; result[2][3]=0; result[3][3]=1; + + hgl::Matrix4f m=hgl::translate(off); + + return(result); +} + +int main() +{ + DirectTranslate(hgl::Vector3f(4,5,6)); + return 0; +}