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

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)
 
MulticastDelegateoperator= (const MulticastDelegate &o)
 
 MulticastDelegate (MulticastDelegate &&o)
 
MulticastDelegateoperator= (MulticastDelegate &&o)
 
 MulticastDelegate (Callback &&initial)
 
template<class T >
 MulticastDelegate (T arg)
 
bool empty () const
 
bool IsNull () const
 
bool operator== (const std::nullptr_t &) const
 
bool operator!= (const std::nullptr_t &) const
 
MulticastDelegateconnect (Callback callback)
 
template<class R , class... Args>
MulticastDelegateconnect (std::function< R(Args...)> f)
 
MulticastDelegateconnect (MulticastDelegate &other)
 
template<class MemberType , class ClassType >
MulticastDelegateconnect (MemberType ClassType::*member, ClassType *obj)
 
template<class MemberType , class ClassType >
MulticastDelegateconnect (MemberType ClassType::*member, const SharedPtr< ClassType > &obj)
 
MulticastDelegateoperator+= (Callback callback)
 
MulticastDelegatedisconnect (Callback callback)
 
template<class MemberType , class ClassType >
MulticastDelegatedisconnect (MemberType ClassType::*member, ClassType *obj)
 
template<class MemberType , class ClassType >
MulticastDelegatedisconnect (MemberType ClassType::*member, const SharedPtr< ClassType > &obj)
 
MulticastDelegatedisconnect (MulticastDelegate &other)
 
MulticastDelegateoperator-= (Callback callback)
 
bool operator== (const MulticastDelegate &other) const
 
bool operator!= (const MulticastDelegate &other) const
 
MulticastDelegatedisconnect_all_slots ()
 
void remove_empty_callbacks ()
 Cleans out contained callbacks that are empty (not actually calling anything). More...
 
ReturnType emit (ArgumentTypes... args)
 
ReturnType operator() (ArgumentTypes... args)
 
template<typename CallbackArgumentType >
SharedPtr< IAsyncResultBeginInvoke (ArgumentTypes... args, const AsyncCallback &member, const CallbackArgumentType &obj)
 
ReturnType EndInvoke (const SharedPtr< IAsyncResult > &)
 

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

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/6]

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/6]

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

Equivalent to defalt constructor.

◆ MulticastDelegate() [3/6]

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/6]

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/6]

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/6]

template<class ReturnType , class... ArgumentTypes>
template<class 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
Typeof the value to put to the delegate collection of the newly constructed instance; the type must be convertible to Callback type.

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 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

◆ connect() [3/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() [4/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() [5/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

◆ 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

◆ emit()

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

◆ 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

◆ 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 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!=() [2/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()()

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

Determines whether the delegate collection is empty.

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

◆ operator==() [2/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

◆ remove_empty_callbacks()

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

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