12 #ifndef _INCLUDE_EASYDELEGATE_DELEGATES_HPP_
13 #define _INCLUDE_EASYDELEGATE_DELEGATES_HPP_
22 template <
typename returnType,
typename... parameters>
52 template <
typename className,
typename returnType,
typename... parameters>
60 template <
typename returnType,
typename... parameters>
79 mMethodPointer(other->mMethodPointer) { }
92 returnType
invoke(parameters... params)
94 assert(mMethodPointer);
124 template <
typename otherClass,
typename otherReturn,
typename... otherParams>
143 template <
typename otherClass,
typename otherReturn,
typename... otherParams>
154 template <
typename otherReturn,
typename... otherParams>
165 template <
typename otherClass,
typename otherReturn,
typename... otherParams>
176 template <
typename otherReturn,
typename... otherParams>
189 template <
typename classType,
typename returnType,
typename... parameters>
190 class MemberDelegate :
public ITypedDelegate<returnType, parameters...>
207 mMethodPointer(methodPointer),
ITypedDelegate<returnType, parameters...>(true) { }
214 mMethodPointer(other->mMethodPointer),
ITypedDelegate<returnType, parameters...>(true) { }
231 assert(mMethodPointer);
239 classType *thisPointer = (classType*)thisPointer;
240 return (thisPointer->*mMethodPointer)(params...);
264 template <
typename otherReturn,
typename... otherParams>
291 template <
typename otherClass,
typename otherReturn,
typename... otherParams>
302 template <
typename otherReturn,
typename... otherParams>
313 template <
typename otherReturn,
typename... otherParams>
323 template <
typename otherClass,
typename otherReturn,
typename... otherParams>
342 template <
typename returnType,
typename... parameters>
352 template <
typename classType>
359 template <
typename classType>
390 template <
typename className>
398 const MemberDelegate<className, returnType, parameters...>* memberDelegateObj =
reinterpret_cast<const MemberDelegate<className, returnType, parameters...
>*>(
this);
399 return memberDelegateObj->callsMethod(methodPointer);
409 virtual bool hasThisPointer(
const void* thisPointer)
const noexcept = 0;
423 virtual returnType
invoke(parameters... params) = 0;
426 #endif // _INCLUDE_EASYDELEGATE_DELEGATES_HPP_
MemberMethodPointer< classType, returnType, parameters...> MethodPointer
Helper typedef referring to a static function pointer that is compatible with this delegate...
Definition: delegates.hpp:194
A delegate of a class member method.
Definition: delegates.hpp:53
EASYDELEGATE_INLINE bool callsMethod(const StaticMethodPointer< otherReturn, otherParams...> methodPointer) const noexcept
Returns whether or not this MemberDelegate calls the given static method pointer. ...
Definition: delegates.hpp:265
EASYDELEGATE_INLINE bool hasThisPointer(const void *thisPointer) const noexcept
Returns whether or not this MemberDelegate calls against the given this pointer.
Definition: delegates.hpp:249
A type that can represent any delegate type, but it cannot be invoked without casting to a delegate t...
Definition: delegates.hpp:35
returnType(className::*)(parameters...) MemberMethodPointer
Helper typedef to a pointer of a class member method with the given signature.
Definition: types.hpp:69
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.
Definition: delegates.hpp:280
returnType invoke(parameters...params)
Invoke the MemberDelegate.
Definition: delegates.hpp:228
classType * mThisPointer
A pointer to the this object.
Definition: delegates.hpp:329
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...
Definition: delegates.hpp:324
ITypedDelegate(const bool &isMemberDelegate) noexcept
Constructor accepting a boolean.
Definition: delegates.hpp:369
returnType(*)(parameters...) StaticMethodPointer
Helper typedef to a pointer of a static method with the given signature.
Definition: types.hpp:65
EASYDELEGATE_INLINE bool hasThisPointer(const void *thisPointer) const noexcept
Returns whether or not this StaticDelegate calls against the given this pointer.
Definition: delegates.hpp:109
Include file containing the definitions for all exception types thrown by the EasyDelegate library...
An exception type that is thrown by the EasyDelegate library when any delegate type has attempted to ...
Definition: exceptions.hpp:51
EASYDELEGATE_INLINE bool hasSameThisPointerAs(const StaticDelegate< otherReturn, otherParams...> *other) const noexcept
Returns whether or not this StaticDelegate uses the same this pointer as the StaticDelegate we are ch...
Definition: delegates.hpp:177
const bool mIsMemberDelegate
A boolean representing whether or not this delegate is a member delegate.
Definition: delegates.hpp:40
EASYDELEGATE_INLINE bool hasSameMethodAs(const StaticDelegate< otherReturn, otherParams...> *other) const noexcept
Returns whether or not this StaticDelegate calls against the same method as the StaticDelegate we are...
Definition: delegates.hpp:155
StaticDelegate< returnType, parameters...> StaticDelegateType
Helper typedef for when building static delegates.
Definition: delegates.hpp:350
StaticMethodPointer< returnType, parameters...> StaticMethodPointerType
Helper typedef referring to a static function pointer.
Definition: delegates.hpp:356
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...
Definition: delegates.hpp:314
StaticMethodPointer< returnType, parameters...> MethodPointer
Helper typedef referring to a static method pointer that is compatible with this delegate.
Definition: delegates.hpp:65
Include file declaring various helper types used by the EasyDelegate library. They may also aid progr...
StaticDelegate(const StaticDelegate< returnType, parameters...> *other)
Standard copy constructor.
Definition: delegates.hpp:78
returnType ReturnType
Helper typedef referring to the return type of this delegate.
Definition: delegates.hpp:348
Namespace containing all EasyDelegate functionality.
Definition: deferredcallers.hpp:20
EASYDELEGATE_INLINE bool hasSameMethodAs(const StaticDelegate< returnType, parameters...> *other) const noexcept
Returns whether or not this StaticDelegate calls the same method as the StaticDelegate we are checkin...
Definition: delegates.hpp:134
Base delegate type.
Definition: delegates.hpp:23
#define EASYDELEGATE_INLINE
A preprocessor definition for a keyword that forces the inlining of a given method.
Definition: easydelegate.hpp:33
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.
Definition: delegates.hpp:273
A delegate of a static method.
Definition: delegates.hpp:61
MemberDelegate(const MethodPointer methodPointer, classType *thisPointer)
Constructor accepting a this pointer and a member function.
Definition: delegates.hpp:206
EASYDELEGATE_INLINE bool callsMethod(const MemberMethodPointer< otherClass, otherReturn, otherParams...> methodPointer) const noexcept
Returns whether or not this StaticDelegate calls the given class member method.
Definition: delegates.hpp:125
virtual returnType invoke(parameters...params)=0
Invoke the delegate with the given arguments and return a value, if any.
virtual bool hasThisPointer(const void *thisPointer) const noexcept=0
Returns whether or not this delegate calls against the given this pointer.
MemberDelegate(const MemberDelegate< classType, returnType, parameters...> *other)
Standard copy constructor.
Definition: delegates.hpp:213
virtual bool callsMethod(const StaticMethodPointerType methodPointer) const noexcept=0
Returns whether or not this delegate calls the given static method.
EASYDELEGATE_INLINE bool hasSameMethodAs(const MemberDelegate< otherClass, otherReturn, otherParams...> *other) const noexcept
Returns whether or not this StaticDelegate calls against the same method as the MemberDelegate we are...
Definition: delegates.hpp:144
StaticDelegate(const MethodPointer methodPointer)
Constructor accepting a static method.
Definition: delegates.hpp:72
IDelegate(const bool &isMemberDelegate) noexcept
Constructor accepting a boolean.
Definition: delegates.hpp:49
bool callsMethod(const MemberDelegateFuncPtr< className > methodPointer) const noexcept
Returns whether or not this delegate calls the given class member method address. ...
Definition: delegates.hpp:391
EASYDELEGATE_INLINE bool callsMethod(const MethodPointer methodPointer) const noexcept
Returns whether or not this MemberDelegate calls the given class member method pointer.
Definition: delegates.hpp:256
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 signatur...
Definition: delegates.hpp:292
returnType(classType::*)(parameters...) MemberDelegateFuncPtr
Helper typedef referring to a class member method pointer.
Definition: delegates.hpp:360
An exception type that is thrown by the EasyDelegate library when a member delegate type has attempte...
Definition: exceptions.hpp:31
returnType invoke(parameters...params)
Invokes the StaticDelegate.
Definition: delegates.hpp:92
EASYDELEGATE_INLINE bool callsMethod(const MethodPointer methodPointer) const noexcept
Returns whether or not this StaticDelegate calls the given static method.
Definition: delegates.hpp:116
EASYDELEGATE_INLINE bool hasSameThisPointerAs(const MemberDelegate< otherClass, otherReturn, otherParams...> *other) const noexcept
Returns whether or not this StaticDelegate uses the same this pointer as the MemberDelegate we are ch...
Definition: delegates.hpp:166
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...
Definition: delegates.hpp:303