Files
henrik karlsson 4a36cfe8ff Moved operator== to be hidden friend instead of put directly in global namespace
Moved GetTypeHash function to be hidden friend instead of put directly in global namespace.

Note that the function/operator needs to be fully inlined in the type or placed in the cpp. If the function is added as friend but then implemented outside the type then hidden friend optimization won't work.

This should improve compile time somewhat according to msvc devs.

#rb Steve.Robb
#preflight 6360b7052b5338aceb26471b

[CL 22889837 by henrik karlsson in ue5-main branch]
2022-11-01 15:50:27 -04:00

114 lines
3.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Analysis/MetasoundFrontendAnalyzerAddress.h"
#include "MetasoundArrayNodesRegistration.h"
#include "MetasoundDataTypeRegistrationMacro.h"
#include "MetasoundFrontendDataTypeTraits.h"
#include "Misc/AssertionMacros.h"
namespace Metasound
{
namespace Frontend
{
FAnalyzerAddress::FAnalyzerAddress(const FString& InAddressString)
{
TArray<FString> Tokens;
if (ensureAlwaysMsgf(InAddressString.ParseIntoArray(Tokens, METASOUND_ANALYZER_PATH_SEPARATOR) == 7, TEXT("Invalid Analyzer Address String Format")))
{
InstanceID = static_cast<uint64>(FCString::Atoi64(*Tokens[0]));
NodeID = FGuid(Tokens[1]);
OutputName = *Tokens[2];
DataType = *Tokens[3];
AnalyzerName = *Tokens[4];
AnalyzerInstanceID = FGuid(Tokens[5]);
AnalyzerMemberName = *Tokens[6];
}
}
FName FAnalyzerAddress::GetAddressType() const
{
return "Analyzer";
}
FName FAnalyzerAddress::GetDataType() const
{
return DataType;
}
TUniquePtr<FTransmissionAddress> FAnalyzerAddress::Clone() const
{
return TUniquePtr<FTransmissionAddress>(new FAnalyzerAddress(*this));
}
uint32 FAnalyzerAddress::GetHash() const
{
uint32 AddressHash = HashCombineFast(AnalyzerInstanceID.A, GetTypeHashHelper(AnalyzerMemberName));
AddressHash = HashCombineFast(AddressHash, GetTypeHashHelper(AnalyzerName));
AddressHash = HashCombineFast(AddressHash, GetTypeHashHelper(DataType));
AddressHash = HashCombineFast(AddressHash, GetTypeHashHelper(InstanceID));
AddressHash = HashCombineFast(AddressHash, NodeID.A);
AddressHash = HashCombineFast(AddressHash, GetTypeHashHelper(OutputName));
return AddressHash;
}
bool FAnalyzerAddress::IsEqual(const FTransmissionAddress& InOther) const
{
if (InOther.GetAddressType() != GetAddressType())
{
return false;
}
const FAnalyzerAddress& OtherAddr = static_cast<const FAnalyzerAddress&>(InOther);
return OtherAddr.AnalyzerInstanceID == AnalyzerInstanceID
&& OtherAddr.AnalyzerMemberName == AnalyzerMemberName
&& OtherAddr.AnalyzerName == AnalyzerName
&& OtherAddr.DataType == DataType
&& OtherAddr.InstanceID == InstanceID
&& OtherAddr.NodeID == NodeID
&& OtherAddr.OutputName == OutputName;
}
FString FAnalyzerAddress::ToString() const
{
return FString::Join(TArray<FString>
{
*FString::Printf(TEXT("%lld"), InstanceID),
*NodeID.ToString(),
*OutputName.ToString(),
*DataType.ToString(),
*AnalyzerName.ToString(),
*AnalyzerInstanceID.ToString(),
*AnalyzerMemberName.ToString()
}, METASOUND_ANALYZER_PATH_SEPARATOR);
}
} // namespace Frontend
template<>
struct TEnableArrayNodes<Frontend::FAnalyzerAddress>
{
static constexpr bool Value = false;
};
template<>
struct TEnableTransmissionNodeRegistration<Frontend::FAnalyzerAddress>
{
static constexpr bool Value = false;
};
template<typename FromDataType>
struct TEnableAutoConverterNodeRegistration<FromDataType, Frontend::FAnalyzerAddress>
{
static constexpr bool Value = false;
};
template<>
struct TEnableConstructorVertex<Frontend::FAnalyzerAddress>
{
static constexpr bool Value = false;
};
REGISTER_METASOUND_DATATYPE(Frontend::FAnalyzerAddress, "AnalyzerAddress");
} // namespace Metasound