Files
UnrealEngineUWP/Engine/Plugins/Runtime/Metasound/Source/MetasoundFrontend/Private/MetasoundFrontendRegistryTransaction.h
phil popp d4af456a9c Metasound Frontend Perf Tuneup
- Added frontend search engine to cache frontend queries
- Allowing frontend queries to be updated in place.
- Tracking node registration transactions to allow incremental runtime checks of newly registered nodes.
- Create public RegistryContainer interface and hide implementation to allow for further optimizations without changing public headers
#jira UEAU-749
#rb Max.Hayes, Jimmy.Smith
#preflight 606399a6e05c4e0001a0d173

#ROBOMERGE-SOURCE: CL 15868737 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v786-15839533)

[CL 15868744 by phil popp in ue5-main branch]
2021-03-30 18:22:10 -04:00

76 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "MetasoundFrontend.h"
namespace Metasound
{
namespace Frontend
{
using FRegistryTransactionID = int32;
/** Returns an ID representing the beginning of the transaction history. */
FRegistryTransactionID GetOriginRegistryTransactionID();
/** Interface for a registry transaction. */
class IRegistryTransaction
{
public:
virtual ~IRegistryTransaction() = default;
virtual TUniquePtr<IRegistryTransaction> Clone() const = 0;
/** If a FNodeClassInfo added during the transaction, this will return
* a non-null pointer to the FNodeClassInfo. */
virtual const FNodeClassInfo* GetNodeClassInfo() const = 0;
};
using FRegistryTransactionPtr = TUniquePtr<IRegistryTransaction>;
/** Create a node registration transaction. */
FRegistryTransactionPtr MakeNodeRegistrationTransaction(const FNodeClassInfo& InInfo);
/** Maintains a history of IRegistryTransactions. Calls are threadsafe (excluding
* the constructor and destructor.)
*/
class FRegistryTransactionHistory
{
public:
FRegistryTransactionHistory();
/** Add a transaction to the history. Threadsafe.
*
* @return The transaction ID associated with the action. */
FRegistryTransactionID Add(FRegistryTransactionPtr&& InRegistryTransaction);
/** Add a transaction to the history. Threadsafe.
*
* @return The transaction ID associated with the action. */
FRegistryTransactionID Add(const IRegistryTransaction& InRegistryTransaction);
/** Gets the transaction ID of the most recent transaction. Threadsafe. */
FRegistryTransactionID GetCurrent() const;
/** Returns an array of transaction pointers. Threadsafe.
*
* @param InSince - All transactions occuring after this transaction ID will be returned.
* @param OutCurrent - If not null, will be set to the most recent transaction ID returned.
*/
TArray<const IRegistryTransaction*> GetTransactions(FRegistryTransactionID InSince, FRegistryTransactionID* OutCurrent) const;
private:
mutable FCriticalSection RegistryTransactionMutex;
FRegistryTransactionID Current;
TMap<FRegistryTransactionID, int32> RegistryTransactionIndexMap;
TArray<FRegistryTransactionPtr> RegistryTransactions;
};
}
}