EasyDelegate  2.0
Delegate and deferred callers for C++11.
Public Types | Public Member Functions | Public Attributes | List of all members
EasyDelegate::MemberDelegate< classType, returnType, parameters > Class Template Reference

A delegate of a class member method. More...

#include <delegates.hpp>

Inheritance diagram for EasyDelegate::MemberDelegate< classType, returnType, parameters >:
EasyDelegate::ITypedDelegate< returnType, parameters...> EasyDelegate::IDelegate

Public Types

typedef MemberMethodPointer< classType, returnType, parameters...> MethodPointer
 Helper typedef referring to a static function pointer that is compatible with this delegate.
 
- Public Types inherited from EasyDelegate::ITypedDelegate< returnType, parameters...>
typedef returnType ReturnType
 Helper typedef referring to the return type of this delegate.
 
typedef StaticDelegate< returnType, parameters...> StaticDelegateType
 Helper typedef for when building static delegates.
 
using MemberDelegateType = MemberDelegate< classType, returnType, parameters...>
 Helper typedef for when building member delegates.
 
typedef StaticMethodPointer< returnType, parameters...> StaticMethodPointerType
 Helper typedef referring to a static function pointer.
 
using MemberDelegateFuncPtr = returnType(classType::*)(parameters...)
 Helper typedef referring to a class member method pointer.
 

Public Member Functions

 MemberDelegate (const MethodPointer methodPointer, classType *thisPointer)
 Constructor accepting a this pointer and a member function. More...
 
 MemberDelegate (const MemberDelegate< classType, returnType, parameters...> *other)
 Standard copy constructor. More...
 
returnType invoke (parameters...params)
 Invoke the MemberDelegate. More...
 
EASYDELEGATE_INLINE bool hasThisPointer (const void *thisPointer) const noexcept
 Returns whether or not this MemberDelegate calls against the given this pointer. More...
 
EASYDELEGATE_INLINE bool callsMethod (const MethodPointer methodPointer) const noexcept
 Returns whether or not this MemberDelegate calls the given class member method pointer. More...
 
template<typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool callsMethod (const StaticMethodPointer< otherReturn, otherParams...> methodPointer) const noexcept
 Returns whether or not this MemberDelegate calls the given static method pointer. More...
 
EASYDELEGATE_INLINE bool callsMethod (const typename ITypedDelegate< returnType, parameters...>::StaticMethodPointerType methodPointer) const noexcept
 Returns whether or not this MemeberDelegate calls the given static method address. More...
 
EASYDELEGATE_INLINE bool hasSameMethodAs (const MemberDelegate< classType, returnType, parameters...> *other) const noexcept
 Returns whether or not this MemberDelegate calls the same method as the other MemberDelegate. More...
 
template<typename otherClass , typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool hasSameMethodAs (const MemberDelegate< otherClass, otherReturn, otherParams...> *other) const noexcept
 Returns whether or not this MemberDelegate calls the same method as the other of a deferring signature. More...
 
template<typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool hasSameMethodAs (const StaticDelegate< otherReturn, otherParams...> *other) const noexcept
 Returns whether or not this MemberDelegate calls the same method as the StaticDelegate type. More...
 
template<typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool hasSameThisPointerAs (const StaticDelegate< otherReturn, otherParams...> *other) const noexcept
 Returns whether or not this MemberDelegate calls against the same this pointer as the StaticDelegate. More...
 
template<typename otherClass , typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool hasSameThisPointerAs (const MemberDelegate< otherClass, otherReturn, otherParams...> *other) const noexcept
 Returns whether or not this MemberDelegate calls against the same this pointer as the other. More...
 
- Public Member Functions inherited from EasyDelegate::ITypedDelegate< returnType, parameters...>
 ITypedDelegate (const bool &isMemberDelegate) noexcept
 Constructor accepting a boolean. More...
 
virtual bool callsMethod (const StaticMethodPointerType methodPointer) const noexcept=0
 Returns whether or not this delegate calls the given static method. More...
 
bool callsMethod (const MemberDelegateFuncPtr< className > methodPointer) const noexcept
 Returns whether or not this delegate calls the given class member method address. More...
 

Public Attributes

classType * mThisPointer
 A pointer to the this object.
 
- Public Attributes inherited from EasyDelegate::IDelegate
const bool mIsMemberDelegate
 A boolean representing whether or not this delegate is a member delegate.
 

Additional Inherited Members

- Protected Member Functions inherited from EasyDelegate::IDelegate
 IDelegate (const bool &isMemberDelegate) noexcept
 Constructor accepting a boolean. More...
 

Detailed Description

template<typename classType, typename returnType, typename... parameters>
class EasyDelegate::MemberDelegate< classType, returnType, parameters >

A delegate of a class member method.

The MemberDelegate behaves exactly like the StaticDelegate type except it works against class member methods.

Constructor & Destructor Documentation

template<typename classType, typename returnType, typename... parameters>
EasyDelegate::MemberDelegate< classType, returnType, parameters >::MemberDelegate ( const MethodPointer  methodPointer,
classType *  thisPointer 
)
inline

Constructor accepting a this pointer and a member function.

Parameters
thisPointerA pointer to the object instance to be considered 'this' during invocation.
methodPointerA pointer to the member function to be invoked upon the this pointer.
Warning
The MemberDelegate invocation code has no way of knowing if the 'this' pointer at any time has been deallocated. The MemberDelegate will cause undefined behavior and/or segfault upon invocation in that case.
template<typename classType, typename returnType, typename... parameters>
EasyDelegate::MemberDelegate< classType, returnType, parameters >::MemberDelegate ( const MemberDelegate< classType, returnType, parameters...> *  other)
inline

Standard copy constructor.

Parameters
otherThe other MemberDelegate pointer with the same signature to copy from.

Member Function Documentation

template<typename classType, typename returnType, typename... parameters>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::callsMethod ( const MethodPointer  methodPointer) const
inlinenoexcept

Returns whether or not this MemberDelegate calls the given class member method pointer.

Parameters
methodPointerA pointer to a class member method to be checked against.
Returns
A boolean representing whether or not this MemberDelegate calls the given class method pointer.
template<typename classType, typename returnType, typename... parameters>
template<typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::callsMethod ( const StaticMethodPointer< otherReturn, otherParams...>  methodPointer) const
inlinenoexcept

Returns whether or not this MemberDelegate calls the given static method pointer.

Parameters
methodPointerA pointer to a static method to be checked against.
Returns
A boolean representing whether or not this MemberDelegate calls the given static method pointer.
Note
Always returns false because a MemberDelegate will never be calling a static method.
template<typename classType, typename returnType, typename... parameters>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::callsMethod ( const typename ITypedDelegate< returnType, parameters...>::StaticMethodPointerType  methodPointer) const
inlinenoexcept

Returns whether or not this MemeberDelegate calls the given static method address.

Parameters
methodPointerA pointer to the static method to be checked against.
Returns
A boolean representing whether or not this delegate calls the given proc address.
Note
Always returns false because a static method cannot be invoked by a MemberDelegate.
template<typename classType, typename returnType, typename... parameters>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::hasSameMethodAs ( const MemberDelegate< classType, returnType, parameters...> *  other) const
inlinenoexcept

Returns whether or not this MemberDelegate calls the same method as the other MemberDelegate.

Parameters
otherThe other MemberDelegate pointer to compare against.
Returns
A boolean representing whether or not both MemberDelegate instances share the same method.
template<typename classType, typename returnType, typename... parameters>
template<typename otherClass , typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::hasSameMethodAs ( const MemberDelegate< otherClass, otherReturn, otherParams...> *  other) const
inlinenoexcept

Returns whether or not this MemberDelegate calls the same method as the other of a deferring signature.

Parameters
otherThe other MemberDelegate pointer to compare against.
Returns
A boolean representing whether or not the two MemberDelegate instances call the same method.
Note
Always returns false because if the method signatures are different, then the methods should never share the same address.
template<typename classType, typename returnType, typename... parameters>
template<typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::hasSameMethodAs ( const StaticDelegate< otherReturn, otherParams...> *  other) const
inlinenoexcept

Returns whether or not this MemberDelegate calls the same method as the StaticDelegate type.

Parameters
otherThe other StaticDelegate pointer to compare against.
Returns
A boolean representing whether or not the this MemberDelegate calls the same method as the StaticDelegate.
Note
Always returns false because MemberDelegate types cannot call static methods.
template<typename classType, typename returnType, typename... parameters>
template<typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::hasSameThisPointerAs ( const StaticDelegate< otherReturn, otherParams...> *  other) const
inlinenoexcept

Returns whether or not this MemberDelegate calls against the same this pointer as the StaticDelegate.

Parameters
otherThe other StaticDelegate pointer to compare against.
Returns
A boolean representing whether or not the this MemberDelegate calls against the same this pointer as the StaticDelegate.
Note
Always returns false because StaticDelegate types do not use this pointers.
template<typename classType, typename returnType, typename... parameters>
template<typename otherClass , typename otherReturn , typename... otherParams>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::hasSameThisPointerAs ( const MemberDelegate< otherClass, otherReturn, otherParams...> *  other) const
inlinenoexcept

Returns whether or not this MemberDelegate calls against the same this pointer as the other.

Parameters
otherThe other MemberDelegate pointer to compare against.
Returns
A boolean representing whether or not the this MemberDelegate calls against the same this pointer as the other.
template<typename classType, typename returnType, typename... parameters>
EASYDELEGATE_INLINE bool EasyDelegate::MemberDelegate< classType, returnType, parameters >::hasThisPointer ( const void *  thisPointer) const
inlinevirtualnoexcept

Returns whether or not this MemberDelegate calls against the given this pointer.

Parameters
thisPointerA pointer referring to the object of interest.
Returns
A boolean representing whether or not this MemberDelegate calls a member function against the given this pointer.

Implements EasyDelegate::ITypedDelegate< returnType, parameters...>.

template<typename classType, typename returnType, typename... parameters>
returnType EasyDelegate::MemberDelegate< classType, returnType, parameters >::invoke ( parameters...  params)
inlinevirtual

Invoke the MemberDelegate.

Parameters
paramsAnything; It depends on the method signature specified in the template.
Returns
Anything; It depends on the method signature specified in the template.
Exceptions
EasyDelegate::InvalidMethodPointerExceptionThrown when the class member method that this delegate is supposed to be invoking is NULL.
EasyDelegate::InvalidThisPointerExceptionThrown when the MemberDelegate's this pointer is NULL.
std::exceptionPotentially thrown by the method called by this MemberDelegate.
Note
The call will not throw an exception in any of the EasyDelegate::DelegateException cases but rather assert if assertions are enabled.

Implements EasyDelegate::ITypedDelegate< returnType, parameters...>.


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