OSVR-Core
Public Types | Public Member Functions | List of all members
osvr::common::DeduplicatingFunctionWrapper< ArgumentType, StorageType > Class Template Reference

A wrapper for a unary function that only calls its contained function when the input has changed. More...

#include <DeduplicatingFunctionWrapper.h>

Public Types

using argument_type = ArgumentType
 Argument type: always must be supplied via template parameter.
 
using storage_type = typename std::conditional< std::is_same< StorageType, void >::value, typename std::remove_const< typename std::remove_reference< ArgumentType >::type >::type, StorageType >::type
 Storage type: if not supplied via template parameter, inferred by removing const& from the argument type. More...
 
typedef void return_type
 Return type - presently fixed.
 
typedef std::function< return_type(argument_type)> function_type
 std::function type corresponding to what is being wrapped.
 

Public Member Functions

 DeduplicatingFunctionWrapper (function_type const &f)
 Constructor from a function.
 
 DeduplicatingFunctionWrapper ()
 Default constructor - must have function set before calling.
 
void setFunction (function_type const &f)
 Set/replace the function.
 
return_type operator() (argument_type arg,...)
 Function call operator: passes call along to contained function if and only if (argument != last argument) or (first time being called) More...
 

Detailed Description

template<typename ArgumentType, typename StorageType = void>
class osvr::common::DeduplicatingFunctionWrapper< ArgumentType, StorageType >

A wrapper for a unary function that only calls its contained function when the input has changed.

Member Typedef Documentation

§ storage_type

template<typename ArgumentType , typename StorageType = void>
using osvr::common::DeduplicatingFunctionWrapper< ArgumentType, StorageType >::storage_type = typename std::conditional< std::is_same<StorageType, void>::value, typename std::remove_const< typename std::remove_reference<ArgumentType>::type>::type, StorageType>::type

Storage type: if not supplied via template parameter, inferred by removing const& from the argument type.

Member Function Documentation

§ operator()()

template<typename ArgumentType , typename StorageType = void>
return_type osvr::common::DeduplicatingFunctionWrapper< ArgumentType, StorageType >::operator() ( argument_type  arg,
  ... 
)
inline

Function call operator: passes call along to contained function if and only if (argument != last argument) or (first time being called)

Takes and throws away extra arguments so you don't have to wrap it in std::bind to get flexible calling ability.


The documentation for this class was generated from the following file: