13#include "CoreMinimal.h"
14#include "Features/IModularFeatures.h"
15#include "Async/Future.h"
95 template<
typename FeatureIn>
118 return IModularFeatures::Get().GetModularFeatureImplementationCount(
FeatureName());
133 return static_cast<Feature*
>(IModularFeatures::Get().GetModularFeatureImplementation(
FeatureName(), index));
137 static FORCEINLINE TArray<Feature*>
GetAll()
139 return IModularFeatures::Get().GetModularFeatureImplementations<
Feature>(
FeatureName());
153 template<
typename Implementation>
requires CDerivedFrom<Implementation, Feature>
157 LogAutoModularFeature, Log,
158 TEXT_"Registering %s as %s feature",
162 IModularFeatures::Get().RegisterModularFeature(
FeatureName(), &self);
168 IModularFeatures::Get().UnregisterModularFeature(
FeatureName(),
this);
186 TSharedRef<TPromise<Feature*>> promise = MakeShared<TPromise<Feature*>>();
187 TFuture<Feature*> result = promise->GetFuture();
191 promise->SetValue(feature);
DECLARE_LOG_CATEGORY_CLASS(LogAutoModularFeature, Log, Log)
#define TEXT_
A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around ...
Tagging an auto feature (DO NOT USE MANUALLY, inherited by TAutoModularFeature)
Tagging an implementation of a feature.
Auto Modular Features are a workflow with Modular Features where the developer doesn't have to rely o...
static FORCEINLINE Feature & Get()
Get the first existing implementation of this feature. If there are no implementations a check will f...
static auto OnRegistered() -> TBelatedEventDelegate< void(Feature *)> &
This event is triggered when an implementation of this feature is created.
static FORCEINLINE TArray< Feature * > GetAll()
static FORCEINLINE int32 ImplementationCount()
void Register(this Implementation &&self)
Call this function in implementation constructors.
virtual ~TAutoModularFeature()
static FORCEINLINE TFuture< Feature * > GetBelated()
Get the first implementation once it is registered, or return the first implementation immediately if...
static FORCEINLINE Feature * TryGet(const int32 index)
Get the first existing implementation of this feature. Return nullptr If there are no implementations...
static FORCEINLINE FName FeatureName()
Get the name of the feature.
"Extension" of a common TMulticastDelegate. It allows to define optional "flags" when adding a bindin...
TInferredDelegate< Function, Captures... > From(Function func, Captures &&... captures)
Instead of specifying manually a delegate type, infer it from the input function and the extra captur...
FName TTypeFName()
Same as TTypeName converted to FName. This is not cached and a new FName is created every time this i...
FString TTypeString()
Same as TTypeName converted to FString. This is not cached and a new FString is created every time th...