PLCnext API Documentation 25.0.2.69
Public Member Functions | Static Public Member Functions | List of all members
Arp::Base::Core::delegate< R(A...)> Class Template Reference

This class represents a delegate, that is a compound of an object reference and a member function pointer. More...

#include <delegate.hxx>

Public Member Functions

 delegate (std::nullptr_t) noexcept
 Constructs an empty delegate representing a nullptr.
 
template<class Lambda >
 delegate (Lambda f)
 Constructs a delegate through a lambda expression implicitly.
 
 delegate (void)
 The default constructor.
 
bool operator== (const delegate &rhs) const noexcept
 Compares this instance to the as argument passed rhs . More...
 
bool operator!= (const delegate &rhs) const noexcept
 Compares this instance to the as argument passed rhs . More...
 
bool operator== (std::nullptr_t const) const noexcept
 Compares this instance to a nullptr. More...
 
bool operator!= (std::nullptr_t const) const noexcept
 Compares this instance to a nullptr. More...
 
 operator bool () const noexcept
 Converts this instance explicitly to bool. More...
 
bool is_lambda (void) const
 Determines if this instance wraps a lambda expression or std::function More...
 
operator() (A... args) const
 The functor operator invokes the adapted callable target. More...
 
void reset (void)
 Resets this instance. More...
 
template<class C >
delegate< R(A...)> create (C *pObject, R(C::*pMethod)(A...)) noexcept
 Creates a delegate from a member function and object pointer. More...
 
template<class C >
delegate< R(A...)> create (C &object, R(C::*pMethod)(A...)) noexcept
 Creates a delegate from a member function and object reference. More...
 
template<class C >
delegate< R(A...)> create (const C *pObject, R(C::*pMethod)(A...) const) noexcept
 Creates a delegate from a const member function and const object pointer. More...
 
template<class C >
delegate< R(A...)> create (const C &object, R(C::*pMethod)(A...) const) noexcept
 Creates a delegate from a const member function and const object reference. More...
 

Static Public Member Functions

static delegate create (R(*const pFunction)(A...))
 Creates a delegate from a static function. More...
 
static delegate create (std::function< R(A...)> &&f)
 Creates a delegate from a lambda expression or std::function. More...
 
static delegate create (const std::function< R(A...)> &f)
 Creates a delegate from a lambda expression or std::function. More...
 
template<class C >
static delegate create (C *pObject, R(C::*pMethod)(A...)) noexcept
 
template<class C >
static delegate create (C &object, R(C::*pMethod)(A...)) noexcept
 
template<class C >
static delegate create (const C *pObject, R(C::*pMethod)(A...) const) noexcept
 
template<class C >
static delegate create (const C &object, R(C::*pMethod)(A...) const) noexcept
 

Detailed Description

template<class R, class ... A>
class Arp::Base::Core::delegate< R(A...)>

This class represents a delegate, that is a compound of an object reference and a member function pointer.

The generic type of a delegate just depends on the signature of the (member) function pointer but not on the type of the object on which the member function pointer is invoked. A delegate might be seen as a generalized function pointer (callback) in OOP design. It might invoke the following callable targets:

The make_delegate function shall be used to create delegates from these callable targets.

Member Function Documentation

◆ create() [1/7]

template<class R , class ... A>
template<class C >
delegate< R(A...)> Arp::Base::Core::delegate< R(A...)>::create ( C &  object,
R(C::*)(A...)  pMethod 
)
inlinenoexcept

Creates a delegate from a member function and object reference.

Parameters
pMethodThe member function to invoke.
objectThe object to invoke the member function on.
Returns
A new delegate instance created by the arguments.

◆ create() [2/7]

template<class R , class ... A>
template<class C >
delegate< R(A...)> Arp::Base::Core::delegate< R(A...)>::create ( C *  pObject,
R(C::*)(A...)  pMethod 
)
inlinenoexcept

Creates a delegate from a member function and object pointer.

Parameters
pMethodThe member function to invoke.
pObjectThe object pointer to invoke the member function on.
Returns
A new delegate instance created by the arguments.

◆ create() [3/7]

template<class R , class ... A>
template<class C >
delegate< R(A...)> Arp::Base::Core::delegate< R(A...)>::create ( const C &  object,
R(C::*)(A...) const  pMethod 
)
inlinenoexcept

Creates a delegate from a const member function and const object reference.

Parameters
pMethodThe member function to invoke.
objectThe object to invoke the member function on.
Returns
A new delegate instance created by the arguments.

◆ create() [4/7]

template<class R , class ... A>
template<class C >
delegate< R(A...)> Arp::Base::Core::delegate< R(A...)>::create ( const C *  pObject,
R(C::*)(A...) const  pMethod 
)
inlinenoexcept

Creates a delegate from a const member function and const object pointer.

Parameters
pMethodThe member function to invoke.
pObjectThe object pointer to invoke the member function on.
Returns
A new delegate instance created by the arguments.

◆ create() [5/7]

template<class R , class ... A>
delegate< R(A...)> Arp::Base::Core::delegate< R(A...)>::create ( const std::function< R(A...)> &  f)
inlinestatic

Creates a delegate from a lambda expression or std::function.

Parameters
fThe function to invoke.
Returns
A new delegate instance created by the arguments.

◆ create() [6/7]

template<class R , class ... A>
delegate< R(A...)> Arp::Base::Core::delegate< R(A...)>::create ( R(*)(A...)  pFunction)
inlinestatic

Creates a delegate from a static function.

Parameters
pFunctionThe static function to invoke.
Returns
A new delegate instance created by the arguments.

◆ create() [7/7]

template<class R , class ... A>
delegate< R(A...)> Arp::Base::Core::delegate< R(A...)>::create ( std::function< R(A...)> &&  f)
inlinestatic

Creates a delegate from a lambda expression or std::function.

Parameters
fThe function to invoke.
Returns
A new delegate instance created by the arguments.

◆ is_lambda()

template<class R , class ... A>
bool Arp::Base::Core::delegate< R(A...)>::is_lambda ( void  ) const
inline

Determines if this instance wraps a lambda expression or std::function

Returns
true if this instance is a lambda expression, otherwise false

◆ operator bool()

template<class R , class ... A>
Arp::Base::Core::delegate< R(A...)>::operator bool
inlinenoexcept

Converts this instance explicitly to bool.

Returns
false if this instance is empty (nullptr), otherwise true

◆ operator!=() [1/2]

template<class R , class ... A>
bool Arp::Base::Core::delegate< R(A...)>::operator!= ( const delegate< R(A...)> &  rhs) const
inlinenoexcept

Compares this instance to the as argument passed rhs .

Parameters
rhsThe argument to compare this instance to.
Returns
true if rhs is not equal, otherwise false

◆ operator!=() [2/2]

template<class R , class ... A>
bool Arp::Base::Core::delegate< R(A...)>::operator!= ( std::nullptr_t const  ) const
inlinenoexcept

Compares this instance to a nullptr.

Returns
true if nullptr is not equal, otherwise false

◆ operator()()

template<class R , class ... A>
R Arp::Base::Core::delegate< R(A...)>::operator() ( A...  args) const
inline

The functor operator invokes the adapted callable target.

Parameters
argsThe arguments to pass to the callable target with the same signature.
Returns
Returns the result of the invoked target.

◆ operator==() [1/2]

template<class R , class ... A>
bool Arp::Base::Core::delegate< R(A...)>::operator== ( const delegate< R(A...)> &  rhs) const
inlinenoexcept

Compares this instance to the as argument passed rhs .

Parameters
rhsThe argument to compare this instance to.
Returns
true if rhs is equal, otherwise false

◆ operator==() [2/2]

template<class R , class ... A>
bool Arp::Base::Core::delegate< R(A...)>::operator== ( std::nullptr_t const  ) const
inlinenoexcept

Compares this instance to a nullptr.

Returns
true if nullptr is equal, otherwise false

◆ reset()

template<class R , class ... A>
void Arp::Base::Core::delegate< R(A...)>::reset ( void  )
inline

Resets this instance.

After resetting this instance, this instance is not invokable any more. if(*this) will return false

.


The documentation for this class was generated from the following files: