Asposecpplib
System::MulticastDelegate< ReturnType(ArgumentTypes...)> Class Template Reference

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...
 
MulticastDelegateoperator= (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)
 Moving constructor. More...
 
MulticastDelegateoperator= (MulticastDelegate &&o)
 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...
 
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...
 
MulticastDelegateconnect (Callback callback)
 Adds the specified delegate to the collection. More...
 
template<class R , class... Args>
MulticastDelegateconnect (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...
 
MulticastDelegateconnect (MulticastDelegate &other)
 Adds the specified MulticastDelegate object to the delegate collection. More...
 
template<class MemberType , class ClassType >
MulticastDelegateconnect (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 >
MulticastDelegateconnect (MemberType ClassType::*member, const SharedPtr< ClassType > &obj)
 Adds the specified non-static method of the specified object to the delegate collection. More...
 
MulticastDelegateoperator+= (Callback callback)
 Adds the specified delegate to the collection. More...
 
MulticastDelegatedisconnect (Callback callback)
 Removes the specified delegate from the delegate collection. More...
 
template<class MemberType , class ClassType >
MulticastDelegatedisconnect (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 >
MulticastDelegatedisconnect (MemberType ClassType::*member, const SharedPtr< ClassType > &obj)
 Removes the specified non-static method of the specified object from the delegate collection. More...
 
MulticastDelegatedisconnect (MulticastDelegate &other)
 Removes the specified MulticastDelegate object from the delegate collection. More...
 
MulticastDelegateoperator-= (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 - point to the same delegates collection. More...
 
bool operator!= (const MulticastDelegate &other) const
 Determines whether two instances of MulticastDelegate - the current object and the specified object - point to different delegates collection. More...
 
MulticastDelegatedisconnect_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< IAsyncResultBeginInvoke (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 TypeInfoType ()
 Returns a reference to the TypeInfo object representing the MulticastDelegate class type information. More...
 

Detailed Description

template<class ReturnType, class... ArgumentTypes>
class System::MulticastDelegate< ReturnType(ArgumentTypes...)>

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.

Template Parameters
ReturnTypeReturn type of the invokable entities pointed to by each delegate in the collection
ArgumentTypesArgument 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
*/
Definition: multicast_delegate.h:28

Member Typedef Documentation

◆ Callback

template<class ReturnType , class... ArgumentTypes>
using System::MulticastDelegate< ReturnType(ArgumentTypes...)>::Callback = Delegate<ReturnType(ArgumentTypes...)>

The type of the delegates represented by the MulticastDelegate class.

Constructor & Destructor Documentation

◆ MulticastDelegate() [1/7]

template<class ReturnType , class... ArgumentTypes>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::MulticastDelegate ( )
inline

Constructs an empty collection.

◆ ~MulticastDelegate()

template<class ReturnType , class... ArgumentTypes>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::~MulticastDelegate ( )
inline

Destructor.

◆ MulticastDelegate() [2/7]

template<class ReturnType , class... ArgumentTypes>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::MulticastDelegate ( std::nullptr_t  )
inline

Equivalent to defalt constructor.

◆ MulticastDelegate() [3/7]

template<class ReturnType , class... ArgumentTypes>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::MulticastDelegate ( const MulticastDelegate< ReturnType(ArgumentTypes...)> &  o)
inline

Performs a shallow copy of the delegate collection.

Parameters
oAn instance of MulticastDelegate class to copy the collection of delegates from.

◆ MulticastDelegate() [4/7]

template<class ReturnType , class... ArgumentTypes>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::MulticastDelegate ( MulticastDelegate< ReturnType(ArgumentTypes...)> &&  o)
inline

Moving constructor.

Parameters
oAn instance of MulticastDelegate class to move the collection of delegates from.

◆ MulticastDelegate() [5/7]

template<class ReturnType , class... ArgumentTypes>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::MulticastDelegate ( Callback &&  initial)
inline

Constructs an instance and puts the specified delegate to the delegates collection.

Parameters
initialA delegate to put to the delegate collection

◆ MulticastDelegate() [6/7]

template<class ReturnType , class... ArgumentTypes>
template<class T , typename = decltype(Callback(std::declval<T>()))>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::MulticastDelegate ( arg)
inline

Constructs an instance and puts the specified value to the delegates collection.

Parameters
argA value to put to the delegate collection
Template Parameters
TType of the value to put to the delegate collection of the newly constructed instance; the type must be convertible to Callback type.

◆ MulticastDelegate() [7/7]

template<class ReturnType , class... ArgumentTypes>
System::MulticastDelegate< ReturnType(ArgumentTypes...)>::MulticastDelegate ( std::function< ReturnType(ArgumentTypes...)>  arg)
inline

Constructs an instance and puts the specified value to the delegates collection.

Parameters
argA value to put to the delegate collection

Member Function Documentation

◆ BeginInvoke()

template<class ReturnType , class... ArgumentTypes>
template<typename CallbackArgumentType >
SharedPtr<IAsyncResult> System::MulticastDelegate< ReturnType(ArgumentTypes...)>::BeginInvoke ( ArgumentTypes...  args,
const AsyncCallback member,
const CallbackArgumentType &  obj 
)
inline

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ connect() [1/5]

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::connect ( Callback  callback)
inline

Adds the specified delegate to the collection.

Parameters
callbackThe delegate to add to the collection
Returns
A reference to the self

◆ connect() [2/5]

template<class ReturnType , class... ArgumentTypes>
template<class MemberType , class ClassType >
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::connect ( MemberType ClassType::*  member,
ClassType *  obj 
)
inline

Adds the specified non-static method of the specified object to the delegate collection.

Parameters
memberA pointer to the non-static method of the specified object
objA pointer to an object member method of which is to be added to the delegate collection
Returns
A reference to the self
Template Parameters
MemberTypeThe type of the non-static method that is to be added to the delegate collection
ClassTypeThe type of the object method of which is to be added to the delegate

◆ connect() [3/5]

template<class ReturnType , class... ArgumentTypes>
template<class MemberType , class ClassType >
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::connect ( MemberType ClassType::*  member,
const SharedPtr< ClassType > &  obj 
)
inline

Adds the specified non-static method of the specified object to the delegate collection.

Parameters
memberA pointer to the non-static method of the specified object
objA shared pointer to an object member method of which is to be added to the delegate collection
Returns
A reference to the self
Template Parameters
MemberTypeThe type of the non-static method that is to be added to the delegate collection
ClassTypeThe type of the object method of which is to be added to the delegate collection

◆ connect() [4/5]

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::connect ( MulticastDelegate< ReturnType(ArgumentTypes...)> &  other)
inline

Adds the specified MulticastDelegate object to the delegate collection.

Parameters
otherAn instance of the MulticastDelegate class to add to the delegate collection
Returns
A reference to the self

◆ connect() [5/5]

template<class ReturnType , class... ArgumentTypes>
template<class R , class... Args>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::connect ( std::function< R(Args...)>  f)
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.

Parameters
fThe function object to add to the collection
Returns
A reference to the self
Template Parameters
RThe return type of the function object to add to the collection
ArgsThe argument list of the function object to add to the collection

◆ disconnect() [1/4]

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::disconnect ( Callback  callback)
inline

Removes the specified delegate from the delegate collection.

Parameters
callbackThe delegate to remove from the collection
Returns
A reference to the self

◆ disconnect() [2/4]

template<class ReturnType , class... ArgumentTypes>
template<class MemberType , class ClassType >
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::disconnect ( MemberType ClassType::*  member,
ClassType *  obj 
)
inline

Removes the specified non-static method of the specified object from the delegate collection.

Parameters
memberA pointer to the non-static method of the specified object
objA pointer to an object member method of which is to be removed from the delegate collection
Returns
A reference to the self
Template Parameters
MemberTypeThe type of the non-static method that is to be removed from the delegate collection
ClassTypeThe type of the object method of which is to be removed from the delegate collection

◆ disconnect() [3/4]

template<class ReturnType , class... ArgumentTypes>
template<class MemberType , class ClassType >
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::disconnect ( MemberType ClassType::*  member,
const SharedPtr< ClassType > &  obj 
)
inline

Removes the specified non-static method of the specified object from the delegate collection.

Parameters
memberA pointer to the non-static method of the specified object
objA shared pointer to an object member method of which is to be removed from the delegate collection
Returns
A reference to the self
Template Parameters
MemberTypeThe type of the non-static method that is to be removed from the delegate collection
ClassTypeThe type of the object method of which is to be removed from the delegate collection

◆ disconnect() [4/4]

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::disconnect ( MulticastDelegate< ReturnType(ArgumentTypes...)> &  other)
inline

Removes the specified MulticastDelegate object from the delegate collection.

Parameters
otherAn instance of the MulticastDelegate class to remove from the delegate collection
Returns
A reference to the self

◆ disconnect_all_slots()

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::disconnect_all_slots ( )
inline

Removes all delegates from the delegate collection.

Returns
A reference to the self

◆ empty()

template<class ReturnType , class... ArgumentTypes>
bool System::MulticastDelegate< ReturnType(ArgumentTypes...)>::empty ( ) const
inline

Determines whether the delegate collection is empty.

Returns
True if the delegate collection is empty, otherwise - false

◆ EndInvoke()

template<class ReturnType , class... ArgumentTypes>
ReturnType System::MulticastDelegate< ReturnType(ArgumentTypes...)>::EndInvoke ( const SharedPtr< IAsyncResult > &  )
inline

NOT IMPLEMENTED.

Exceptions
NotImplementedExceptionAlways

◆ invoke()

template<class ReturnType , class... ArgumentTypes>
ReturnType System::MulticastDelegate< ReturnType(ArgumentTypes...)>::invoke ( ArgumentTypes...  args) const
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.

Parameters
argsArguments to pass to the delegates to be invoked
Returns
Return value of the last invoked delegate

◆ IsNull()

template<class ReturnType , class... ArgumentTypes>
bool System::MulticastDelegate< ReturnType(ArgumentTypes...)>::IsNull ( ) const
inline

Determines whether the delegate collection is empty.

Returns
True if the delegate collection is empty, otherwise - false

◆ operator!=() [1/2]

template<class ReturnType , class... ArgumentTypes>
bool System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator!= ( const MulticastDelegate< ReturnType(ArgumentTypes...)> &  other) const
inline

Determines whether two instances of MulticastDelegate - the current object and the specified object - point to different delegates collection.

Parameters
otherThe MulticastDelegate object to compare with
Returns
True if both objects represent the same delegates collection, otherwise - false

◆ operator!=() [2/2]

template<class ReturnType , class... ArgumentTypes>
bool System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator!= ( const std::nullptr_t &  ) const
inline

Determines whether the delegate collection is not empty.

Returns
True if the delegate collection is not empty, otherwise - false

◆ operator()()

template<class ReturnType , class... ArgumentTypes>
ReturnType System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator() ( ArgumentTypes...  args) const
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.

Parameters
argsArguments to pass to the delegates to be invoked
Returns
Return value of the last invoked delegate

◆ operator+=()

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator+= ( Callback  callback)
inline

Adds the specified delegate to the collection.

Parameters
callbackThe delegate to add to the collection
Returns
A reference to the self

◆ operator-=()

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator-= ( Callback  callback)
inline

Removes the specified delegate from the delegate collection.

Parameters
callbackThe delegate to remove from the collection
Returns
A reference to the self

◆ operator=() [1/2]

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator= ( const MulticastDelegate< ReturnType(ArgumentTypes...)> &  o)
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.

Parameters
oAn instance of MulticastDelegate class containing the collection of delegates to be assigned to the current object.

◆ operator=() [2/2]

template<class ReturnType , class... ArgumentTypes>
MulticastDelegate& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator= ( MulticastDelegate< ReturnType(ArgumentTypes...)> &&  o)
inline

Moving assignment operator.

Parameters
oAn instance of MulticastDelegate class to move the collection of delegates from.

◆ operator==() [1/2]

template<class ReturnType , class... ArgumentTypes>
bool System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator== ( const MulticastDelegate< ReturnType(ArgumentTypes...)> &  other) const
inline

Determines whether two instances of MulticastDelegate - the current object and the specified object - point to the same delegates collection.

Parameters
otherThe MulticastDelegate object to compare with
Returns
True if both objects represent the same delegates collection, otherwise - false

◆ operator==() [2/2]

template<class ReturnType , class... ArgumentTypes>
bool System::MulticastDelegate< ReturnType(ArgumentTypes...)>::operator== ( const std::nullptr_t &  ) const
inline

Determines whether the delegate collection is empty.

Returns
True if the delegate collection is empty, otherwise - false

◆ remove_empty_callbacks()

template<class ReturnType , class... ArgumentTypes>
void System::MulticastDelegate< ReturnType(ArgumentTypes...)>::remove_empty_callbacks ( ) const
inline

Cleans out contained callbacks that are empty (not actually calling anything).

◆ Type()

template<class ReturnType , class... ArgumentTypes>
static const TypeInfo& System::MulticastDelegate< ReturnType(ArgumentTypes...)>::Type ( )
inlinestatic

Returns a reference to the TypeInfo object representing the MulticastDelegate class type information.