You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Move bIsDefault/bCanEdit(renamed bIsModifiable) from InterfaceRegistryEntry to Interface data definition - Add checks in builder to disallow mutation of interfaces that shouldn't be via editor or document builder (ex. SourceInterface which is default and then never changed) - Optimize SearchEngine query for finding default interfaces - Tweak MetaSoundUObjectRegistry to support non MetasoundAssetBase classes and add UMetaSoundBuilderDocument. Update iterator w/optional param to only return asset types (true by default for back compat) - Move FName class name comparitors to use new TopLevelAssetPath #rb phil.popp #jira UE-181360 #rnx #p4v-preflight-copy 24658328 #preflight 642b10834d26bcd1eb0e566c [CL 24920763 by rob gay in ue5-main branch]
126 lines
3.9 KiB
C++
126 lines
3.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
#include "Interfaces/MetasoundFrontendInterfaceRegistry.h"
|
|
|
|
#include "HAL/PlatformTime.h"
|
|
#include "Interfaces/MetasoundFrontendInterfaceBindingRegistry.h"
|
|
#include "MetasoundFrontendInterfaceRegistryPrivate.h"
|
|
#include "MetasoundFrontendRegistryTransaction.h"
|
|
#include "MetasoundTrace.h"
|
|
|
|
|
|
namespace Metasound::Frontend
|
|
{
|
|
FInterfaceRegistry::FInterfaceRegistry()
|
|
: TransactionBuffer(MakeShared<TTransactionBuffer<FInterfaceRegistryTransaction>>())
|
|
{
|
|
}
|
|
|
|
bool FInterfaceRegistry::RegisterInterface(TUniquePtr<IInterfaceRegistryEntry>&& InEntry)
|
|
{
|
|
METASOUND_LLM_SCOPE;
|
|
|
|
FInterfaceRegistryTransaction::FTimeType TransactionTime = FPlatformTime::Cycles64();
|
|
if (InEntry.IsValid())
|
|
{
|
|
FInterfaceRegistryKey Key = GetInterfaceRegistryKey(InEntry->GetInterface());
|
|
if (IsValidInterfaceRegistryKey(Key))
|
|
{
|
|
if (const IInterfaceRegistryEntry* Entry = FindInterfaceRegistryEntry(Key))
|
|
{
|
|
UE_LOG(LogMetaSound, Warning, TEXT("Registration of interface overwriting previously registered interface [RegistryKey: %s]"), *Key);
|
|
|
|
FInterfaceRegistryTransaction Transaction{FInterfaceRegistryTransaction::ETransactionType::InterfaceUnregistration, Key, Entry->GetInterface().Version, TransactionTime};
|
|
TransactionBuffer->AddTransaction(MoveTemp(Transaction));
|
|
}
|
|
|
|
FInterfaceRegistryTransaction Transaction{FInterfaceRegistryTransaction::ETransactionType::InterfaceRegistration, Key, InEntry->GetInterface().Version, TransactionTime};
|
|
TransactionBuffer->AddTransaction(MoveTemp(Transaction));
|
|
Entries.Add(Key, MoveTemp(InEntry));
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
const IInterfaceRegistryEntry* FInterfaceRegistry::FindInterfaceRegistryEntry(const FInterfaceRegistryKey& InKey) const
|
|
{
|
|
if (const TUniquePtr<IInterfaceRegistryEntry>* Entry = Entries.Find(InKey))
|
|
{
|
|
return Entry->Get();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
bool FInterfaceRegistry::FindInterface(const FInterfaceRegistryKey& InKey, FMetasoundFrontendInterface& OutInterface) const
|
|
{
|
|
if (const IInterfaceRegistryEntry* Entry = FindInterfaceRegistryEntry(InKey))
|
|
{
|
|
OutInterface = Entry->GetInterface();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
TUniquePtr<FInterfaceTransactionStream> FInterfaceRegistry::CreateTransactionStream()
|
|
{
|
|
return MakeUnique<FInterfaceTransactionStream>(TransactionBuffer);
|
|
}
|
|
|
|
bool IsValidInterfaceRegistryKey(const FInterfaceRegistryKey& InKey)
|
|
{
|
|
return !InKey.IsEmpty();
|
|
}
|
|
|
|
FInterfaceRegistryKey GetInterfaceRegistryKey(const FMetasoundFrontendVersion& InInterfaceVersion)
|
|
{
|
|
return FString::Format(TEXT("{0}_{1}.{2}"), { InInterfaceVersion.Name.ToString(), InInterfaceVersion.Number.Major, InInterfaceVersion.Number.Minor });
|
|
|
|
}
|
|
|
|
FInterfaceRegistryKey GetInterfaceRegistryKey(const FMetasoundFrontendInterface& InInterface)
|
|
{
|
|
return GetInterfaceRegistryKey(InInterface.Version);
|
|
}
|
|
|
|
FInterfaceRegistryTransaction::FInterfaceRegistryTransaction(ETransactionType InType, const FInterfaceRegistryKey& InKey, const FMetasoundFrontendVersion& InInterfaceVersion, FInterfaceRegistryTransaction::FTimeType InTimestamp)
|
|
: Type(InType)
|
|
, Key(InKey)
|
|
, InterfaceVersion(InInterfaceVersion)
|
|
, Timestamp(InTimestamp)
|
|
{
|
|
}
|
|
|
|
FInterfaceRegistryTransaction::ETransactionType FInterfaceRegistryTransaction::GetTransactionType() const
|
|
{
|
|
return Type;
|
|
}
|
|
|
|
const FMetasoundFrontendVersion& FInterfaceRegistryTransaction::GetInterfaceVersion() const
|
|
{
|
|
return InterfaceVersion;
|
|
}
|
|
|
|
const FInterfaceRegistryKey& FInterfaceRegistryTransaction::GetInterfaceRegistryKey() const
|
|
{
|
|
return Key;
|
|
}
|
|
|
|
FInterfaceRegistryTransaction::FTimeType FInterfaceRegistryTransaction::GetTimestamp() const
|
|
{
|
|
return Timestamp;
|
|
}
|
|
|
|
FInterfaceRegistry& FInterfaceRegistry::Get()
|
|
{
|
|
static FInterfaceRegistry Registry;
|
|
return Registry;
|
|
}
|
|
|
|
IInterfaceRegistry& IInterfaceRegistry::Get()
|
|
{
|
|
return FInterfaceRegistry::Get();
|
|
}
|
|
} // namespace Metasound::Frontend
|