DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs > Class Template Referenceabstract

Typed base class for inter-module events to realize CRTP. More...

+ Inheritance diagram for DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >:

Public Types

using EventListenersType = TypedEventListeners< EventFuncArgs... >
 Type of the manager of event listeners, which relates event listeners (instances of ModuleBase) to their event functions. The event functions expect EventFuncArgs as further arguments. More...
 

Public Member Functions

 InterModuleEvent ()=default
 
virtual ~InterModuleEvent ()
 
- Public Member Functions inherited from DynExp::InterModuleEventBase
 InterModuleEventBase ()=default
 
virtual ~InterModuleEventBase ()=0
 
- Public Member Functions inherited from DynExp::EventBase
 EventBase ()=default
 
virtual ~EventBase ()=0
 
void Invoke (ModuleInstance &Instance) const
 Invokes the event passing the receiving module's instance reference to it. More...
 

Static Public Member Functions

template<typename CallableT >
static void Register (const ModuleBase &Listener, CallableT EventFunc)
 Registers/Subscribes module Listener to the event with the event function EventFunc. Indirectly calls ModuleBase::AddRegisteredEvent(). More...
 
static void Deregister (const ModuleBase &Listener)
 Deregisters/unsubscribes module Listener from the event. Indirectly calls ModuleBase::RemoveRegisteredEvent(). More...
 

Private Member Functions

virtual void InvokeChild (ModuleInstance &Instance) const override final
 Invokes the event passing the receiving module's instance reference to it. More...
 
Override

Override by derived classes.

virtual void InvokeWithParamsChild (ModuleInstance &Instance, EventListenersType::EventFunctionType EventFunc) const =0
 Called by InvokeChild(). Override to call EventFunc with Instance as the first argument and with further arguments of type EventFuncArgs. More...
 

Static Private Attributes

static EventListenersType Listeners
 Holds one EventListenersType instance per derived event, which manages all the subscribers of DerivedEvent. More...
 

Detailed Description

template<typename DerivedEvent, typename... EventFuncArgs>
class DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >

Typed base class for inter-module events to realize CRTP.

Template Parameters
DerivedEventType of the class derived from InterModuleEvent
...EventFuncArgsTypes of the arguments to be passed to event functions registered/subscribed to DerivedEvent.

Definition at line 1010 of file Module.h.

Member Typedef Documentation

◆ EventListenersType

template<typename DerivedEvent , typename... EventFuncArgs>
using DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::EventListenersType = TypedEventListeners<EventFuncArgs...>

Type of the manager of event listeners, which relates event listeners (instances of ModuleBase) to their event functions. The event functions expect EventFuncArgs as further arguments.

Definition at line 1018 of file Module.h.

Constructor & Destructor Documentation

◆ InterModuleEvent()

template<typename DerivedEvent , typename... EventFuncArgs>
DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::InterModuleEvent ( )
default

◆ ~InterModuleEvent()

template<typename DerivedEvent , typename... EventFuncArgs>
virtual DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::~InterModuleEvent ( )
inlinevirtual

Definition at line 1021 of file Module.h.

Member Function Documentation

◆ Deregister()

template<typename DerivedEvent , typename... EventFuncArgs>
static void DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::Deregister ( const ModuleBase Listener)
inlinestatic

Deregisters/unsubscribes module Listener from the event. Indirectly calls ModuleBase::RemoveRegisteredEvent().

Parameters
ListenerModule to deregister/unsubscribe.

Definition at line 1034 of file Module.h.

◆ InvokeChild()

template<typename DerivedEvent , typename... EventFuncArgs>
virtual void DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::InvokeChild ( ModuleInstance Instance) const
inlinefinaloverrideprivatevirtual

Invokes the event passing the receiving module's instance reference to it.

Parameters
InstanceModule instance handle.

Implements DynExp::EventBase.

Definition at line 1037 of file Module.h.

◆ InvokeWithParamsChild()

template<typename DerivedEvent , typename... EventFuncArgs>
virtual void DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::InvokeWithParamsChild ( ModuleInstance Instance,
EventListenersType::EventFunctionType  EventFunc 
) const
privatepure virtual

Called by InvokeChild(). Override to call EventFunc with Instance as the first argument and with further arguments of type EventFuncArgs.

Parameters
InstanceHandle to the module thread's data of the module EventFunc is invoked on.
EventFuncEvent function to invoke.

◆ Register()

template<typename DerivedEvent , typename... EventFuncArgs>
template<typename CallableT >
static void DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::Register ( const ModuleBase Listener,
CallableT  EventFunc 
)
inlinestatic

Registers/Subscribes module Listener to the event with the event function EventFunc. Indirectly calls ModuleBase::AddRegisteredEvent().

Template Parameters
CallableTType of the event function (member function of Listener's derived type) to invoke for Listener when the event is triggered.
Parameters
ListenerModule to register/subscribe.
EventFuncEvent function to invoke on module Listener when the event is triggered.

Definition at line 1028 of file Module.h.

Member Data Documentation

◆ Listeners

template<typename DerivedEvent , typename... EventFuncArgs>
InterModuleEvent< DerivedEvent, EventFuncArgs... >::EventListenersType DynExp::InterModuleEvent< DerivedEvent, EventFuncArgs >::Listeners
staticprivate

Holds one EventListenersType instance per derived event, which manages all the subscribers of DerivedEvent.

Instantiate the respective static InterModuleEvent::Listeners variable to avoid linker errors.

Definition at line 1063 of file Module.h.


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