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

Public Member Functions

 Delegate ()=default
 Default constructor. Constructs the delegate object that does not point to anything. More...
 
 Delegate (const Delegate &)=delete
 
Delegateoperator= (const Delegate &)=delete
 
 Delegate (Delegate &&o)
 
Delegateoperator= (Delegate &&o)
 
template<class T >
 Delegate (T function, typename std::enable_if<!std::is_bind_expression< T >::value >::type *=0)
 
template<class T >
 Delegate (T function, typename std::enable_if< std::is_bind_expression< T >::value >::type *=0)
 
template<class T >
 Delegate (int functor_tag, T &functor)
 
template<class T >
 Delegate (long functor_tag, T &&functor)
 
template<class MemberType , class ClassType >
 Delegate (MemberType ClassType::*member, ClassType *obj)
 
template<class MemberType , class ClassType >
 Delegate (MemberType ClassType::*member, const SharedPtr< ClassType > &obj)
 
template<class R , class... Args>
 Delegate (std::function< R(Args...)> f)
 
ReturnType operator() (ArgumentTypes... args)
 
bool operator== (const Delegate &f) const
 
bool Empty ()
 

Detailed Description

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

Represents a pointer to a function, method or a function object. 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
ReturnTypeThe return type of a function, method or a function object pointer to which is represented by the class
ArgumentTypesThe argument list of a function, method or a function object pointer to which is represented by the class

Constructor & Destructor Documentation

◆ Delegate() [1/10]

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

Default constructor. Constructs the delegate object that does not point to anything.

◆ Delegate() [2/10]

template<class ReturnType , class... ArgumentTypes>
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate ( const Delegate< ReturnType(ArgumentTypes...)> &  )
delete

◆ Delegate() [3/10]

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

Moving copy constructor. Takes the ownership of an entity pointed to by the specified delegate.

Parameters
oThe Delegate object to move the pointed to entity from

◆ Delegate() [4/10]

template<class ReturnType , class... ArgumentTypes>
template<class T >
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate ( function,
typename std::enable_if<!std::is_bind_expression< T >::value >::type *  = 0 
)
inline

Constructor. Constructs a delegate object from the specified pointer to free function or static method.

Parameters
functionPointer to a function or a static method that will be pointed to by the newly created Delegate instance
Template Parameters
Thetype of the function or static method pointer accepted by the constructor as an argument

◆ Delegate() [5/10]

template<class ReturnType , class... ArgumentTypes>
template<class T >
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate ( function,
typename std::enable_if< std::is_bind_expression< T >::value >::type *  = 0 
)
inline

Constructor. Constructs a delegate from the specified pointer to the function object generated by std::bind().

Parameters
functionPointer to a "bind expression" - a function pointer generated by std::bind() - that will be pointed to by the newly created Delegate instance
Template Parameters
Thetype of the function object generated by std::bind() accepted by the constructor as an argument

◆ Delegate() [6/10]

template<class ReturnType , class... ArgumentTypes>
template<class T >
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate ( int  functor_tag,
T &  functor 
)
inline

Constructor. Constructs a delegate from the specified function object.

Parameters
functor_tagA dummy integer value; this argument is used to resolve ambiguity
functorA function object that the newly constructed delegate will point to
Template Parameters
TThe type of the function object accepted by the constructor as an argument

◆ Delegate() [7/10]

template<class ReturnType , class... ArgumentTypes>
template<class T >
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate ( long  functor_tag,
T &&  functor 
)
inline

Moving constructor. Constructs a delegate from the specified function object.

Parameters
functor_tagA dummy integer value; this argument is used to resolve ambiguity
functorA function object that the newly constructed delegate will point to
Template Parameters
TThe type of the function object accepted by the constructor as an argument

◆ Delegate() [8/10]

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

Constructor. Constructs a delegate that points to the specified non-static method of the specified object.

Parameters
memberA pointer to the non-static method that the newly created delegate will point to
objA pointer to an object member method of which will be pointed to by the newly created delegate
Template Parameters
MemberTypeThe type of the non-static method that the constructor accepts as an argument
ClassTypeThe type of the object accepted by the constructor as an argument

◆ Delegate() [9/10]

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

Constructor. Constructs a delegate that points to the specified non-static method of the specified object.

Parameters
memberA pointer to the non-static method that the newly created delegate will point to
objA shard pointer to an object member method of which will be pointed to by the newly created delegate
Template Parameters
MemberTypeThe type of the non-static method that the constructor accepts as an argument
ClassTypeThe type of the object accepted by the constructor as an argument

◆ Delegate() [10/10]

template<class ReturnType , class... ArgumentTypes>
template<class R , class... Args>
System::Delegate< ReturnType(ArgumentTypes...)>::Delegate ( std::function< R(Args...)>  f)
inline

Constructs a delegate object that points to an std::function function object.

Parameters
fA function object to be pointed to by the newly created delegate object
Template Parameters
RThe return type of the function object accepted by the constructor as an argument
ArgsThe argument list of the function object accepted by the constructor as an argument

Member Function Documentation

◆ Empty()

template<class ReturnType , class... ArgumentTypes>
bool System::Delegate< ReturnType(ArgumentTypes...)>::Empty ( )
inline

Determines if the current delegate object is empty, e.g. does not point to any entity.

Returns
True if current delegate object does not point to a function, a method of a function object, otherwise - false.

◆ operator()()

template<class ReturnType , class... ArgumentTypes>
ReturnType System::Delegate< ReturnType(ArgumentTypes...)>::operator() ( ArgumentTypes...  args)
inline

Invokes a function, method or a function object that is pointed to by current delegate object.

Parameters
argsArguments to pass to the invoked entity
Returns
The value returned by invoked entity

◆ operator=() [1/2]

template<class ReturnType , class... ArgumentTypes>
Delegate& System::Delegate< ReturnType(ArgumentTypes...)>::operator= ( const Delegate< ReturnType(ArgumentTypes...)> &  )
delete

◆ operator=() [2/2]

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

Moving assignment operator. Takes the ownership of an entity pointed to by the specified delegate.

Parameters
oThe Delegate object to move the pointed to entity from
Returns
A reference to the self

◆ operator==()

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

Compares two delegate objects to check if they point to the same entity.

Parameters
fA delegate object to compare current delegate object with
Returns
True if both delegates point the same entity, otherwise - false