template class ugcs::vsm::Callback<Method, typename std::enable_if<callback_internal::Is_method_ptr<Method>()>::type, Class_ptr, Args…>

Overview

Generic callback which uses bound class method as callable. More…

#include <callback.h>

template <class Method, class Class_ptr, typename... Args>
class Callback<Method, typename std::enable_if<callback_internal::Is_method_ptr<Method>()>::type, Class_ptr, Args...>: public ugcs::vsm::Callback_base
{
public:
    // typedefs

    typedef Callback_base<typename std::result_of<Method(Class_ptr, 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(Method method, Class_ptr&& obj_ptr, Args&&... args);
    Callback(Callback&&);

    // methods

    static Ptr Create(Method method, Class_ptr&& obj_ptr, 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 which uses bound class method as callable.

Use Make_callback for convenient instantiation. Specialized template version for class member function.

Parameters:

Class_ptr

Pointer to class object (used with pointer semantic, can be any smart pointer as well).

Class

method to call.

Args

Arguments pack.

See also:

Make_callback

Typedefs

typedef Callback_base<typename std::result_of<Method(Class_ptr, 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(Method method, Class_ptr&& obj_ptr, Args&&... args)

Constructor for class method bound callback.

Callback(Callback&&)

Move constructor.

Methods

static Ptr Create(Method method, Class_ptr&& obj_ptr, 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.