VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::Callback< Callable, Enable, Args > Class Template Reference

Generic callback. More...

#include <callback.h>

Inheritance diagram for ugcs::vsm::Callback< Callable, Enable, Args >:
ugcs::vsm::Callback_base< std::result_of< Callable(Args...)>::type >

Public Types

typedef Callback_base< typename std::result_of< Callable(Args...)>::type > Base_type
 Base class type. More...
 
typedef Base_type::template Ptr< CallbackPtr
 Callable pointer class type. More...
 
template<size_t arg_idx>
using Arg_type = typename std::tuple_element< arg_idx, Args_tuple >::type
 Get type of the specified argument. More...
 
- Public Types inherited from ugcs::vsm::Callback_base< std::result_of< Callable(Args...)>::type >
typedef std::result_of< Callable(Args...)>::type Result_t
 Result type. More...
 

Public Member Functions

 Callback (Callable &&callable, Args &&...args)
 Construct callback instance. More...
 
 Callback (Callback &&)=default
 Move constructor. More...
 
virtual Base_type::Result_t operator() () override
 Execute callback. More...
 
template<size_t arg_idx>
Arg_type< arg_idx > & Get_arg ()
 Get reference to an argument at the specified position. More...
 

Static Public Member Functions

static Ptr Create (Callable &&callable, Args &&...args)
 Create callback instance. More...
 

Protected Member Functions

template<int... s>
Base_type::Result_t Invoke (callback_internal::Sequence< s... >)
 Invoke callable entity with user provided arguments. More...
 

Protected Attributes

callback_internal::Adapt_callable_type< Callable >::type callable
 Callable entity from user. More...
 
Args_tuple args
 User provided arguments pack. More...
 

Detailed Description

template<class Callable, class Enable, typename... Args>
class ugcs::vsm::Callback< Callable, Enable, Args >

Generic callback.

Use Make_callback for convenient instantiation. Generic template version for any callable object.

Parameters
CallableAny callable object type (function, lambda, class with overloaded call operator etc.).
EnableDummy template argument for conditional specialization.
ArgsArguments pack.
See also
Make_callback

Member Typedef Documentation

template<class Callable , class Enable , typename... Args>
template<size_t arg_idx>
using ugcs::vsm::Callback< Callable, Enable, Args >::Arg_type = typename std::tuple_element<arg_idx, Args_tuple>::type

Get type of the specified argument.

Parameters
arg_idxIndex of the argument. Should be in range [0, sizeof...(Args)).
template<class Callable , class Enable , typename... Args>
typedef Callback_base<typename std::result_of<Callable(Args...)>::type> ugcs::vsm::Callback< Callable, Enable, Args >::Base_type

Base class type.

template<class Callable , class Enable , typename... Args>
typedef Base_type::template Ptr<Callback> ugcs::vsm::Callback< Callable, Enable, Args >::Ptr

Callable pointer class type.

Constructor & Destructor Documentation

template<class Callable , class Enable , typename... Args>
ugcs::vsm::Callback< Callable, Enable, Args >::Callback ( Callable &&  callable,
Args &&...  args 
)
inline

Construct callback instance.

Parameters
callableCallable entity instance.
argsUser defined arguments pack.
template<class Callable , class Enable , typename... Args>
ugcs::vsm::Callback< Callable, Enable, Args >::Callback ( Callback< Callable, Enable, Args > &&  )
default

Move constructor.

Member Function Documentation

template<class Callable , class Enable , typename... Args>
static Ptr ugcs::vsm::Callback< Callable, Enable, Args >::Create ( Callable &&  callable,
Args &&...  args 
)
inlinestatic

Create callback instance.

template<class Callable , class Enable , typename... Args>
template<size_t arg_idx>
Arg_type<arg_idx>& ugcs::vsm::Callback< Callable, Enable, Args >::Get_arg ( )
inline

Get reference to an argument at the specified position.

Template parameters:

  • arg_idx Index of the argument to get.
    Returns
    Reference to the stored argument.
template<class Callable , class Enable , typename... Args>
template<int... s>
Base_type::Result_t ugcs::vsm::Callback< Callable, Enable, Args >::Invoke ( callback_internal::Sequence< s... >  )
inlineprotected

Invoke callable entity with user provided arguments.

template<class Callable , class Enable , typename... Args>
virtual Base_type::Result_t ugcs::vsm::Callback< Callable, Enable, Args >::operator() ( )
inlineoverridevirtual

Member Data Documentation

template<class Callable , class Enable , typename... Args>
Args_tuple ugcs::vsm::Callback< Callable, Enable, Args >::args
protected

User provided arguments pack.

template<class Callable , class Enable , typename... Args>
callback_internal::Adapt_callable_type<Callable>::type ugcs::vsm::Callback< Callable, Enable, Args >::callable
protected

Callable entity from user.


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