Files
andrew rodham 2a214e6c18 Added initial draft of Universal Object Locator mechanism
Universal Object Locators (UOLs) are designed to support referencing objects that don't fit neatly into a basic outer->inner path representation. Examples might include transient actors, dynamically created objects, or objects that need to be referenced by an external ID or using external lookup logic. Specifically this might be an object spawned by Sequencer, a transient object on a USD stage, or a gameplay-specific object created by a game system.

A UOL comprises zero or more 'fragments': atomic pieces of data and logic that defines how to lookup or load an object based on a context. Fragment types are globally registered as part of module initialization.
UOLs are hashable, and support string conversion that conforms to RFC3986 so they can be used as URIs (though that is not a current use-case). In order to support this type of string conversion, the 'path' part of of a UOL defines the fragment types, and the query string is used to encode the payload data for each fragment. This allows us to support a more diverse set of characters as part of payload strings (ie, / : and .) which are otherwise unsupported as part of the path.

An example UOL to an anim instance might look like: uobj://actor/subobj/animinst?payload0=/Path/To/Package.LevelName:PathToActor&payload1=ComponentName

#rb david.bromberg, ludovic.chabant, Max.Chen

[CL 29714989 by andrew rodham in ue5-main branch]
2023-11-14 11:31:58 -05:00

52 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreTypes.h"
#include "UObject/SoftObjectPath.h"
#include "UniversalObjectLocatorFwd.h"
#include "DirectPathObjectLocator.generated.h"
class UObject;
/**
* Object locator type that simply references its object by a direct path
*/
USTRUCT()
struct FDirectPathObjectLocator
{
GENERATED_BODY()
UPROPERTY()
FSoftObjectPath Path;
UNIVERSALOBJECTLOCATOR_API static UE::UniversalObjectLocator::TFragmentTypeHandle<FDirectPathObjectLocator> FragmentType;
friend uint32 GetTypeHash(const FDirectPathObjectLocator& A)
{
return GetTypeHash(A.Path);
}
friend bool operator==(const FDirectPathObjectLocator& A, const FDirectPathObjectLocator& B)
{
return A.Path == B.Path;
}
UE::UniversalObjectLocator::FResolveResult Resolve(const UE::UniversalObjectLocator::FResolveParams& Params) const;
UE::UniversalObjectLocator::FInitializeResult Initialize(const UE::UniversalObjectLocator::FInitializeParams& InParams);
void ToString(FStringBuilderBase& OutStringBuilder) const;
UE::UniversalObjectLocator::FParseStringResult TryParseString(FStringView InString, const UE::UniversalObjectLocator::FParseStringParams& Params);
static uint32 ComputePriority(const UObject* Object, const UObject* Context);
};
template<>
struct TStructOpsTypeTraits<FDirectPathObjectLocator> : public TStructOpsTypeTraitsBase2<FDirectPathObjectLocator>
{
enum
{
WithIdenticalViaEquality = true,
};
};