A set of delegate instances that provides helper methods to invoke all contained delegates.
More...
#include <delegateset.hpp>
|
| ~DelegateSet (void) |
| Standard destructor.
|
|
EASYDELEGATE_INLINE void | invoke (parameters...params) const |
| Invoke all delegates in the set, ignoring return values. More...
|
|
EASYDELEGATE_INLINE void | invoke (std::set< returnType > &out, parameters...params) const |
| Invoke all delegates in the set, storing return values in out. More...
|
|
EASYDELEGATE_INLINE void | push_back (StoredDelegateType *delegateInstance) |
| Pushes a delegate instance to the end of the set. More...
|
|
EASYDELEGATE_INLINE void | operator+= (StoredDelegateType *delegateInstance) |
| Pushes a delegate instance to the end of the set. More...
|
|
template<typename className > |
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. More...
|
|
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. More...
|
|
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 against. More...
|
|
StoredDelegateType * | removeDelegate (StoredDelegateType *instance, const bool &deleteInstance=true) |
| Removes a given delegate by its address. More...
|
|
template<typename returnType, typename... parameters>
class EasyDelegate::DelegateSet< returnType, parameters >
A set of delegate instances that provides helper methods to invoke all contained delegates.
The DelegateSet type can be described as a sink for specific event types. Typical usage of this behavior would involve creating a typedef of a DelegateSet type for a specific method signature which then has its own specialized typedefs to facilitate the creation of StaticDelegate and MemberDelegate types that are compatible with instances of this new specialized DelegateSet type.
- Examples:
- example.cpp.
template<typename returnType , typename... parameters>
Invoke all delegates in the set, ignoring return values.
- Parameters
-
params | All other arguments that will be used as parameters to each delegate. |
- Exceptions
-
- Note
- The call will not throw an exception in any of the DelegateException cases but rather assert if assertions are enabled.
-
If this throws an exception, the invocation of the set halts.
template<typename returnType , typename... parameters>
Invoke all delegates in the set, storing return values in out.
- Parameters
-
out | The std::set that all return values will be sequentially written to. |
params | All other arguments that will be used as parameters to each delegate. |
- Exceptions
-
- Note
- The call will not throw an exception in any of the DelegateException cases but rather assert if assertions are enabled.
-
If this throws an exception, the invocation of the set halts.
template<typename returnType , typename... parameters>
Pushes a delegate instance to the end of the set.
- Parameters
-
delegateInstance | The delegate instance to the pushed onto the set. |
- Warning
- Ownership of the delegate will be given to the set, therefore the given delegate should not be deleted manually.
template<typename returnType , typename... parameters>
Pushes a delegate instance to the end of the set.
- Parameters
-
delegateInstance | The delegate instance to the pushed onto the set. |
- Warning
- Ownership of the delegate will be given to the set, therefore the given delegate should not be deleted manually.
template<typename returnType , typename... parameters>
Removes a given delegate by its address.
- Parameters
-
instance | The delegate pointer to attempt to remove from this set. |
deleteInstance | A boolean representing whether or not the target delegate should be deleted. |
- Returns
- A pointer to the delegate that was removed. This is NULL if none were removed or if deleteInstance is true.
template<typename returnType , typename... parameters>
template<typename className >
Removes all delegates from the set that have the given class member method address for its method.
- Parameters
-
method | The class method method poiner to check against. |
deleteInstances | A boolean representing whether or not all matches should be deleted when removed. The default for this parameter is true for better memory management. |
out | A pointer to an std::unordered_set templated for the ITypedDelegate type that this DelegateSet contains. This set will then be populated with a list of removed delegates if deleteInstances if false. If deleteInstances is true, this list will never be populated as the removed delegates are simply deleted. |
- Warning
- If deleteInstances=false, then the delegates written to out will have their ownership transferred to whatever made the call, so they must be deletated accordingly.
template<typename returnType , typename... parameters>
Removes all delegates from the set that have the given static method address for it's method.
- Parameters
-
methodPointer | The static method pointer to check against. |
deleteInstances | A boolean representing whether or not all matches should be deleted when removed. The default for this parameter is true for better memory management. |
out | A pointer to an std::unordered_set templated for the ITypedDelegate type that this DelegateSet contains. This set will then be populated with a list of removed delegates if deleteInstances is false. If deleteInstances is true, then this list will never be populated as the removed delegates are simply destroyed. |
- Warning
- If deleteInstances is false and there is no out specified, you will be leaking memory if there is no other delegate sets tracking the removed delegates.
template<typename returnType , typename... parameters>
Removes a all MemberDelegate types from the set that have a given 'this' pointer address to call against.
- Parameters
-
thisPtr | The address of the object to check against. |
deleteInstances | A boolean representing whether or not all matches should be deleted when removed. The default for this parameter is true for better memory management. |
out | A pointer to an std::unordered_set templated for the ITypedDelegate type that this DelegateSet contains. This set will then be populated with a list of removed delegates if deleteInstances is false. If deleteInstances is true, then this list will never be populated as the removed delegates are simply deleted. |
- Warning
- If deleteInstances is false and there is no out specified, you will be leaking memory if there is no other delegate set tracking the removed delegates.
The documentation for this class was generated from the following file: