Files
UnrealEngineUWP/Engine/Source/Runtime/AnimationCore/Public/AnimationDataSource.h
Bryan sefcik b4a6e947d8 Ran IWYU on Public headers under Engine/Source/Runtime/...
Headers are updated to contain any missing #includes needed to compile and #includes are sorted.  Nothing is removed.

#ushell-cherrypick of 21065896 by bryan.sefcik
#preflight 62d4b1a5a6141b6adfb0c892
#jira

#ROBOMERGE-OWNER: Bryan.sefcik
#ROBOMERGE-AUTHOR: bryan.sefcik
#ROBOMERGE-SOURCE: CL 21150156 via CL 21151754 via CL 21154719
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)
#ROBOMERGE-CONFLICT from-shelf

[CL 21181076 by Bryan sefcik in ue5-main branch]
2022-07-20 11:31:36 -04:00

86 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/Map.h"
#include "CoreMinimal.h"
#include "Templates/Casts.h"
#include "UObject/Interface.h"
#include "UObject/NameTypes.h"
#include "UObject/Object.h"
#include "UObject/ObjectMacros.h"
#include "UObject/UObjectGlobals.h"
#include "UObject/WeakObjectPtrTemplates.h"
#include "AnimationDataSource.generated.h"
class UClass;
UCLASS()
class ANIMATIONCORE_API UAnimationDataSourceRegistry : public UObject
{
GENERATED_BODY()
public:
/**
* Registers a new data source under a given name.
* Returns false in case the data source has already been registered.
*
* @param InName The name to register the data source under
* @param InDataSource The data source to register
* @return true if succeeded
*/
bool RegisterDataSource(const FName& InName, UObject* InDataSource);
/**
* Unregisters / removes an existing data source under a given name.
* Returns false in case the data source has already been unregistered.
*
* @param InName The name of the data source to remove
* @return true if succeeded
*/
bool UnregisterDataSource(const FName& InName);
/**
* Returns true if this registry contains a source with the given name
*
* @param InName The name of the data source to look up.
* @return true if a source with the given name exists
*/
bool ContainsSource(const FName& InName) const;
/**
* Returns a given data source and cast it to the expected class.
*
* @param InName The name of the data source to look up.
* @param InExpectedClass The class expected from the data source
* @return The requested data source
*/
UObject* RequestSource(const FName& InName, UClass* InExpectedClass) const;
/**
* Returns a given data source and cast it to the expected class.
*
* @param InName The name of the data source to look up.
* @return The requested data source
*/
template<class T>
T* RequestSource(const FName& InName) const
{
UObject* DataSource = RequestSource(InName, T::StaticClass());
if (DataSource == nullptr)
{
return nullptr;
}
return Cast<T>(DataSource);
}
private:
UPROPERTY(transient)
TMap<FName, TWeakObjectPtr<UObject>> DataSources;
/** Clear Invalid Data Sources that are GC-ed */
void ClearInvalidDataSource();
};