25 #ifndef INCLUDED_DeduplicatingFunctionWrapper_h_GUID_56CC2963_C33D_4FAA_34AB_4562516FE97B 26 #define INCLUDED_DeduplicatingFunctionWrapper_h_GUID_56CC2963_C33D_4FAA_34AB_4562516FE97B 36 #include <type_traits> 43 template <
typename ArgumentType,
typename StorageType =
void>
52 std::is_same<StorageType, void>::value,
53 typename std::remove_const<
54 typename std::remove_reference<ArgumentType>::type>::type,
65 : m_func(f), m_beenCalled(false) {}
81 throw std::logic_error(
"Must set the function in " 82 "DeduplicatingFunctionWrapper before " 94 return m_defaultReturn();
100 static return_type m_defaultReturn() {
return return_type(); }
110 function_type m_func;
121 #endif // INCLUDED_DeduplicatingFunctionWrapper_h_GUID_56CC2963_C33D_4FAA_34AB_4562516FE97B Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
return_type operator()(argument_type arg,...)
Function call operator: passes call along to contained function if and only if (argument != last argu...
Definition: DeduplicatingFunctionWrapper.h:79
ArgumentType argument_type
Argument type: always must be supplied via template parameter.
Definition: DeduplicatingFunctionWrapper.h:47
void return_type
Return type - presently fixed.
Definition: DeduplicatingFunctionWrapper.h:58
DeduplicatingFunctionWrapper()
Default constructor - must have function set before calling.
Definition: DeduplicatingFunctionWrapper.h:68
std::function< return_type(argument_type)> function_type
std::function type corresponding to what is being wrapped.
Definition: DeduplicatingFunctionWrapper.h:61
void setFunction(function_type const &f)
Set/replace the function.
Definition: DeduplicatingFunctionWrapper.h:71
DeduplicatingFunctionWrapper(function_type const &f)
Constructor from a function.
Definition: DeduplicatingFunctionWrapper.h:64
typename std::conditional< std::is_same< StorageType, void >::value, typename std::remove_const< typename std::remove_reference< ArgumentType >::type >::type, StorageType >::type storage_type
Storage type: if not supplied via template parameter, inferred by removing const& from the argument t...
Definition: DeduplicatingFunctionWrapper.h:55
A wrapper for a unary function that only calls its contained function when the input has changed...
Definition: DeduplicatingFunctionWrapper.h:44