Plasma Engine  2.0
Loading...
Searching...
No Matches
HashableStruct_inl.h
1#include <Foundation/Algorithm/HashingUtils.h>
2#include <Foundation/Memory/MemoryUtils.h>
3
4template <typename T>
6{
7 plMemoryUtils::ZeroFill<T>(static_cast<T*>(this), 1);
8}
9
10template <typename T>
12{
13 plMemoryUtils::RawByteCopy(this, &other, sizeof(T));
14}
15
16template <typename T>
17PL_ALWAYS_INLINE void plHashableStruct<T>::operator=(const plHashableStruct<T>& other)
18{
19 if (this != &other)
20 {
21 plMemoryUtils::RawByteCopy(this, &other, sizeof(T));
22 }
23}
24
25template <typename T>
26PL_ALWAYS_INLINE plUInt32 plHashableStruct<T>::CalculateHash() const
27{
28 return plHashingUtils::xxHash32(this, sizeof(T));
29}
This class provides a base class for hashable structs (e.g. descriptor objects).
Definition HashableStruct.h:17
plUInt32 CalculateHash() const
Calculates the 32 bit hash of the struct and returns it.
Definition HashableStruct_inl.h:26
static plUInt32 xxHash32(const void *pKey, size_t uiSizeInByte, plUInt32 uiSeed=0)
Calculates the 32bit xxHash of the given key.
Definition HashingUtils.cpp:209
static void RawByteCopy(void *pDestination, const void *pSource, size_t uiNumBytesToCopy)
Copies exactly uiNumBytesToCopy from pSource to pDestination, independent of the involved types and t...
Definition MemoryUtils_inl.h:197
static void ZeroFill(T *pDestination, size_t uiCount=1)
Zeros every byte in the provided memory buffer.