Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::TClosure< Result, Args > Class Template Reference

Encapsulates the std::function() template. More...

#include <TClosure.h>

Public Types

typedef std::function< Result(Args...)> func_type
 Function type of the lambda or function.
 

Public Member Functions

 TClosure ()=default
 Default constructor.
 
 TClosure (const TClosure &c)
 Copy constructor.
 
 TClosure (const func_type &fn)
 Function assignment constructor.
 
TClosureassign (const func_type &fn)
 Function assignment method for static function.
 
template<typename ClassType , typename MethodType , typename... BoundArgs>
TClosureassign (ClassType *cls, MethodType mtd, BoundArgs... args)
 Binds a non-static class member function to this instance.
 
TClosureunassign ()
 Function assignment member.
 
TClosureoperator= (const TClosure &c)
 Closure assignment operator.
 
TClosureoperator= (const func_type &f)
 Closure assignment operator.
 
Result operator() (Args... args) const
 Make the call to the member function.
 
bool isAssigned () const
 Checks if the closure is valid for calling.
 
 operator bool () const
 Checks if the closure is valid for calling.
 

Protected Member Functions

Result call (Args... args) const
 Makes the call to the member function.
 

Detailed Description

template<typename Result, typename... Args>
class sf::TClosure< Result, Args >

Encapsulates the std::function() template.

Template Parameters
ResultReturn type of the function.
ArgsVariable amount of function arguments.

Member Typedef Documentation

◆ func_type

template<typename Result , typename... Args>
typedef std::function<Result(Args...)> sf::TClosure< Result, Args >::func_type

Function type of the lambda or function.

Constructor & Destructor Documentation

◆ TClosure() [1/3]

template<typename Result , typename... Args>
sf::TClosure< Result, Args >::TClosure ( )
default

Default constructor.

◆ TClosure() [2/3]

template<typename Result , typename... Args>
sf::TClosure< Result, Args >::TClosure ( const TClosure< Result, Args > &  c)
inline

Copy constructor.

◆ TClosure() [3/3]

template<typename Result , typename... Args>
sf::TClosure< Result, Args >::TClosure ( const func_type fn)
inlineexplicit

Function assignment constructor.

Member Function Documentation

◆ assign() [1/2]

template<typename Result , typename... Args>
template<typename ClassType , typename MethodType , typename... BoundArgs>
TClosure & sf::TClosure< Result, Args >::assign ( ClassType *  cls,
MethodType  mtd,
BoundArgs...  args 
)
inline

Binds a non-static class member function to this instance.

Short for passing a std::bind(...) result the assign().
For example:

bool MyClass::method(const char* s, int i);
c2.assign(&MyClass::method, this, std::placeholders::_1, std::placeholders::_2)
Encapsulates the std::function() template.
Definition TClosure.h:17
TClosure & assign(const func_type &fn)
Function assignment method for static function.
Definition TClosure.h:47
Template Parameters
ClassTypeType having the to be called method.
MethodTypeType from the passed class type.
BoundArgsOnly std::placeholders::_? enumeration values. (see std::bind)
Parameters
clsPointer of the class having the passed method.
mtdPointer to method of the given class.
argsAmount of arguments needed to call the method using std::placeholders::_? enumeration values.
Returns
Itself.

◆ assign() [2/2]

template<typename Result , typename... Args>
TClosure & sf::TClosure< Result, Args >::assign ( const func_type fn)
inline

Function assignment method for static function.

◆ call()

template<typename Result , typename... Args>
Result sf::TClosure< Result, Args >::call ( Args...  args) const
protected

Makes the call to the member function.

Parameters
argsList of arguments specified by the template.
Returns
Result type

◆ isAssigned()

template<typename Result , typename... Args>
bool sf::TClosure< Result, Args >::isAssigned ( ) const
inline

Checks if the closure is valid for calling.

◆ operator bool()

template<typename Result , typename... Args>
sf::TClosure< Result, Args >::operator bool ( ) const
inlineexplicit

Checks if the closure is valid for calling.

◆ operator()()

template<typename Result , typename... Args>
Result sf::TClosure< Result, Args >::operator() ( Args...  args) const
inline

Make the call to the member function.

Parameters
argsList of arguments specified by the template.
Returns
Result type

◆ operator=() [1/2]

template<typename Result , typename... Args>
TClosure & sf::TClosure< Result, Args >::operator= ( const func_type f)
inline

Closure assignment operator.

◆ operator=() [2/2]

template<typename Result , typename... Args>
TClosure & sf::TClosure< Result, Args >::operator= ( const TClosure< Result, Args > &  c)
inline

Closure assignment operator.

◆ unassign()

template<typename Result , typename... Args>
TClosure & sf::TClosure< Result, Args >::unassign ( )
inline

Function assignment member.


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