diff --git a/Hazel/src/Hazel/Core/UUID.cpp b/Hazel/src/Hazel/Core/UUID.cpp new file mode 100644 index 0000000..638b436 --- /dev/null +++ b/Hazel/src/Hazel/Core/UUID.cpp @@ -0,0 +1,25 @@ +// +// Created by sfd on 25-6-18. +// + +#include "UUID.h" + +#include + +namespace Hazel +{ + static std::random_device s_RandomDevice; + static std::mt19937_64 s_Engine(s_RandomDevice()); + static std::uniform_int_distribution s_UniformDistribution; + + UUID::UUID() + : m_UUID(s_UniformDistribution(s_Engine)) + { + + } + + UUID::UUID(const uint64_t uuid) + : m_UUID(uuid) + { + } +} diff --git a/Hazel/src/Hazel/Core/UUID.h b/Hazel/src/Hazel/Core/UUID.h new file mode 100644 index 0000000..eee0196 --- /dev/null +++ b/Hazel/src/Hazel/Core/UUID.h @@ -0,0 +1,40 @@ +// +// Created by sfd on 25-6-18. +// + +#ifndef UUID_H +#define UUID_H +#include +#include "Core.h" + +namespace Hazel +{ + class HAZEL_API UUID + { + public: + UUID(); + UUID(uint64_t uuid); + UUID(const UUID&) = default; + + operator uint64_t() const { return m_UUID;} + private: + uint64_t m_UUID; + }; +} + +namespace std +{ + + template<> + struct hash + { + std::size_t operator() (const Hazel::UUID& uuid) const + { + return hash()((uint64_t)uuid); + } + }; + +} + + +#endif //UUID_H