Files
UnrealEngineUWP/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Public/Analysis/MetasoundFrontendAnalyzerView.h
Rob Gay 20742757be - Narrow/privitize template implementation scope for MetaSound Analyzers
- Implement/encapsulate binding for analyzer output/sender logic
- Move to using FAnyDataReferences where possible over collections for analyzers
- Misc clean-up
#jira UE-147027
#rb phil.popp
#preflight 627d3884332e182a583f19b3

[CL 20167469 by Rob Gay in ue5-main branch]
2022-05-12 13:47:17 -04:00

57 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Analysis/MetasoundFrontendVertexAnalyzer.h"
#include "Containers/Array.h"
#include "HAL/Platform.h"
#include "MetasoundAssetBase.h"
#include "MetasoundRouter.h"
#include "Templates/UniquePtr.h"
// Forward Declarations
class FMetasoundAssetBase;
class UAudioComponent;
namespace Metasound
{
// Forward Declarations
class FOperatorSettings;
namespace Frontend
{
// Pairs an IReceiver with a given AnalyzerAddress, which enables
// watching a particular analyzer result on any given thread.
class METASOUNDFRONTEND_API FMetasoundAnalyzerView
{
TMap<FName, TSharedPtr<IReceiver>> OutputReceivers;
public:
const FAnalyzerAddress AnalyzerAddress = { };
FMetasoundAnalyzerView() = default;
FMetasoundAnalyzerView(FAnalyzerAddress&& InAnalyzerAddress);
void BindToAllOutputs(const FOperatorSettings& InOperatorSettings);
bool UnbindOutput(FName InOutputName);
template <typename DataType>
bool TryGetOutputData(FName InOutputName, DataType& OutValue)
{
TSharedPtr<IReceiver>* Receiver = OutputReceivers.Find(InOutputName);
if (Receiver && Receiver->IsValid())
{
TReceiver<DataType>& TypedReceiver = (*Receiver)->GetAs<TReceiver<DataType>>();
if (TypedReceiver.CanPop())
{
TypedReceiver.Pop(OutValue);
return true;
}
}
return false;
}
};
}
}