// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "MetasoundRouter.h" #include "MetasoundFrontendRegistries.h" #include namespace Metasound { namespace MetasoundTransmissionPrivate { // Determines whether send/receive nodes are enabled for a specific data type. template struct TEnableTransmission { static constexpr bool Value = true; }; // TTransmissionSupport determines whether the send/receive system is // supported for a given data type. It is used to add send/receive // support when possible, and avoid errors when registering data types // that do not support the transmission system. template struct TTransmissionSupport { private: static constexpr bool bEnabled = TEnableTransmission::Value; // All types that support copy assignment and copy construction can be // used in the transmission system. static constexpr bool bIsCopyable = std::is_copy_assignable::value && std::is_copy_constructible::value; // IAudioDataType derived classes have specialized templates for the // transmission system. static constexpr bool bIsAudioDataType = std::is_base_of::value; public: static constexpr bool bIsTransmissionSupported = bEnabled && (bIsCopyable || bIsAudioDataType); }; // At the time of writing this code, TArray incorrectly defines a copy constructor // even when the underlying elements or not copyable. Normally this results // in compilation errors when trying to utilize the erroneously defined // TArray copy constructor. This specialization checks the underlying TArray // element type to determine if the array is copyable. template struct TTransmissionSupport> { static constexpr bool bIsCopyable = std::is_copy_assignable::value && std::is_copy_constructible::value; static constexpr bool bEnabled = TEnableTransmission>::Value; public: static constexpr bool bIsTransmissionSupported = bIsCopyable && bEnabled; }; } struct FTransmissionDataChannelFactory { /** Create a transmission IDataChannel given a data type. * * This function is defined if a data type is supported by the transmission system. */ template< typename DataType, typename std::enable_if< MetasoundTransmissionPrivate::TTransmissionSupport::bIsTransmissionSupported, bool >::type = true > static TSharedPtr CreateDataChannel(const FOperatorSettings& InOperatorSettings) { return MakeDataChannel(InOperatorSettings); } /** Create a transmission IDataChannel given a data type. * * This function is defined if a data type is not supported by the transmission system. * It returns null data channel. */ template< typename DataType, typename std::enable_if< !MetasoundTransmissionPrivate::TTransmissionSupport::bIsTransmissionSupported, bool >::type = true > static TSharedPtr CreateDataChannel(const FOperatorSettings& InOperatorSettings) { return TSharedPtr(nullptr); } }; }