Plasma Engine  2.0
Loading...
Searching...
No Matches
Uuid.h
1
2#pragma once
3
4#include <Foundation/Algorithm/HashingUtils.h>
5
8
10class PL_FOUNDATION_DLL plUuid
11{
12public:
13 PL_DECLARE_POD_TYPE();
14
16 PL_ALWAYS_INLINE plUuid() = default; // [tested]
17
19 PL_ALWAYS_INLINE constexpr plUuid(plUInt64 uiLow, plUInt64 uiHigh)
20 : m_uiHigh(uiHigh)
21 , m_uiLow(uiLow)
22 {
23 }
24
26 PL_ALWAYS_INLINE bool operator==(const plUuid& other) const;
27
29 PL_ALWAYS_INLINE bool operator!=(const plUuid& other) const;
30
32 PL_ALWAYS_INLINE bool operator<(const plUuid& other) const;
33
35 PL_ALWAYS_INLINE bool IsValid() const;
36
38 [[nodiscard]] PL_ALWAYS_INLINE static plUuid MakeInvalid() { return plUuid(0, 0); }
39
41 [[nodiscard]] static plUuid MakeUuid();
42
44 void GetValues(plUInt64& ref_uiLow, plUInt64& ref_uiHigh) const
45 {
46 ref_uiHigh = m_uiHigh;
47 ref_uiLow = m_uiLow;
48 }
49
51 [[nodiscard]] static plUuid MakeStableUuidFromString(plStringView sString);
52
54 [[nodiscard]] static plUuid MakeStableUuidFromInt(plInt64 iInt);
55
57 PL_ALWAYS_INLINE void CombineWithSeed(const plUuid& seed);
58
60 PL_ALWAYS_INLINE void RevertCombinationWithSeed(const plUuid& seed);
61
63 PL_ALWAYS_INLINE void HashCombine(const plUuid& hash);
64
65private:
66 friend PL_FOUNDATION_DLL_FRIEND void operator>>(plStreamReader& inout_stream, plUuid& ref_value);
67 friend PL_FOUNDATION_DLL_FRIEND void operator<<(plStreamWriter& inout_stream, const plUuid& value);
68
69 plUInt64 m_uiHigh = 0;
70 plUInt64 m_uiLow = 0;
71};
72
73#include <Foundation/Types/Implementation/Uuid_inl.h>
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
static PL_ALWAYS_INLINE plUuid MakeInvalid()
Returns an invalid UUID.
Definition Uuid.h:38
void GetValues(plUInt64 &ref_uiLow, plUInt64 &ref_uiHigh) const
Returns the internal 128 Bit of data.
Definition Uuid.h:44
PL_ALWAYS_INLINE plUuid()=default
Default constructor. Constructed Uuid will be invalid.
PL_ALWAYS_INLINE constexpr plUuid(plUInt64 uiLow, plUInt64 uiHigh)
Constructs the Uuid from existing values.
Definition Uuid.h:19