5#include <Common/Utility/string_utils.h>
6#include <Utility/traits.h>
7#include <Utility/utility.h>
21template<
typename Item,
typename Index = std::
size_t,
typename Generation = Index>
30 inline static constexpr auto INVALID_INDEX = std::numeric_limits<Index>::max();
37 , m_itemGeneration(itemGeneration)
44 template<CDerived<Item> DerivedItem>
56 return m_itemGeneration;
70 ? std::to_string(m_itemIdx) :
"invalid";
72 ? std::to_string(m_itemGeneration) :
"invalid";
73 return "[index=" + indexStr +
", generation=" + generationStr +
"]";
79 inline operator bool ()
const
92 inline static constexpr Generation
nextGeneration(
const Generation currentGeneration)
94 Index nextGen = currentGeneration + 1;
109template<
typename Item,
typename Index,
typename Generation>
115template<ph::editor::CWeakHandle Handle>
118 std::size_t operator () (
const Handle& handle)
const
120 return ph::math::murmur3_32(handle, 0);
PH_DEFINE_INLINE_TO_STRING_FORMATTER_TEMPLATE(ph::editor::TWeakHandle< Item, Index, Generation >)
Handle with weak reference semantics. Default constructor creates empty handle.
Definition TWeakHandle.h:23
bool operator==(const TWeakHandle &rhs) const =default
TWeakHandle(const TWeakHandle< DerivedItem, Index, Generation > &otherHandle)
Definition TWeakHandle.h:45
static constexpr auto INVALID_INDEX
Definition TWeakHandle.h:30
Generation GenerationType
Definition TWeakHandle.h:28
std::string toString() const
Definition TWeakHandle.h:67
Index IndexType
Definition TWeakHandle.h:27
Item ItemType
Definition TWeakHandle.h:26
Index getIndex() const
Definition TWeakHandle.h:49
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS(TWeakHandle)
Generation getGeneration() const
Definition TWeakHandle.h:54
static constexpr Generation nextGeneration(const Generation currentGeneration)
Get the next generation given a current generation.
Definition TWeakHandle.h:92
static constexpr auto INVALID_GENERATION
Definition TWeakHandle.h:31
void WeakHandleTag
Definition TWeakHandle.h:25
bool isEmpty() const
Definition TWeakHandle.h:62
TWeakHandle(Index itemIdx, Generation itemGeneration)
Definition TWeakHandle.h:35
Definition ph_editor.h:10
Definition TWeakHandle.h:113