From 8fd3b3912dae7ee2f4454dfc8cb565827a8b6903 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 23 Aug 2024 01:56:13 +0800 Subject: [PATCH] added IDObject --- inc/hgl/type/_Object.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/inc/hgl/type/_Object.h b/inc/hgl/type/_Object.h index f4ded21..308e575 100644 --- a/inc/hgl/type/_Object.h +++ b/inc/hgl/type/_Object.h @@ -41,4 +41,30 @@ namespace hgl //此代码取自AngelScript,感谢 #define GetMemberFuncPointer(c,m) MethodPtr::Convert((void (c::*)())(&c::m)) + + /** + * 取得一个类型的哈希值 + */ + template inline constexpr const size_t GetTypeHash() + { + return typeid(T).hash_code(); + } + + class IDObject :public _Object + { + private: + + size_t object_type_hash; ///<最终类的类型哈希值 + + public: + + IDObject(const size_t &oth) + { + object_type_hash=oth; + } + + virtual ~IDObject()=default; + + const size_t GetObjectTypeHash()const { return object_type_hash; } + };//class IDObject }//namespace hgl