From 8dc653b7b12c110a9f890e8312741865533835f3 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sat, 2 Nov 2024 19:32:32 +0800 Subject: [PATCH] renamed to SortedSet instead of SortedSets --- inc/hgl/io/event/InputEvent.h | 4 ++-- inc/hgl/thread/Thread.h | 4 ++-- inc/hgl/type/ActiveIDManager.h | 4 ++-- inc/hgl/type/ConstStringSet.h | 4 ++-- inc/hgl/type/DataArray.h | 16 ++++++++-------- inc/hgl/type/DataChain.h | 4 ++-- inc/hgl/type/SeriesPool.h | 4 ++-- inc/hgl/type/{SortedSets.h => SortedSet.h} | 10 +++++----- inc/hgl/type/object/Object.h | 11 ++++++++--- inc/hgl/type/object/ObjectManager.h | 4 ++-- src/CMakeLists.txt | 5 +++-- src/Object/ObjectManager.cpp | 4 ++-- 12 files changed, 40 insertions(+), 34 deletions(-) rename inc/hgl/type/{SortedSets.h => SortedSet.h} (95%) diff --git a/inc/hgl/io/event/InputEvent.h b/inc/hgl/io/event/InputEvent.h index 0c4f0cd..e22f53b 100644 --- a/inc/hgl/io/event/InputEvent.h +++ b/inc/hgl/io/event/InputEvent.h @@ -1,7 +1,7 @@ #ifndef HGL_IO_INPUT_EVENT_INCLUDE #define HGL_IO_INPUT_EVENT_INCLUDE -#include +#include #include namespace hgl { @@ -31,7 +31,7 @@ namespace hgl InputEventSource source_type; - SortedSets sub_event_proc[size_t(InputEventSource::RANGE_SIZE)]; + SortedSet sub_event_proc[size_t(InputEventSource::RANGE_SIZE)]; public: diff --git a/inc/hgl/thread/Thread.h b/inc/hgl/thread/Thread.h index 875366b..247d8cd 100644 --- a/inc/hgl/thread/Thread.h +++ b/inc/hgl/thread/Thread.h @@ -2,7 +2,7 @@ #define HGL_THREAD_INCLUDE #include -#include +#include #include #include #include @@ -121,7 +121,7 @@ namespace hgl { protected: - SortedSets thread_set; + SortedSet thread_set; public: diff --git a/inc/hgl/type/ActiveIDManager.h b/inc/hgl/type/ActiveIDManager.h index cf1d046..da08ea5 100644 --- a/inc/hgl/type/ActiveIDManager.h +++ b/inc/hgl/type/ActiveIDManager.h @@ -2,7 +2,7 @@ #include #include -#include +#include namespace hgl { @@ -11,7 +11,7 @@ namespace hgl */ class ActiveIDManager { - SortedSets active_list; ///<活跃ID列表 + SortedSet active_list; ///<活跃ID列表 Stack idle_list; ///<闲置ID列表 int id_count; diff --git a/inc/hgl/type/ConstStringSet.h b/inc/hgl/type/ConstStringSet.h index ddd28e7..a06cf49 100644 --- a/inc/hgl/type/ConstStringSet.h +++ b/inc/hgl/type/ConstStringSet.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include @@ -74,7 +74,7 @@ namespace hgl DataArray str_data; ///<字符串数据 - SortedSets> str_set; ///<字符串集合 + SortedSet> str_set; ///<字符串集合 List> str_list; ///<字符串列表 Map str_offset_map; ///<字符串映射 diff --git a/inc/hgl/type/DataArray.h b/inc/hgl/type/DataArray.h index f5b9f66..a9ee09a 100644 --- a/inc/hgl/type/DataArray.h +++ b/inc/hgl/type/DataArray.h @@ -626,8 +626,8 @@ namespace hgl result_list.SetCount(result); } - //int64 Intersection (SortedSets &result,const SortedSets &sets); ///<取得与指定合集的交集 - //int64 Intersection (const SortedSets &set); ///<取得与指定合集的交集数量 + //int64 Intersection (SortedSet &result,const SortedSet &sets); ///<取得与指定合集的交集 + //int64 Intersection (const SortedSet &set); ///<取得与指定合集的交集数量 ///** // * 取得与指定交集is的合集,但排斥cs合集中的数据 @@ -636,9 +636,9 @@ namespace hgl // * @param cs 求排斥的合集 // * @return 结果数量 // */ - //int64 Intersection (SortedSets &result,const SortedSets &is,const SortedSets &cs); + //int64 Intersection (SortedSet &result,const SortedSet &is,const SortedSet &cs); - //int64 Difference (const SortedSets &is); ///<求差集数量 + //int64 Difference (const SortedSet &is); ///<求差集数量 ///** // * 求当前合集与另一个数据集的交集 @@ -646,7 +646,7 @@ namespace hgl // * @param list 要计算交集的数据集 // * @return 交集数量 // */ - //int64 Intersection(SortedSets &result,const SortedSets &list) + //int64 Intersection(SortedSet &result,const SortedSet &list) //{ // if(data_list.GetCount()<=0) // return(0); @@ -663,7 +663,7 @@ namespace hgl // return result.GetCount(); //} - //int64 Intersection(const SortedSets &list) + //int64 Intersection(const SortedSet &list) //{ // if(data_list.GetCount()<=0) // return(0); @@ -685,7 +685,7 @@ namespace hgl // return count; //} - //int64 Intersection(SortedSets &result,const SortedSets &il,const SortedSets &cl) + //int64 Intersection(SortedSet &result,const SortedSet &il,const SortedSet &cl) //{ // if(data_list.GetCount()<=0) // return(0); @@ -727,6 +727,6 @@ namespace hgl // return count; //} - //int64 Clear (const SortedSets &clear_sets); ///<清除指定合集中所有数据 + //int64 Clear (const SortedSet &clear_sets); ///<清除指定合集中所有数据 };//template class DataArray }//namespace hgl diff --git a/inc/hgl/type/DataChain.h b/inc/hgl/type/DataChain.h index 8cce2f2..a4060d4 100644 --- a/inc/hgl/type/DataChain.h +++ b/inc/hgl/type/DataChain.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace hgl { @@ -42,7 +42,7 @@ namespace hgl DataStackPool ud_pool; ///<用户数据占用信息池 - SortedSets ud_set; ///<用户数据占用合集 + SortedSet ud_set; ///<用户数据占用合集 #ifdef _DEBUG public: diff --git a/inc/hgl/type/SeriesPool.h b/inc/hgl/type/SeriesPool.h index 469e436..b583f52 100644 --- a/inc/hgl/type/SeriesPool.h +++ b/inc/hgl/type/SeriesPool.h @@ -1,5 +1,5 @@ #pragma once -#include +#include #include namespace hgl @@ -79,7 +79,7 @@ namespace hgl if(min_value==0&&max_value==0) max_value=max_count-1; - SortedSets ss; //使用排序集合用来储存随机序号 + SortedSet ss; //使用排序集合用来储存随机序号 std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution dis(min_value,max_value); diff --git a/inc/hgl/type/SortedSets.h b/inc/hgl/type/SortedSet.h similarity index 95% rename from inc/hgl/type/SortedSets.h rename to inc/hgl/type/SortedSet.h index 24d35d0..63de573 100644 --- a/inc/hgl/type/SortedSets.h +++ b/inc/hgl/type/SortedSet.h @@ -8,7 +8,7 @@ namespace hgl * 集合数据列表中不允许数据出现重复性,同时它会将数据排序
* 我们删除了批量添加数据的Add函数,因为每一次添加数据都会导致一次插入,这样效率太低了。我们建议将数据全部添加到List,再转换为SortedSets。
*/ - template class SortedSets + template class SortedSet { protected: @@ -38,8 +38,8 @@ namespace hgl public: - SortedSets()=default; - virtual ~SortedSets()=default; + SortedSet()=default; + virtual ~SortedSet()=default; void SetCount (int64 count){data_list.SetCount(count);} ///<指定数据数量,一般用于批量加载前的处理 void PreAlloc (int64 count){data_list.Alloc(count);} ///<预分配指定数量的数据空间 @@ -173,6 +173,6 @@ namespace hgl bool GetFirst (T &data){return hgl_cpy(data,*begin());} ///<取得最前面一个数据 bool GetLast (T &data){return hgl_cpy(data,*last());} ///<取得最后面一个数据 - void operator =(const SortedSets &set){data_list=set.data_list;} ///<等号操作符重载 - };//template class SortedSets + void operator =(const SortedSet &set){data_list=set.data_list;} ///<等号操作符重载 + };//template class SortedSet }//namespace hgl diff --git a/inc/hgl/type/object/Object.h b/inc/hgl/type/object/Object.h index bc42e6d..45efdc2 100644 --- a/inc/hgl/type/object/Object.h +++ b/inc/hgl/type/object/Object.h @@ -13,11 +13,12 @@ namespace hgl public: + const ObjectSimpleInfo &GetObjectSimpleInfo () const noexcept { return object_base_info; } ///<获取对象简单信息 const ObjectBaseInfo & GetObjectBaseInfo () const noexcept { return object_base_info; } ///<获取对象基本信息 ObjectManager * GetObjectManager () noexcept { return object_base_info.object_manager; } ///<获取对象管理器 - const size_t GetHashCode () const noexcept { return object_base_info.hash_code; } ///<获取对象数据类型的hash值 + const size_t GetTypeHash () const noexcept { return object_base_info.hash_code; } ///<获取对象数据类型的hash值 const size_t GetSerialNumber () const noexcept { return object_base_info.serial_number; } ///<获取对象的序列号 protected: @@ -32,6 +33,10 @@ namespace hgl virtual ~Object()=default; virtual void Deinitailize()=0; + + virtual bool CheckType() + { + } };//class Object template class DefaultObjectManager; @@ -50,7 +55,7 @@ namespace hgl \ public: \ \ - static const size_t StaticHashCode() noexcept {return GetTypeHash();} \ + static const size_t StaticTypeHash() noexcept {return hgl::GetTypeHash();} \ @@ -150,7 +155,7 @@ namespace hgl template SafePtr &operator=(SafePtr &spd) { - if(T::StaticHashCode()!=OT.StaticHashCode()) + if(T::StaticTypeHash()!=OT::StaticTypeHash()) { Release(); return *this; diff --git a/inc/hgl/type/object/ObjectManager.h b/inc/hgl/type/object/ObjectManager.h index 555559c..69dfc74 100644 --- a/inc/hgl/type/object/ObjectManager.h +++ b/inc/hgl/type/object/ObjectManager.h @@ -23,7 +23,7 @@ namespace hgl public: - const size_t GetHashCode()const{return object_hash_code;} + const size_t GetTypeHash()const{return object_hash_code;} const char * GetTypename()const{return object_type_name;} const size_t GetCount()const{return object_count;} @@ -88,7 +88,7 @@ namespace hgl { ObjectBaseInfo obi { - .hash_code =GetHashCode(), + .hash_code =GetTypeHash(), .object_manager =this, .serial_number =AcquireSerialNumber(), .source_code_location=scl diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d9ca47..e43ed8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,6 +58,7 @@ SET(SYSTEM_INFO_SOURCE ${CORE_PLATFORM_INCLUDE_PATH}/SystemInfo.h SET(MATH_INCLUDE_PATH ${CMCORE_ROOT_INCLUDE_PATH}/hgl/math) SET(BASE_OBJECT_HEADER_FILES ${TYPE_INCLUDE_PATH}/object/ObjectBaseInfo.h + ${TYPE_INCLUDE_PATH}/object/ObjectRelation.h ${TYPE_INCLUDE_PATH}/object/Object.h ${TYPE_INCLUDE_PATH}/object/ObjectAllocator.h ${TYPE_INCLUDE_PATH}/object/ObjectManager.h @@ -221,8 +222,8 @@ SET(BASE_TIME_HEADER_FILES ${TYPE_INCLUDE_PATH}/DateTime.h ${CMCORE_ROOT_INCLUDE_PATH}/hgl/Time.h) SET(BASE_TIME_SOURCE_FILES Time/DateTime.cpp - Time/TimeCount.cpp - Time/TimeVal.cpp) + Time/TimeCount.cpp + Time/TimeVal.cpp) SOURCE_GROUP("Time\\Header Files" FILES ${BASE_TIME_HEADER_FILES}) SOURCE_GROUP("Time\\Source Files" FILES ${BASE_TIME_SOURCE_FILES}) diff --git a/src/Object/ObjectManager.cpp b/src/Object/ObjectManager.cpp index a45e9de..576177d 100644 --- a/src/Object/ObjectManager.cpp +++ b/src/Object/ObjectManager.cpp @@ -24,7 +24,7 @@ namespace hgl if(!om) return(false); - const size_t hc=om->GetHashCode(); + const size_t hc=om->GetTypeHash(); auto *omm=GetObjectManagerMap(); @@ -43,7 +43,7 @@ namespace hgl if(!om) return; - const size_t hc=om->GetHashCode(); + const size_t hc=om->GetTypeHash(); auto *omm=GetObjectManagerMap();