You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This ensures that it compares correctly when used via a UScriptStruct, eg, within Python. #jira [FYI] Bryce.Lumpkin, Ben.Hoffman #rnx #ROBOMERGE-OWNER: jamie.dale #ROBOMERGE-AUTHOR: jamie.dale #ROBOMERGE-SOURCE: CL 21182599 via CL 21182750 via CL 21182943 via CL 21182968 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824) [CL 21192673 by jamie dale in ue5-main branch]
84 lines
2.2 KiB
C++
84 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "HAL/Platform.h"
|
|
#include "Templates/SharedPointer.h"
|
|
#include "Templates/TypeHash.h"
|
|
#include "UObject/ObjectMacros.h"
|
|
|
|
#include "SubobjectDataHandle.generated.h"
|
|
|
|
struct FSubobjectData;
|
|
|
|
/**
|
|
* A subobject handle is a globally unique identifier for subobjects
|
|
* Upon construction, the handle will be invalid. It is the responsibility
|
|
* of the owning FSubobjectData to set the DataPtr once the subobject
|
|
* data has validated that it has a good context.
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct SUBOBJECTDATAINTERFACE_API FSubobjectDataHandle
|
|
{
|
|
friend struct FSubobjectData;
|
|
friend class USubobjectDataSubsystem;
|
|
|
|
GENERATED_USTRUCT_BODY();
|
|
|
|
explicit FSubobjectDataHandle()
|
|
: DataPtr(nullptr)
|
|
{}
|
|
|
|
~FSubobjectDataHandle()
|
|
{
|
|
DataPtr = nullptr;
|
|
}
|
|
|
|
/**
|
|
* True if the Handle is valid (i.e. not INDEX_NONE). This is true once GenerateNewHandle is called
|
|
*
|
|
* @return bool True if this handle is valid
|
|
*/
|
|
inline bool IsValid() const { return DataPtr != nullptr; }
|
|
|
|
bool operator==(const FSubobjectDataHandle& Other) const
|
|
{
|
|
return DataPtr.Get() == Other.DataPtr.Get();
|
|
}
|
|
|
|
bool operator!=(const FSubobjectDataHandle& Other) const
|
|
{
|
|
return DataPtr != Other.DataPtr;
|
|
}
|
|
|
|
/** Returns a pointer to the subobject data that this is a handle for */
|
|
inline TSharedPtr<FSubobjectData> GetSharedDataPtr() const { return DataPtr; }
|
|
inline FSubobjectData* GetData() const { return DataPtr.IsValid() ? DataPtr.Get() : nullptr; }
|
|
|
|
/**
|
|
* A static representation of an invalid handle. Mostly used as a return
|
|
* value for functions that need to return a handle but have the risk of being invalid.
|
|
*/
|
|
static const FSubobjectDataHandle InvalidHandle;
|
|
|
|
/** Get the hash code to use for the given FSubobjectDataHandle */
|
|
friend uint32 GetTypeHash(const FSubobjectDataHandle& Key)
|
|
{
|
|
return PointerHash(Key.DataPtr.Get());
|
|
}
|
|
|
|
private:
|
|
/** Pointer to the actual subobject data that this handle represents */
|
|
TSharedPtr<FSubobjectData> DataPtr;
|
|
};
|
|
|
|
template<>
|
|
struct TStructOpsTypeTraits<FSubobjectDataHandle> : public TStructOpsTypeTraitsBase2<FSubobjectDataHandle>
|
|
{
|
|
enum
|
|
{
|
|
WithIdenticalViaEquality = true,
|
|
};
|
|
};
|