Files
UnrealEngineUWP/Engine/Source/Developer/DerivedDataCache/Public/DerivedDataBuildFunctionFactory.h
devin doucette c3443800ec DDC: Converted modular feature names to constant lazy names
#rb Zousar.Shaker
#rnx
#preflight 61f97050fa6554dff3d6fa76

#ROBOMERGE-AUTHOR: devin.doucette
#ROBOMERGE-SOURCE: CL 18812871 in //UE5/Release-5.0/... via CL 18812927 via CL 18822743
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v909-18823584)

[CL 18823987 by devin doucette in ue5-main branch]
2022-02-02 06:26:22 -05:00

60 lines
1.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "DerivedDataBuildFunction.h"
#include "Features/IModularFeatures.h"
#include "UObject/NameTypes.h"
namespace UE::DerivedData
{
/** DO NOT USE DIRECTLY. Base for the build function factory. Use TBuildFunctionFactory. */
class IBuildFunctionFactory : public IModularFeature
{
public:
static inline const FLazyName FeatureName{"BuildFunctionFactory"};
/** Returns the build function associated with this factory. */
virtual const IBuildFunction& GetFunction() const = 0;
};
/**
* Factory that creates and registers a build function.
*
* A build function must be registered by a build function factory before it can execute a build.
* Register a function in the source file that implements it or in the corresponding module.
*
* Examples:
* static const TBuildFunctionFactory<FExampleFunction> ExampleFunctionFactory;
* static const TBuildFunctionFactory<TExampleFunction<FType>> ExampleFunctionFactory(Name, Version);
*/
template <typename FunctionType>
class TBuildFunctionFactory final : public IBuildFunctionFactory
{
static_assert(sizeof(FunctionType) == sizeof(IBuildFunction), "IBuildFunction must be pure and maintain no state.");
public:
template <typename... ArgTypes>
explicit TBuildFunctionFactory(ArgTypes&&... Args)
: Function(Forward<ArgTypes>(Args)...)
{
IModularFeatures::Get().RegisterModularFeature(FeatureName, this);
}
~TBuildFunctionFactory()
{
IModularFeatures::Get().UnregisterModularFeature(FeatureName, this);
}
const IBuildFunction& GetFunction() const final
{
return Function;
}
private:
const FunctionType Function;
};
} // UE::DerivedData