Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | Protected Member Functions | List of all members
jau::InvocationFunc< R, A > Class Template Referenceabstract

One goal to produce the member-function type instance is to be class type agnostic for storing in the toolkit. More...

#include <function_def.hpp>

Inheritance diagram for jau::InvocationFunc< R, A >:
Collaboration diagram for jau::InvocationFunc< R, A >:

Public Member Functions

virtual ~InvocationFunc () noexcept
 
 InvocationFunc (const InvocationFunc &o) noexcept=default
 
 InvocationFunc (InvocationFunc &&o) noexcept=default
 
InvocationFuncoperator= (const InvocationFunc &o) noexcept=default
 
InvocationFuncoperator= (InvocationFunc &&o) noexcept=default
 
virtual int getType () const noexcept=0
 Poor man's RTTI. More...
 
virtual InvocationFunc< R, A... > * clone () const noexcept=0
 
virtual R invoke (A... args)=0
 
virtual bool operator== (const InvocationFunc< R, A... > &rhs) const noexcept=0
 
virtual bool operator!= (const InvocationFunc< R, A... > &rhs) const noexcept=0
 
virtual std::string toString () const =0
 

Protected Member Functions

 InvocationFunc () noexcept
 

Detailed Description

template<typename R, typename... A>
class jau::InvocationFunc< R, A >

One goal to produce the member-function type instance is to be class type agnostic for storing in the toolkit.

This is essential to utilize a function-callback API, where only the provider of an instance knows about its class type.

Further we can't utilize std::function and std::bind, as std::function doesn't provide details about the member-function-call identity and hence lacks of the equality operator and std::bind doesn't even specify a return type.

A capturing lambda in C++-11, does produce decoration code accessing the captured elements, i.e. an anonymous helper class. Due to this fact, the return type is an undefined lambda specific and hence we can't use it to feed the function invocation into ClassFunction<> using a well specified type.

 template<typename R, typename C, typename... A>
 inline ClassFunction<R, A...>
 bindClassFunction(C *base, R(C::*mfunc)(A...)) {
     return ClassFunction<R, A...>(
             (void*)base,
             (void*)(*((void**)&mfunc)),
             [&](A... args)->R{ (base->*mfunc)(args...); });
              ^
              | Capturing lambda function-pointer are undefined!
 }
 

Hence we need to manually produce the on-the-fly invocation data type to capture details on the caller's class type for the member-function-call, which are then being passed to the ClassFunction<> anonymously while still being able to perform certain operations like equality operation for identity.

Definition at line 78 of file function_def.hpp.

Constructor & Destructor Documentation

◆ InvocationFunc() [1/3]

template<typename R , typename... A>
jau::InvocationFunc< R, A >::InvocationFunc ( )
inlineprotectednoexcept

Definition at line 80 of file function_def.hpp.

◆ ~InvocationFunc()

template<typename R , typename... A>
virtual jau::InvocationFunc< R, A >::~InvocationFunc ( )
inlinevirtualnoexcept

Definition at line 83 of file function_def.hpp.

◆ InvocationFunc() [2/3]

template<typename R , typename... A>
jau::InvocationFunc< R, A >::InvocationFunc ( const InvocationFunc< R, A > &  o)
defaultnoexcept

◆ InvocationFunc() [3/3]

template<typename R , typename... A>
jau::InvocationFunc< R, A >::InvocationFunc ( InvocationFunc< R, A > &&  o)
defaultnoexcept

Member Function Documentation

◆ clone()

template<typename R , typename... A>
virtual InvocationFunc<R, A...>* jau::InvocationFunc< R, A >::clone ( ) const
pure virtualnoexcept
Here is the caller graph for this function:

◆ getType()

template<typename R , typename... A>
virtual int jau::InvocationFunc< R, A >::getType ( ) const
pure virtualnoexcept

Poor man's RTTI.

Here is the caller graph for this function:

◆ invoke()

template<typename R , typename... A>
virtual R jau::InvocationFunc< R, A >::invoke ( A...  args)
pure virtual

◆ operator!=()

template<typename R , typename... A>
virtual bool jau::InvocationFunc< R, A >::operator!= ( const InvocationFunc< R, A... > &  rhs) const
pure virtualnoexcept

◆ operator=() [1/2]

template<typename R , typename... A>
InvocationFunc& jau::InvocationFunc< R, A >::operator= ( const InvocationFunc< R, A > &  o)
defaultnoexcept

◆ operator=() [2/2]

template<typename R , typename... A>
InvocationFunc& jau::InvocationFunc< R, A >::operator= ( InvocationFunc< R, A > &&  o)
defaultnoexcept

◆ operator==()

template<typename R , typename... A>
virtual bool jau::InvocationFunc< R, A >::operator== ( const InvocationFunc< R, A... > &  rhs) const
pure virtualnoexcept

◆ toString()

template<typename R , typename... A>
virtual std::string jau::InvocationFunc< R, A >::toString ( ) const
pure virtual

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