Skip to content
Snippets Groups Projects
Select Git revision
  • feature/QuadBufferPostprocessing
  • master default protected
  • feature/ita
  • develop protected
  • feature/IMAGES_WITH_OPENVR
  • feature/IMAGES_AND_VIEWPORTS
  • feature/UPDATE_LEAP_DRIVER_TO_SDK_V3
  • feature/volume_raycaster_bindless
  • feature/IntegrateNewOculusSDK
  • feature/SimpleOpenGLDraw
  • feature/LeapMotionMeasureNameFix
  • feature/observeable_sequenced_notifications
  • feature/BoundingBoxIntentionSelect
  • feature/RenamedVistaTexture
  • feature/conan_io_support
  • release/1.16 protected
  • release/1.15 protected
  • feature/REMOVE_PLUGIN_DLL
  • feature/COH_GRP_TRUNK_INTEGRATE
  • release/1.14 protected
  • 1.16.0
  • Before_OGLExt_CoreLibs_Integration
  • 1.14.0
  • 1.15.0
  • 1.11.0
  • 1.12.0
  • 1.13
  • 1.13.0
  • 1.10.1
  • 1.10.0
30 results

changelog.md

Blame
  • To find the state of this project's repository at the time of any of these versions, check out the tags.
    DisplayClusterEventParameterHelper.h 2.81 KiB
    #pragma once
    
    #include "Serialization/MemoryReader.h"
    #include "Serialization/MemoryWriter.h"
    #include "type_traits"
    
    template <typename ParameterType, typename... RemainingParameterTypes>
    inline void SerializeParameters(FMemoryWriter* MemoryWriter, ParameterType&& Parameter,
                                    RemainingParameterTypes&&... RemainingParameters)
    {
    	using NonConstType = typename std::remove_cv_t<typename TRemoveReference<ParameterType>::Type>;
    	// const_cast because the same operator (<<) is used for reading and writing
    	(*MemoryWriter) << const_cast<NonConstType&>(Parameter);
    	SerializeParameters(MemoryWriter, Forward<RemainingParameterTypes>(RemainingParameters)...);
    }
    
    inline void SerializeParameters(FMemoryWriter* MemoryWriter)
    {
    }
    
    // This is a wrapper function to recursively fill the argument tuple. This overload is only used if the index indicating the
    // currently handled attribute is less than the number of total attributes. I.e., if the attribute index is valid.
    template <int CurrentIndex, typename... ArgTypes>
    inline typename TEnableIf<(CurrentIndex < sizeof...(ArgTypes))>::Type
    FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTuple)
    {
    	// Read the "<<" as ">>" operator here. FArchive uses the same for both and decides based on an internal type on what to do. So
    	// this statement parses the bytes that were passed into reader and puts the parsed object into the tuple at index CurrentIndex.
    	(*MemoryReader) << ArgumentTuple->template Get<CurrentIndex>();
    
    	// Recursive call for the remaining attributes.
    	FillArgumentTuple<CurrentIndex + 1>(MemoryReader, Forward<TTuple<ArgTypes...>*>(ArgumentTuple));
    }
    
    // The overload that is called if we are "passed the end" of attributes.
    template <int CurrentIndex, typename... ArgTypes>
    inline typename TEnableIf<(CurrentIndex >= sizeof...(ArgTypes))>::Type
    FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTuple)
    {
    }
    
    template <typename RetType, typename... ArgTypes>
    inline RetType CallDelegateWithParameterMap(
    	const TDelegate<RetType, ArgTypes...>& Delegate, const TMap<FString, FString>& Parameters)
    {
    	// Create a tuple that holds all arguments. This assumes that all argument types are default constructible. However, all
    	// types that overload the FArchive "<<" operator probably are.
    	TTuple<typename std::remove_cv_t<typename TRemoveReference<ArgTypes>::Type>::Type...> ArgumentTuple;
    
    	// This call will parse the string map and fill all values in the tuple appropriately.
    	FillArgumentTuple<0>(&ArgumentTuple, Parameters);
    
    	// The lambda function is only necessary because delegates do not overload the ()-operator but use the Execute() method
    	// instead. So, the lambda acts as a wrapper.
    	return ArgumentTuple.ApplyBefore([Delegate](ArgTypes&&... Arguments)
    	{
    		Delegate.Execute(Forward<ArgTypes>(Arguments)...);
    	});
    }