template class ugcs::vsm::Callback¶
Overview¶
Generic callback. More…
#include <callback.h> template <class Callable, class Enable, typename... Args> class Callback: public ugcs::vsm::Callback_base { public: // typedefs typedef Callback_base<typename std::result_of<Callable(Args...)>::type> Base_type; typedef typename Base_type::template Ptr<Callback> Ptr; typedef typename std::tuple_element<arg_idx, Args_tuple>::type Arg_type; // construction Callback(Callable&& callable, Args&&... args); Callback(Callback&&); // methods static Ptr Create(Callable&& callable, Args&&... args); virtual Base_type::Result_t operator () (); template <size_t arg_idx> Arg_type<arg_idx>& Get_arg(); };
Inherited Members¶
public: // typedefs typedef Result Result_t; // classes template <class Callback = Callback_base> class Ptr; // methods virtual Result_t operator () () = 0;
Detailed Documentation¶
Generic callback.
Use Make_callback for convenient instantiation. Generic template version for any callable object.
Parameters:
Callable |
Any callable object type (function, lambda, class with overloaded call operator etc.). |
Enable |
Dummy template argument for conditional specialization. |
Args |
Arguments pack. |
See also:
Typedefs¶
typedef Callback_base<typename std::result_of<Callable(Args...)>::type> Base_type
Base class type.
typedef typename Base_type::template Ptr<Callback> Ptr
Callable pointer class type.
typedef typename std::tuple_element<arg_idx, Args_tuple>::type Arg_type
Get type of the specified argument.
Parameters:
arg_idx |
Index of the argument. Should be in range [0, sizeof…(Args)). |
Construction¶
Callback(Callable&& callable, Args&&... args)
Construct callback instance.
Parameters:
callable |
Callable entity instance. |
args |
User defined arguments pack. |
Callback(Callback&&)
Move constructor.
Methods¶
static Ptr Create(Callable&& callable, Args&&... args)
Create callback instance.
virtual Base_type::Result_t operator () ()
Execute callback.
template <size_t arg_idx> Arg_type<arg_idx>& Get_arg()
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.