PLCnext API Documentation 25.0.2.69
Public Member Functions | List of all members
Arp::Base::Core::event< Args > Class Template Reference

Use this class to register and invoke several delegates (function pointer in OOP design). More...

#include <event.hxx>

Public Member Functions

 event (void)
 Constructs a event instance. More...
 
eventoperator+= (delegate_type &&rhs)
 Adds a delegate to this event. More...
 
eventoperator+= (const delegate_type &rhs)
 Adds a delegate to this event. More...
 
eventoperator-= (const delegate_type &rhs)
 Removes a delegate from this event. More...
 
void operator() (Args... args) const
 Fires this event instance. More...
 
bool is_empty (void) const
 Checks if this event has any delegates to be invoked. More...
 

Detailed Description

template<class ... Args>
class Arp::Base::Core::event< Args >

Use this class to register and invoke several delegates (function pointer in OOP design).

The type of this generic event class depends only on the signature of the delegates to be invoked, but not on the type of the objects on which the member function pointers of the delegates are invoked.

This class is leaned on the event mechanism of .NET.

See also
delegate

A delegate is a function pointer (callback) in OOP design, which only 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.

Constructor & Destructor Documentation

◆ event()

template<class ... Args>
Arp::Base::Core::event< Args >::event ( void  )
inlinedefault

Constructs a event instance.

Template Parameters
ArgsThe argument types of this event.

Member Function Documentation

◆ is_empty()

template<class ... Args>
bool Arp::Base::Core::event< Args >::is_empty ( void  ) const
inline

Checks if this event has any delegates to be invoked.

Returns
true if this event has any delegates to be invoked, otherwise false.
Template Parameters
ArgsThe argument types of this event.

◆ operator()()

template<class ... Args>
void Arp::Base::Core::event< Args >::operator() ( Args...  args) const
inline

Fires this event instance.

Parameters
argsThe arguments passed to the invoked delegates.

All added delegates are invoked in reversed insertion order by passing the arguments accordingly. The invocation in reversed order ensures backward compatibility.

Template Parameters
ArgsThe argument types of this event.

◆ operator+=() [1/2]

template<class ... Args>
event< Args... > & Arp::Base::Core::event< Args >::operator+= ( const delegate_type rhs)
inline

Adds a delegate to this event.

Parameters
rhsThe delegate to add to this event.
Returns
This instance as reference.
Template Parameters
ArgsThe argument types of this event.

◆ operator+=() [2/2]

template<class ... Args>
event< Args... > & Arp::Base::Core::event< Args >::operator+= ( delegate_type &&  rhs)
inline

Adds a delegate to this event.

Parameters
rhsThe delegate to add to this event.
Returns
This instance as reference.
Template Parameters
ArgsThe argument types of this event.

◆ operator-=()

template<class ... Args>
event< Args... > & Arp::Base::Core::event< Args >::operator-= ( const delegate_type rhs)
inline

Removes a delegate from this event.

Parameters
rhsThe delegate to remove from this event.
Returns
This instance as reference.
Template Parameters
ArgsThe argument types of this event.

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