12 #ifndef _INCLUDE_EASYDELEGATE_DELEGATESET_HPP_
13 #define _INCLUDE_EASYDELEGATE_DELEGATESET_HPP_
16 #include <unordered_set>
33 template <
typename returnType,
typename... parameters>
34 class DelegateSet :
public std::set<ITypedDelegate<returnType, parameters...> *>
44 template <
typename classType>
54 template <
typename classType>
57 #ifndef EASYDELEGATE_NO_DEFERRED_CALLING
62 template <
typename classType>
78 for (
auto it = this->begin(); it != this->end(); it++)
96 for (
auto it = this->begin(); it != this->end(); it++)
97 (*it)->invoke(params...);
115 for (
auto it = this->begin(); it != this->end(); it++)
116 out.insert(out.end(), (*it)->invoke(params...));
127 this->insert(this->end(), delegateInstance);
153 template <
typename className>
156 for (
auto it = this->begin(); it != this->end(); it++)
165 out->insert(out->end(), current);
167 this->erase(current);
186 for (
auto it = this->begin(); it != this->end(); it++)
195 out->insert(out->end(), current);
197 this->erase(current);
216 for (
auto it = this->begin(); it != this->end(); it++)
225 out->insert(out->end(), current);
227 this->erase(current);
242 for (
auto it = this->begin(); it != this->end(); it++)
246 if (current == instance)
251 this->erase(current);
264 #endif // _INCLUDE_EASYDELEGATE_DELEGATESET_HPP_
A delegate of a class member method.
Definition: delegates.hpp:53
void removeDelegateByThisPointer(const void *thisPtr, const bool &deleteInstances=true, std::unordered_set< StoredDelegateType * > *out=NULL)
Removes a all MemberDelegate types from the set that have a given 'this' pointer address to call agai...
Definition: delegateset.hpp:214
EASYDELEGATE_INLINE void push_back(StoredDelegateType *delegateInstance)
Pushes a delegate instance to the end of the set.
Definition: delegateset.hpp:125
std::set< returnType > ReturnSetType
Helper typedef to an std::set that is compatible with the return types of delegates stored here...
Definition: delegateset.hpp:73
~DelegateSet(void)
Standard destructor.
Definition: delegateset.hpp:76
EASYDELEGATE_INLINE void operator+=(StoredDelegateType *delegateInstance)
Pushes a delegate instance to the end of the set.
Definition: delegateset.hpp:136
Include file declaring the deferred caller types for use in systems where deferred calls is a necessi...
const bool mIsMemberDelegate
A boolean representing whether or not this delegate is a member delegate.
Definition: delegates.hpp:40
Include file declaring various helper types used by the EasyDelegate library. They may also aid progr...
DeferredStaticCaller< returnType, parameters...> DeferredStaticCallerType
A helper typedef to a DeferredStaticCaller matches the signatures stored in this delegate set...
Definition: delegateset.hpp:69
Namespace containing all EasyDelegate functionality.
Definition: deferredcallers.hpp:20
returnType(* StaticDelegateFuncPtr)(parameters...)
Helper typedef referring to a static function pointer.
Definition: delegateset.hpp:52
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
A delegate of a static method.
Definition: delegates.hpp:61
returnType ReturnType
Helper typedef for when wanting the return type of this set.
Definition: delegateset.hpp:47
EASYDELEGATE_INLINE void invoke(parameters...params) const
Invoke all delegates in the set, ignoring return values.
Definition: delegateset.hpp:94
A deferred caller type for class member methods.
Definition: deferredcallers.hpp:66
virtual bool hasThisPointer(const void *thisPointer) const noexcept=0
Returns whether or not this delegate calls against the given this pointer.
StoredDelegateType * removeDelegate(StoredDelegateType *instance, const bool &deleteInstance=true)
Removes a given delegate by its address.
Definition: delegateset.hpp:240
virtual bool callsMethod(const StaticMethodPointerType methodPointer) const noexcept=0
Returns whether or not this delegate calls the given static method.
EASYDELEGATE_INLINE void removeDelegateByMethod(const MemberDelegateFuncPtr< className > method, const bool &deleteInstances=true, std::unordered_set< StoredDelegateType * > *out=NULL)
Removes all delegates from the set that have the given class member method address for its method...
Definition: delegateset.hpp:154
void removeDelegateByMethod(StaticDelegateFuncPtr methodPointer, const bool &deleteInstances=true, std::unordered_set< StoredDelegateType * > *out=NULL)
Removes all delegates from the set that have the given static method address for it's method...
Definition: delegateset.hpp:184
EASYDELEGATE_INLINE void invoke(std::set< returnType > &out, parameters...params) const
Invoke all delegates in the set, storing return values in out.
Definition: delegateset.hpp:113
ITypedDelegate< returnType, parameters...> StoredDelegateType
Helper typedef to construct the StaticDelegate signature from the template.
Definition: delegateset.hpp:49
returnType(classType::*)(parameters...) MemberDelegateFuncPtr
Helper typedef referring to a member function pointer.
Definition: delegateset.hpp:55
A set of delegate instances that provides helper methods to invoke all contained delegates.
Definition: delegateset.hpp:34
StaticDelegate< returnType, parameters...> StaticDelegateType
Helper typedef for when building static delegates for this set.
Definition: delegateset.hpp:42
returnType(* delegateFuncPtr)(parameters...)
Helper typedef to construct the function pointer signature from the template.
Definition: delegateset.hpp:38
Include file declaring various delegate types.
A deferred caller type for static methods.
Definition: deferredcallers.hpp:76