2021-11-07 23:43:01 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "MetasoundAssetManager.h"
|
2024-05-08 14:53:53 -04:00
|
|
|
#include "MetasoundFrontendRegistryKey.h"
|
2021-11-07 23:43:01 -05:00
|
|
|
|
2024-05-08 14:53:53 -04:00
|
|
|
namespace Metasound::Frontend
|
2021-11-07 23:43:01 -05:00
|
|
|
{
|
2024-05-08 14:53:53 -04:00
|
|
|
namespace AssetManagerPrivate
|
2021-11-07 23:43:01 -05:00
|
|
|
{
|
2024-05-08 14:53:53 -04:00
|
|
|
static TUniquePtr<IMetaSoundAssetManager> Instance;
|
|
|
|
|
|
|
|
|
|
bool IsAssetClassType(EMetasoundFrontendClassType ClassType)
|
2021-11-07 23:43:01 -05:00
|
|
|
{
|
2024-05-08 14:53:53 -04:00
|
|
|
switch (ClassType)
|
|
|
|
|
{
|
|
|
|
|
case EMetasoundFrontendClassType::External:
|
|
|
|
|
case EMetasoundFrontendClassType::Graph:
|
|
|
|
|
case EMetasoundFrontendClassType::Invalid:
|
|
|
|
|
return true;
|
2021-11-07 23:43:01 -05:00
|
|
|
|
2024-05-08 14:53:53 -04:00
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} // AssetManagerPrivate
|
|
|
|
|
|
|
|
|
|
namespace AssetTags
|
|
|
|
|
{
|
|
|
|
|
const FString ArrayDelim = TEXT(",");
|
|
|
|
|
|
|
|
|
|
const FName AssetClassID = "AssetClassID";
|
2022-10-26 15:28:04 -04:00
|
|
|
|
|
|
|
|
#if WITH_EDITORONLY_DATA
|
2024-05-08 14:53:53 -04:00
|
|
|
const FName IsPreset = "bIsPreset";
|
2022-10-26 15:28:04 -04:00
|
|
|
#endif // WITH_EDITORONLY_DATA
|
|
|
|
|
|
2024-05-08 14:53:53 -04:00
|
|
|
const FName RegistryVersionMajor = "RegistryVersionMajor";
|
|
|
|
|
const FName RegistryVersionMinor = "RegistryVersionMinor";
|
2021-11-07 23:43:01 -05:00
|
|
|
|
|
|
|
|
#if WITH_EDITORONLY_DATA
|
2024-05-08 14:53:53 -04:00
|
|
|
const FName RegistryInputTypes = "RegistryInputTypes";
|
|
|
|
|
const FName RegistryOutputTypes = "RegistryOutputTypes";
|
2021-11-07 23:43:01 -05:00
|
|
|
#endif // WITH_EDITORONLY_DATA
|
2024-05-08 14:53:53 -04:00
|
|
|
} // namespace AssetTags
|
2021-11-07 23:43:01 -05:00
|
|
|
|
2024-05-08 14:53:53 -04:00
|
|
|
FAssetKey::FAssetKey(const FMetasoundFrontendClassName& InClassName, const FMetasoundFrontendVersionNumber& InVersion)
|
|
|
|
|
: ClassName(InClassName)
|
|
|
|
|
, Version(InVersion)
|
|
|
|
|
{
|
|
|
|
|
}
|
2024-01-17 07:07:19 -05:00
|
|
|
|
2024-05-08 14:53:53 -04:00
|
|
|
FAssetKey::FAssetKey(const FNodeRegistryKey& RegKey)
|
|
|
|
|
: ClassName(RegKey.ClassName)
|
|
|
|
|
, Version(RegKey.Version)
|
|
|
|
|
{
|
|
|
|
|
checkf(AssetManagerPrivate::IsAssetClassType(RegKey.Type), TEXT("Invalid ClassType '%s' for Registry Key"), LexToString(RegKey.Type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FAssetKey::FAssetKey(const FMetasoundFrontendClassMetadata& InMetadata)
|
|
|
|
|
: ClassName(InMetadata.GetClassName())
|
|
|
|
|
, Version(InMetadata.GetVersion())
|
|
|
|
|
{
|
|
|
|
|
checkf(AssetManagerPrivate::IsAssetClassType(InMetadata.GetType()), TEXT("Invalid ClassType '%s' for Registry Key"), LexToString(InMetadata.GetType()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FString FAssetKey::ToString() const
|
|
|
|
|
{
|
|
|
|
|
TStringBuilder<128> KeyStringBuilder;
|
|
|
|
|
KeyStringBuilder.Append(ClassName.GetFullName().ToString());
|
|
|
|
|
KeyStringBuilder.AppendChar('_');
|
|
|
|
|
KeyStringBuilder.Append(FString::FromInt(Version.Major));
|
|
|
|
|
KeyStringBuilder.AppendChar('.');
|
|
|
|
|
KeyStringBuilder.Append(FString::FromInt(Version.Minor));
|
|
|
|
|
return KeyStringBuilder.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IMetaSoundAssetManager* IMetaSoundAssetManager::Get()
|
|
|
|
|
{
|
|
|
|
|
return AssetManagerPrivate::Instance.Get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IMetaSoundAssetManager& IMetaSoundAssetManager::GetChecked()
|
|
|
|
|
{
|
|
|
|
|
check(AssetManagerPrivate::Instance.IsValid());
|
|
|
|
|
return *AssetManagerPrivate::Instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IMetaSoundAssetManager::Deinitialize()
|
|
|
|
|
{
|
|
|
|
|
if (AssetManagerPrivate::Instance.IsValid())
|
|
|
|
|
{
|
|
|
|
|
AssetManagerPrivate::Instance.Reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IMetaSoundAssetManager::Initialize(TUniquePtr<IMetaSoundAssetManager>&& InInterface)
|
|
|
|
|
{
|
|
|
|
|
check(!AssetManagerPrivate::Instance.IsValid());
|
|
|
|
|
AssetManagerPrivate::Instance = MoveTemp(InInterface);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IMetaSoundAssetManager::IsTesting() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} // namespace Metasound::Frontend
|