Files
UnrealEngineUWP/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Private/MetasoundFrontendSearchEngineEditorOnly.cpp
rob gay 1de499ef8e More MetaSound Interface registry clean-up
- 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]
2023-04-04 19:14:26 -04:00

188 lines
6.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MetasoundFrontendSearchEngineEditorOnly.h"
#include "Containers/Array.h"
#include "Interfaces/MetasoundFrontendInterfaceRegistry.h"
#include "MetasoundFrontendDocument.h"
#include "MetasoundFrontendQuery.h"
#include "MetasoundFrontendQuerySteps.h"
#include "MetasoundFrontendRegistryTransaction.h"
#include "MetasoundFrontendSearchEngineCore.h"
#include "MetasoundTrace.h"
#if WITH_EDITORONLY_DATA
namespace Metasound
{
namespace Frontend
{
FFrontendQuery FFindAllClassesQueryPolicy::CreateQuery()
{
using namespace SearchEngineQuerySteps;
FFrontendQuery Query;
Query.AddStep<FNodeClassRegistrationEvents>()
.AddStep<FMapRegistrationEventsToNodeRegistryKeys>()
.AddStep<FReduceRegistrationEventsToCurrentStatus>()
.AddStep<FTransformRegistrationEventsToClasses>()
.AddStep<FRemoveDeprecatedClasses>()
.AddStep<FMapToNull>();
return Query;
}
TArray<FMetasoundFrontendClass> FFindAllClassesQueryPolicy::BuildResult(const FFrontendQueryPartition& InPartition)
{
using namespace SearchEngineQuerySteps;
return BuildArrayOfClassesFromPartition(InPartition);
}
FFrontendQuery FFindAllClassesIncludingAllVersionsQueryPolicy::CreateQuery()
{
using namespace SearchEngineQuerySteps;
FFrontendQuery Query;
Query.AddStep<FNodeClassRegistrationEvents>()
.AddStep<FMapRegistrationEventsToNodeRegistryKeys>()
.AddStep<FReduceRegistrationEventsToCurrentStatus>()
.AddStep<FTransformRegistrationEventsToClasses>()
.AddStep<FMapToNull>();
return Query;
}
TArray<FMetasoundFrontendClass> FFindAllClassesIncludingAllVersionsQueryPolicy::BuildResult(const FFrontendQueryPartition& InPartition)
{
using namespace SearchEngineQuerySteps;
return BuildArrayOfClassesFromPartition(InPartition);
}
FFrontendQuery FFindClassesWithNameSortedQueryPolicy::CreateQuery()
{
using namespace SearchEngineQuerySteps;
FFrontendQuery Query;
Query.AddStep<FNodeClassRegistrationEvents>()
.AddStep<FMapRegistrationEventsToNodeRegistryKeys>()
.AddStep<FReduceRegistrationEventsToCurrentStatus>()
.AddStep<FTransformRegistrationEventsToClasses>()
.AddStep<FMapClassesToClassName>()
.AddStep<FSortClassesByVersion>();
return Query;
}
TArray<FMetasoundFrontendClass> FFindClassesWithNameSortedQueryPolicy::BuildResult(const FFrontendQueryPartition& InPartition)
{
using namespace SearchEngineQuerySteps;
return BuildArrayOfClassesFromPartition(InPartition);
}
FFrontendQuery FFindClassesWithNameUnsortedQueryPolicy::CreateQuery()
{
using namespace SearchEngineQuerySteps;
FFrontendQuery Query;
Query.AddStep<FNodeClassRegistrationEvents>()
.AddStep<FMapRegistrationEventsToNodeRegistryKeys>()
.AddStep<FReduceRegistrationEventsToCurrentStatus>()
.AddStep<FTransformRegistrationEventsToClasses>()
.AddStep<FMapClassesToClassName>();
return Query;
}
TArray<FMetasoundFrontendClass> FFindClassesWithNameUnsortedQueryPolicy::BuildResult(const FFrontendQueryPartition& InPartition)
{
using namespace SearchEngineQuerySteps;
return BuildArrayOfClassesFromPartition(InPartition);
}
FFrontendQuery FFindClassWithHighestVersionQueryPolicy::CreateQuery()
{
using namespace SearchEngineQuerySteps;
FFrontendQuery Query;
Query.AddStep<FNodeClassRegistrationEvents>()
.AddStep<FMapRegistrationEventsToNodeRegistryKeys>()
.AddStep<FReduceRegistrationEventsToCurrentStatus>()
.AddStep<FTransformRegistrationEventsToClasses>()
.AddStep<FRemoveDeprecatedClasses>()
.AddStep<FMapToFullClassName>()
.AddStep<FReduceClassesToHighestVersion>();
return Query;
}
FMetasoundFrontendClass FFindClassWithHighestVersionQueryPolicy::BuildResult(const FFrontendQueryPartition& InPartition)
{
using namespace SearchEngineQuerySteps;
return BuildSingleClassFromPartition(InPartition);
}
void FSearchEngineEditorOnly::Prime()
{
Super::Prime();
{
METASOUND_LLM_SCOPE;
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE(metasound::FSearchEngineEditorOnly::Prime);
FindAllClassesQuery.Prime();
FindAllClassesIncludingAllVersionsQuery.Prime();
FindClassesWithNameUnsortedQuery.Prime();
FindClassesWithNameSortedQuery.Prime();
FindClassWithHighestVersionQuery.Prime();
FindAllInterfacesIncludingAllVersionsQuery.Prime();
FindAllInterfacesQuery.Prime();
}
}
TArray<FMetasoundFrontendClass> FSearchEngineEditorOnly::FindAllClasses(bool bInIncludeAllVersions)
{
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE(metasound::FSearchEngineEditorOnly::FindAllClasses);
FFrontendQueryKey NullKey;
if (bInIncludeAllVersions)
{
return FindAllClassesIncludingAllVersionsQuery.UpdateAndFindResult(NullKey);
}
else
{
return FindAllClassesQuery.UpdateAndFindResult(NullKey);
}
}
TArray<FMetasoundFrontendClass> FSearchEngineEditorOnly::FindClassesWithName(const FMetasoundFrontendClassName& InName, bool bInSortByVersion)
{
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE(metasound::FSearchEngineEditorOnly::FindClassesWithName);
const FFrontendQueryKey Key(InName.GetFullName());
if (bInSortByVersion)
{
return FindClassesWithNameSortedQuery.UpdateAndFindResult(Key);
}
else
{
return FindClassesWithNameUnsortedQuery.UpdateAndFindResult(Key);
}
}
bool FSearchEngineEditorOnly::FindClassWithHighestVersion(const FMetasoundFrontendClassName& InName, FMetasoundFrontendClass& OutClass)
{
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE(metasound::FSearchEngineEditorOnly::FindClassWithHighestVersion);
const FFrontendQueryKey Key{InName.GetFullName()};
return FindClassWithHighestVersionQuery.UpdateAndFindResult(Key, OutClass);
}
TArray<FMetasoundFrontendInterface> FSearchEngineEditorOnly::FindAllInterfaces(bool bInIncludeAllVersions)
{
METASOUND_TRACE_CPUPROFILER_EVENT_SCOPE(metasound::FSearchEngineEditorOnly::FindAllInterfaces);
const FFrontendQueryKey NullKey;
if (bInIncludeAllVersions)
{
return FindAllInterfacesIncludingAllVersionsQuery.UpdateAndFindResult(NullKey);
}
else
{
return FindAllInterfacesQuery.UpdateAndFindResult(NullKey);
}
}
}
}
#endif