Brunot
Loading...
Searching...
No Matches
th::MemberFunction< returnType, parameter > Class Template Reference

#include <MemberFunction.h>

Collaboration diagram for th::MemberFunction< returnType, parameter >:
[legend]

Public Member Functions

 MemberFunction ()=delete
 MemberFunction (std::function< returnType(parameter...)> function, std::string nameOfFunction, GameObject *funcOwner)
 Creates a MemberFunction from a given std::function, a name, and an owner
NOTE: The std::function return type and parameters should match that of the Member Function
NOTE: The std::function should be bound (std::bind_front) to the object instance before being passed in
Example Call:
std::function<void(const Message&)> functionToCall = std::bind_front(functionToLink, pointerToSelf);
th::MemberFunction<void, const Message&> connectedFunction{functionToCall, functionName, pointerToSelf};.
auto operator== (const MemberFunction &rhs) const -> bool
auto operator() (parameter... inputParameter) -> returnType
 Call the function associated with a Member Function.
auto hasValidOwner () const -> bool
 Checks if the owner of the member function still exists.
auto function_owner () const -> GameObject *
auto function_name () const -> const std::string &

Private Attributes

std::function< returnType(parameter...)> actualFunction
std::string functionName
GameObjectfunctionOwner

Constructor & Destructor Documentation

◆ MemberFunction() [1/2]

template<typename returnType, typename... parameter>
th::MemberFunction< returnType, parameter >::MemberFunction ( )
delete
Here is the caller graph for this function:

◆ MemberFunction() [2/2]

template<typename returnType, typename... parameter>
th::MemberFunction< returnType, parameter >::MemberFunction ( std::function< returnType(parameter...)> function,
std::string nameOfFunction,
GameObject * funcOwner )
inline

Creates a MemberFunction from a given std::function, a name, and an owner
NOTE: The std::function return type and parameters should match that of the Member Function
NOTE: The std::function should be bound (std::bind_front) to the object instance before being passed in
Example Call:
std::function<void(const Message&)> functionToCall = std::bind_front(functionToLink, pointerToSelf);
th::MemberFunction<void, const Message&> connectedFunction{functionToCall, functionName, pointerToSelf};.

Parameters
functionThe actual function that you want to be called
nameOfFunctionThe name of the function. Should always match the actual name in the class
funcOwnerThe object that the function belongs to

Member Function Documentation

◆ function_name()

template<typename returnType, typename... parameter>
auto th::MemberFunction< returnType, parameter >::function_name ( ) const->conststd::string &
inlinenodiscard

◆ function_owner()

template<typename returnType, typename... parameter>
auto th::MemberFunction< returnType, parameter >::function_owner ( ) const->GameObject *
inlinenodiscard

◆ hasValidOwner()

template<typename returnType, typename... parameter>
auto th::MemberFunction< returnType, parameter >::hasValidOwner ( ) const->bool
inline

Checks if the owner of the member function still exists.

Returns
TRUE if the owner has not been destroyed, FALSE otherwise
Here is the caller graph for this function:

◆ operator()()

template<typename returnType, typename... parameter>
auto th::MemberFunction< returnType, parameter >::operator() ( parameter... inputParameter) ->returnType
inline

Call the function associated with a Member Function.

Parameters
inputParameterThe parameter to pass into the function
Returns
Whatever the function normally returns

◆ operator==()

template<typename returnType, typename... parameter>
auto th::MemberFunction< returnType, parameter >::operator== ( const MemberFunction< returnType, parameter > & rhs) const->bool
inline
Parameters
rhsThe Member Function you want to compare against
Returns
TRUE if the other function has the same function name and owner, FALSE otherwise
Here is the call graph for this function:

Member Data Documentation

◆ actualFunction

template<typename returnType, typename... parameter>
std::function<returnType(parameter...)> th::MemberFunction< returnType, parameter >::actualFunction
private

◆ functionName

template<typename returnType, typename... parameter>
std::string th::MemberFunction< returnType, parameter >::functionName
private

◆ functionOwner

template<typename returnType, typename... parameter>
GameObject* th::MemberFunction< returnType, parameter >::functionOwner
private

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