2023-06-16 17:48:20 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "MetasoundDocumentInterface.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Metasound::Frontend
|
|
|
|
|
{
|
|
|
|
|
namespace DocumentBuilderRegistryPrivate
|
|
|
|
|
{
|
2023-09-14 17:47:02 -04:00
|
|
|
static bool bInitialized = false;
|
2023-09-05 17:54:02 -04:00
|
|
|
TUniqueFunction<IDocumentBuilderRegistry&()> GetInstance;
|
2023-06-16 17:48:20 -04:00
|
|
|
} // namespace DocumentBuilderRegistryPrivate
|
|
|
|
|
|
2023-09-14 17:47:02 -04:00
|
|
|
IDocumentBuilderRegistry* IDocumentBuilderRegistry::Get()
|
|
|
|
|
{
|
|
|
|
|
using namespace DocumentBuilderRegistryPrivate;
|
|
|
|
|
|
|
|
|
|
if (!DocumentBuilderRegistryPrivate::bInitialized)
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &GetInstance();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-05 17:54:02 -04:00
|
|
|
IDocumentBuilderRegistry& IDocumentBuilderRegistry::GetChecked()
|
2023-06-16 17:48:20 -04:00
|
|
|
{
|
|
|
|
|
using namespace DocumentBuilderRegistryPrivate;
|
|
|
|
|
|
|
|
|
|
checkf(GetInstance, TEXT("Failed to return MetaSoundDocumentBuilderRegistry instance: Registry has not been initialized"));
|
|
|
|
|
return GetInstance();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-05 17:54:02 -04:00
|
|
|
void IDocumentBuilderRegistry::Set(TUniqueFunction<IDocumentBuilderRegistry&()>&& InGetInstance)
|
2023-06-16 17:48:20 -04:00
|
|
|
{
|
|
|
|
|
using namespace DocumentBuilderRegistryPrivate;
|
|
|
|
|
|
|
|
|
|
checkf(!GetInstance, TEXT("Failed to initialize MetaSoundDocumentBuilderRegistry getter: Cannot reinitialize once initialized."))
|
|
|
|
|
GetInstance = MoveTemp(InGetInstance);
|
2023-09-14 17:47:02 -04:00
|
|
|
DocumentBuilderRegistryPrivate::bInitialized = true;
|
2023-06-16 17:48:20 -04:00
|
|
|
}
|
2023-09-14 16:54:36 -04:00
|
|
|
|
|
|
|
|
IMetaSoundDocumentBuilderRegistry& IMetaSoundDocumentBuilderRegistry::GetChecked()
|
|
|
|
|
{
|
|
|
|
|
return static_cast<IMetaSoundDocumentBuilderRegistry&>(IDocumentBuilderRegistry::GetChecked());
|
|
|
|
|
}
|
2023-09-21 18:24:25 -04:00
|
|
|
} // namespace Metasound::Frontend
|