Kouta
A small application framework based on Boost
kouta::base::callback::DirectCallback< TArgs > Class Template Reference

Direct Callback implementation. More...

#include <direct-callback.hpp>

Inheritance diagram for kouta::base::callback::DirectCallback< TArgs >:
Collaboration diagram for kouta::base::callback::DirectCallback< TArgs >:

Public Member Functions

 DirectCallback (const DirectCallback &)=default
 
DirectCallbackoperator= (const DirectCallback &)=default
 
 DirectCallback (DirectCallback &&)=default
 
DirectCallbackoperator= (DirectCallback &&)=default
 
 ~DirectCallback () override=default
 
template<class TClass >
 DirectCallback (TClass *object, void(TClass::*method)(TArgs...))
 Callback constructor from a bound method. More...
 
- Public Member Functions inherited from kouta::base::callback::BaseCallback< TArgs... >
 BaseCallback ()=default
 Default constructor. More...
 
 BaseCallback (const BaseCallback &)=default
 
 BaseCallback (BaseCallback &&)=default
 
BaseCallbackoperator= (const BaseCallback &)=default
 
BaseCallbackoperator= (BaseCallback &&)=default
 
virtual ~BaseCallback ()=default
 
void operator() (TArgs... args) const
 Invoke the underlying callable. More...
 

Additional Inherited Members

- Public Types inherited from kouta::base::callback::BaseCallback< TArgs... >
using Callable = std::function< void(TArgs...)>
 The type of the callable the Callback points to. More...
 
- Protected Member Functions inherited from kouta::base::callback::BaseCallback< TArgs... >
void set_callable (const Callable &callable)
 Set the callable. More...
 

Detailed Description

template<class... TArgs>
class kouta::base::callback::DirectCallback< TArgs >

Direct Callback implementation.

A direct Callback wraps a callable that is invoked within the caller's thread, making it no different to a direct invokation of a specific function or method.

The lifetime of the object the Callback points to must be guaranteed to surpass that of the Callback itself.

Template Parameters
TArgsCallable arguments.

Constructor & Destructor Documentation

◆ DirectCallback() [1/3]

template<class... TArgs>
kouta::base::callback::DirectCallback< TArgs >::DirectCallback ( const DirectCallback< TArgs > &  )
default

◆ DirectCallback() [2/3]

template<class... TArgs>
kouta::base::callback::DirectCallback< TArgs >::DirectCallback ( DirectCallback< TArgs > &&  )
default

◆ ~DirectCallback()

template<class... TArgs>
kouta::base::callback::DirectCallback< TArgs >::~DirectCallback ( )
overridedefault

◆ DirectCallback() [3/3]

template<class... TArgs>
template<class TClass >
kouta::base::callback::DirectCallback< TArgs >::DirectCallback ( TClass *  object,
void(TClass::*)(TArgs...)  method 
)
inline

Callback constructor from a bound method.

This constructor initializes the internal callable with a pointer to the specified bound method. The developer must guarantee the lifetime of the object to prevent invalid memory access.

Template Parameters
TClassObject type.
Parameters
[in]objectPointer to the object whose method is going to be called.
[in]methodPointer to the method that is going to be called. The arguments of the Callback must match those of this method.

Member Function Documentation

◆ operator=() [1/2]

template<class... TArgs>
DirectCallback& kouta::base::callback::DirectCallback< TArgs >::operator= ( const DirectCallback< TArgs > &  )
default

◆ operator=() [2/2]

template<class... TArgs>
DirectCallback& kouta::base::callback::DirectCallback< TArgs >::operator= ( DirectCallback< TArgs > &&  )
default

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