Represents a collection of delegates. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type. More...
Inherits System::Details::DelegateHoldingVariables.
Public Types | |
using | Callback = Delegate< ReturnType(ArgumentTypes...)> |
The type of the delegates represented by the MulticastDelegate class. More... | |
Public Member Functions | |
MulticastDelegate () | |
Constructs an empty collection. More... | |
~MulticastDelegate () | |
Destructor. More... | |
MulticastDelegate (std::nullptr_t) | |
Equivalent to defalt constructor. More... | |
MulticastDelegate (const MulticastDelegate &o) | |
Performs a shallow copy of the delegate collection. More... | |
MulticastDelegate & | operator= (const MulticastDelegate &o) |
Assigns the collection of delegates represented by the specified object to the current object. As a result both objects point to the same collection of delegates. More... | |
MulticastDelegate (MulticastDelegate &&o) noexcept | |
Moving constructor. More... | |
MulticastDelegate & | operator= (MulticastDelegate &&o) noexcept |
Moving assignment operator. More... | |
MulticastDelegate (Callback &&initial) | |
Constructs an instance and puts the specified delegate to the delegates collection. More... | |
template<class T , typename = decltype(Callback(std::declval<T>()))> | |
MulticastDelegate (T arg) | |
Constructs an instance and puts the specified value to the delegates collection. More... | |
MulticastDelegate (std::function< ReturnType(ArgumentTypes...)> arg) | |
Constructs an instance and puts the specified value to the delegates collection. More... | |
bool | empty () const |
Determines whether the delegate collection is empty. More... | |
bool | IsNull () const |
Determines whether the delegate collection is empty. More... | |
const TypeInfo & | GetType () const |
String | ToString () const |
int | GetHashCode () const |
bool | operator== (const std::nullptr_t &) const |
Determines whether the delegate collection is empty. More... | |
bool | operator!= (const std::nullptr_t &) const |
Determines whether the delegate collection is not empty. More... | |
MulticastDelegate & | connect (Callback callback) |
Adds the specified delegate to the collection. More... | |
template<class R , class... Args> | |
MulticastDelegate & | connect (std::function< R(Args...)> f) |
Adds the specified function object to the delegate collection. The function object is converted to the Callback delegate type before being added to the collection. More... | |
MulticastDelegate & | connect (MulticastDelegate &other) |
Adds the specified MulticastDelegate object to the delegate collection. More... | |
template<class MemberType , class ClassType > | |
MulticastDelegate & | connect (MemberType ClassType::*member, ClassType *obj) |
Adds the specified non-static method of the specified object to the delegate collection. More... | |
template<class MemberType , class ClassType > | |
MulticastDelegate & | connect (MemberType ClassType::*member, const SharedPtr< ClassType > &obj) |
Adds the specified non-static method of the specified object to the delegate collection. More... | |
MulticastDelegate & | operator+= (Callback callback) |
Adds the specified delegate to the collection. More... | |
MulticastDelegate & | disconnect (Callback callback) |
Removes the specified delegate from the delegate collection. More... | |
template<class MemberType , class ClassType > | |
MulticastDelegate & | disconnect (MemberType ClassType::*member, ClassType *obj) |
Removes the specified non-static method of the specified object from the delegate collection. More... | |
template<class MemberType , class ClassType > | |
MulticastDelegate & | disconnect (MemberType ClassType::*member, const SharedPtr< ClassType > &obj) |
Removes the specified non-static method of the specified object from the delegate collection. More... | |
MulticastDelegate & | disconnect (MulticastDelegate &other) |
Removes the specified MulticastDelegate object from the delegate collection. More... | |
MulticastDelegate & | operator-= (Callback callback) |
Removes the specified delegate from the delegate collection. More... | |
bool | operator== (const MulticastDelegate &other) const |
Determines whether two instances of MulticastDelegate - the current object and the specified object - are equal. More... | |
bool | operator!= (const MulticastDelegate &other) const |
Determines whether two instances of MulticastDelegate - the current object and the specified object - are inequal. More... | |
MulticastDelegate & | disconnect_all_slots () |
Removes all delegates from the delegate collection. More... | |
void | remove_empty_callbacks () const |
Cleans out contained callbacks that are empty (not actually calling anything). More... | |
ReturnType | invoke (ArgumentTypes... args) const |
Invokes all delegates currently present in the delegates collection. Delegates are invoked in the same order as they were added to the collection. The method blocks while the delegates are executed. More... | |
ReturnType | operator() (ArgumentTypes... args) const |
Invokes all delegates currently present in the delegates collection. Delegates are invoked in the same order as they were added to the collection. The operator blocks while the delegates are executed. More... | |
template<typename CallbackArgumentType > | |
SharedPtr< IAsyncResult > | BeginInvoke (ArgumentTypes... args, const AsyncCallback &member, const CallbackArgumentType &obj) |
NOT IMPLEMENTED. More... | |
ReturnType | EndInvoke (const SharedPtr< IAsyncResult > &) |
NOT IMPLEMENTED. More... | |
Static Public Member Functions | |
static const TypeInfo & | Type () |
Returns a reference to the TypeInfo object representing the MulticastDelegate class type information. More... | |
Represents a collection of delegates. This type should be allocated on stack and passed to functions by value or by reference. Never use System::SmartPtr class to manage objects of this type.
ReturnType | Return type of the invokable entities pointed to by each delegate in the collection |
ArgumentTypes | Argument list of the invokable entities pointed to by each delegate in the collection #include "system/multicast_delegate.h" #include <iostream> int main() { // Create an instance of MulticastDelegate. System::MulticastDelegate<void(float, float)> operations; // Print the sum of two numbers. operations.connect(std::function<void(float, float)>([](float a, float b) -> void { std::cout << a << " + " << b << " = " << a + b << std::endl; })); // Print the sub of two numbers. operations.connect(std::function<void(float, float)>([](float a, float b) -> void { std::cout << a << " - " << b << " = " << a - b << std::endl; })); // Print the mul of two numbers. operations.connect(std::function<void(float, float)>([](float a, float b) -> void { std::cout << a << " * " << b << " = " << a * b << std::endl; })); // Print the div of two numbers. operations.connect(std::function<void(float, float)>([](float a, float b) -> void { std::cout << a << " / " << b << " = " << a / b << std::endl; })); // Call all operations with two numbers. operations(10.0f, 2.0f); return 0; } /* This code example produces the following output: 10 + 2 = 12 10 - 2 = 8 10 * 2 = 20 10 / 2 = 5 */ |
using System::MulticastDelegate< ReturnType(ArgumentTypes...)>::Callback = Delegate<ReturnType(ArgumentTypes...)> |
The type of the delegates represented by the MulticastDelegate class.
|
inline |
Constructs an empty collection.
|
inline |
Destructor.
|
inline |
Equivalent to defalt constructor.
|
inline |
Performs a shallow copy of the delegate collection.
o | An instance of MulticastDelegate class to copy the collection of delegates from. |
|
inlinenoexcept |
Moving constructor.
o | An instance of MulticastDelegate class to move the collection of delegates from. |
|
inline |
Constructs an instance and puts the specified delegate to the delegates collection.
initial | A delegate to put to the delegate collection |
|
inline |
Constructs an instance and puts the specified value to the delegates collection.
arg | A value to put to the delegate collection |
T | Type of the value to put to the delegate collection of the newly constructed instance; the type must be convertible to Callback type. |
|
inline |
Constructs an instance and puts the specified value to the delegates collection.
arg | A value to put to the delegate collection |
|
inline |
NOT IMPLEMENTED.
NotImplementedException | Always |
|
inline |
Adds the specified delegate to the collection.
callback | The delegate to add to the collection |
|
inline |
Adds the specified function object to the delegate collection. The function object is converted to the Callback delegate type before being added to the collection.
f | The function object to add to the collection |
R | The return type of the function object to add to the collection |
Args | The argument list of the function object to add to the collection |
|
inline |
Adds the specified MulticastDelegate object to the delegate collection.
other | An instance of the MulticastDelegate class to add to the delegate collection |
|
inline |
Adds the specified non-static method of the specified object to the delegate collection.
member | A pointer to the non-static method of the specified object |
obj | A pointer to an object member method of which is to be added to the delegate collection |
MemberType | The type of the non-static method that is to be added to the delegate collection |
ClassType | The type of the object method of which is to be added to the delegate |
|
inline |
Adds the specified non-static method of the specified object to the delegate collection.
member | A pointer to the non-static method of the specified object |
obj | A shared pointer to an object member method of which is to be added to the delegate collection |
MemberType | The type of the non-static method that is to be added to the delegate collection |
ClassType | The type of the object method of which is to be added to the delegate collection |
|
inline |
Removes the specified delegate from the delegate collection.
callback | The delegate to remove from the collection |
|
inline |
Removes the specified non-static method of the specified object from the delegate collection.
member | A pointer to the non-static method of the specified object |
obj | A pointer to an object member method of which is to be removed from the delegate collection |
MemberType | The type of the non-static method that is to be removed from the delegate collection |
ClassType | The type of the object method of which is to be removed from the delegate collection |
|
inline |
Removes the specified non-static method of the specified object from the delegate collection.
member | A pointer to the non-static method of the specified object |
obj | A shared pointer to an object member method of which is to be removed from the delegate collection |
MemberType | The type of the non-static method that is to be removed from the delegate collection |
ClassType | The type of the object method of which is to be removed from the delegate collection |
|
inline |
Removes the specified MulticastDelegate object from the delegate collection.
other | An instance of the MulticastDelegate class to remove from the delegate collection |
|
inline |
Removes all delegates from the delegate collection.
|
inline |
Determines whether the delegate collection is empty.
|
inline |
NOT IMPLEMENTED.
NotImplementedException | Always |
|
inline |
|
inline |
|
inline |
Invokes all delegates currently present in the delegates collection. Delegates are invoked in the same order as they were added to the collection. The method blocks while the delegates are executed.
args | Arguments to pass to the delegates to be invoked |
|
inline |
Determines whether the delegate collection is empty.
|
inline |
Determines whether the delegate collection is not empty.
|
inline |
Determines whether two instances of MulticastDelegate - the current object and the specified object - are inequal.
other | The MulticastDelegate object to compare with |
|
inline |
Invokes all delegates currently present in the delegates collection. Delegates are invoked in the same order as they were added to the collection. The operator blocks while the delegates are executed.
args | Arguments to pass to the delegates to be invoked |
|
inline |
Adds the specified delegate to the collection.
callback | The delegate to add to the collection |
|
inline |
Removes the specified delegate from the delegate collection.
callback | The delegate to remove from the collection |
|
inline |
Assigns the collection of delegates represented by the specified object to the current object. As a result both objects point to the same collection of delegates.
o | An instance of MulticastDelegate class containing the collection of delegates to be assigned to the current object. |
|
inlinenoexcept |
Moving assignment operator.
o | An instance of MulticastDelegate class to move the collection of delegates from. |
|
inline |
Determines whether the delegate collection is empty.
|
inline |
Determines whether two instances of MulticastDelegate - the current object and the specified object - are equal.
other | The MulticastDelegate object to compare with |
|
inline |
Cleans out contained callbacks that are empty (not actually calling anything).
|
inline |