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

Use this class to register and invoke several delegates (function pointer in OOP design) in synced manner, so that it might be used in asynchronous context. More...

#include <synced_event.hxx>

Public Member Functions

 synced_event (void)
 Constructs a synced_event instance. More...
 
synced_eventoperator+= (delegate_type &&rhs)
 Adds a delegate to this event. More...
 
synced_eventoperator+= (const delegate_type &rhs)
 Adds a delegate to this event. More...
 
synced_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...
 
size_t count (void) const
 Gets the number of delegates to be invoked. More...
 

Detailed Description

template<class M, class ... Args>
class Arp::Base::Core::synced_event< M, Args >

Use this class to register and invoke several delegates (function pointer in OOP design) in synced manner, so that it might be used in asynchronous context.

The type of this generic synced_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 mechansim 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

◆ synced_event()

template<class M , class ... Args>
Arp::Base::Core::synced_event< M, Args >::synced_event ( void  )
inlinedefault

Constructs a synced_event instance.

Template Parameters
ArgsThe argument types of this event.
MThe mutex tpye to be used for synchronization. It shall provide a nested lock guard type called LockGuard.

Member Function Documentation

◆ count()

template<class M , class ... Args>
size_t Arp::Base::Core::synced_event< M, Args >::count ( void  ) const
inline

Gets the number of delegates to be invoked.

Returns
The number of delegates to be invoked..
Template Parameters
MThe mutex tpye to be used for synchronization. It shall provide a nested lock guard type called LockGuard.

◆ is_empty()

template<class M , class ... Args>
bool Arp::Base::Core::synced_event< M, 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.
MThe mutex tpye to be used for synchronization. It shall provide a nested lock guard type called LockGuard.

◆ operator()()

template<class M , class ... Args>
void Arp::Base::Core::synced_event< M, 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.
MThe mutex tpye to be used for synchronization. It shall provide a nested lock guard type called LockGuard.

◆ operator+=() [1/2]

template<class M , class ... Args>
synced_event< M, Args... > & Arp::Base::Core::synced_event< M, 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.
MThe mutex tpye to be used for synchronization. It shall provide a nested lock guard type called LockGuard.

◆ operator+=() [2/2]

template<class M , class ... Args>
synced_event< M, Args... > & Arp::Base::Core::synced_event< M, 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.
MThe mutex tpye to be used for synchronization. It shall provide a nested lock guard type called LockGuard.

◆ operator-=()

template<class M , class ... Args>
synced_event< M, Args... > & Arp::Base::Core::synced_event< M, 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.
MThe mutex tpye to be used for synchronization. It shall provide a nested lock guard type called LockGuard.

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