VSM C++ SDK
Vehicle Specific Modules SDK
ugcs::vsm::Callback_proxy< Result, Args > Class Template Reference

Helper class for proxying callback invocation. More...

#include <callback.h>

Classes

class  Hasher
 Callback proxy hasher based on referenced callback. More...
 

Public Types

typedef Callback_base< Result > Callback_type
 Base type of the underlying callback object. More...
 
typedef Callback_type::template Ptr Callback_ptr
 Pointer to the underlying callback object. More...
 
template<size_t arg_idx>
using Arg_ref_type = typename std::tuple_element< arg_idx, Args_ref_tuple >::type
 Creates reference type to the argument with index arg_idx. More...
 
template<size_t arg_idx>
using Arg_ptr_type = typename std::tuple_element< arg_idx, Args_ptr_tuple >::type
 Creates pointer type to the argument with index arg_idx. More...
 

Public Member Functions

 Callback_proxy ()=default
 Default constructor creates unbound instance. More...
 
template<class Callback_ptr >
 Callback_proxy (Callback_ptr cbk)
 Constructs instance bound to the provided callback object. More...
 
template<typename... Invoke_args>
void Set_args (Invoke_args &&...invoke_args) const
 Set arguments values for callback invocation. More...
 
template<typename... Invoke_args>
Result operator() (Invoke_args &&...invoke_args) const
 Invoke the callback with the specified first arguments. More...
 
Result Invoke () const
 Invoke the callback with the previously set argument values. More...
 
Callback_ptr Get_callback ()
 Get the associated callback. More...
 
 operator bool () const
 Check if the proxy object is bound to some callback object. More...
 
 operator Callback_ptr ()
 Support implicit cast to callback base class. More...
 
template<size_t arg_idx>
Arg_ref_type< arg_idx > Get_arg ()
 Get reference to an argument at the specified position. More...
 
template<size_t arg_idx, typename Arg_type >
void Set_arg (Arg_type &&arg)
 Set argument value at the specified position. More...
 
bool operator== (const Callback_proxy &other) const
 Equality operator. More...
 
bool operator!= (const Callback_proxy &other) const
 Non-equality operator. More...
 

Detailed Description

template<class Result, typename... Args>
class ugcs::vsm::Callback_proxy< Result, Args >

Helper class for proxying callback invocation.

It is aware of specified number of first arguments to the target callback.

Parameters
ResultType of the callback invocation result.
ArgsType of the first arguments.
Examples:
async_workflow.cpp.

Member Typedef Documentation

template<class Result, typename... Args>
template<size_t arg_idx>
using ugcs::vsm::Callback_proxy< Result, Args >::Arg_ptr_type = typename std::tuple_element<arg_idx, Args_ptr_tuple>::type

Creates pointer type to the argument with index arg_idx.

template<class Result, typename... Args>
template<size_t arg_idx>
using ugcs::vsm::Callback_proxy< Result, Args >::Arg_ref_type = typename std::tuple_element<arg_idx, Args_ref_tuple>::type

Creates reference type to the argument with index arg_idx.

template<class Result, typename... Args>
typedef Callback_type::template Ptr ugcs::vsm::Callback_proxy< Result, Args >::Callback_ptr

Pointer to the underlying callback object.

template<class Result, typename... Args>
typedef Callback_base<Result> ugcs::vsm::Callback_proxy< Result, Args >::Callback_type

Base type of the underlying callback object.

Constructor & Destructor Documentation

template<class Result, typename... Args>
ugcs::vsm::Callback_proxy< Result, Args >::Callback_proxy ( )
default

Default constructor creates unbound instance.

template<class Result, typename... Args>
template<class Callback_ptr >
ugcs::vsm::Callback_proxy< Result, Args >::Callback_proxy ( Callback_ptr  cbk)
inline

Constructs instance bound to the provided callback object.

Member Function Documentation

template<class Result, typename... Args>
template<size_t arg_idx>
Arg_ref_type<arg_idx> ugcs::vsm::Callback_proxy< Result, 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 Result, typename... Args>
Callback_ptr ugcs::vsm::Callback_proxy< Result, Args >::Get_callback ( )
inline

Get the associated callback.

template<class Result, typename... Args>
Result ugcs::vsm::Callback_proxy< Result, Args >::Invoke ( ) const
inline

Invoke the callback with the previously set argument values.

template<class Result, typename... Args>
ugcs::vsm::Callback_proxy< Result, Args >::operator bool ( ) const
inlineexplicit

Check if the proxy object is bound to some callback object.

template<class Result, typename... Args>
ugcs::vsm::Callback_proxy< Result, Args >::operator Callback_ptr ( )
inline

Support implicit cast to callback base class.

template<class Result, typename... Args>
bool ugcs::vsm::Callback_proxy< Result, Args >::operator!= ( const Callback_proxy< Result, Args > &  other) const
inline

Non-equality operator.

Proxies pointing to the different callbacks are considered different.

template<class Result, typename... Args>
template<typename... Invoke_args>
Result ugcs::vsm::Callback_proxy< Result, Args >::operator() ( Invoke_args &&...  invoke_args) const
inline

Invoke the callback with the specified first arguments.

template<class Result, typename... Args>
bool ugcs::vsm::Callback_proxy< Result, Args >::operator== ( const Callback_proxy< Result, Args > &  other) const
inline

Equality operator.

Proxies pointing to the same callback are considered the same.

template<class Result, typename... Args>
template<size_t arg_idx, typename Arg_type >
void ugcs::vsm::Callback_proxy< Result, Args >::Set_arg ( Arg_type &&  arg)
inline

Set argument value at the specified position.

Template parameters:

  • arg_idx Argument position.
    Parameters
    argArgument value.
template<class Result, typename... Args>
template<typename... Invoke_args>
void ugcs::vsm::Callback_proxy< Result, Args >::Set_args ( Invoke_args &&...  invoke_args) const
inline

Set arguments values for callback invocation.


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