13#include "CoreMinimal.h"
15#include "Async/Future.h"
88 template<
typename FeatureIn>
106 return IModularFeatures::Get().GetModularFeatureImplementationCount(
FeatureName());
122 return static_cast<Feature*
>(IModularFeatures::Get().GetModularFeatureImplementation(
FeatureName(), index));
128 static FORCEINLINE TArray<Feature*>
GetAll()
130 return IModularFeatures::Get().GetModularFeatureImplementations<
Feature>(
FeatureName());
142 template<
typename Implementation>
requires CDerivedFrom<Implementation, Feature>
146 LogAutoModularFeature, Log,
147 TEXT(
"Registering %s as %s feature"),
151 IModularFeatures::Get().RegisterModularFeature(
FeatureName(), &self);
156 IModularFeatures::Get().UnregisterModularFeature(
FeatureName(),
this);
171 return MakeFulfilledPromise<Feature*>(&
Get()).GetFuture();
175 TSharedRef<TPromise<Feature*>> promise = MakeShared<TPromise<Feature*>>();
176 TFuture<Feature*> result = promise->GetFuture();
177 IModularFeatures::Get().OnModularFeatureRegistered().AddLambda(
178 [promise, once =
FOnce()](
const FName& type, IModularFeature*)
mutable
181 promise->SetValue(&
Get());
DECLARE_LOG_CATEGORY_CLASS(LogAutoModularFeature, Log, Log)
static FORCEINLINE Feature & Get()
static FORCEINLINE TArray< Feature * > GetAll()
static FORCEINLINE int32 ImplementationCount()
void Register(this Implementation &&self)
virtual ~TAutoModularFeature()
static FORCEINLINE TFuture< Feature * > GetBelated()
static FORCEINLINE const FName & FeatureName()
static FORCEINLINE Feature * TryGet(const int32 index)
const FString TTypeString