|
DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
Typed base class for inter-module events to realize CRTP. More...
#include <Module.h>
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. | |
Public Types inherited from DynExp::InterModuleEventBase | |
| using | InterModuleEventPtrType = std::unique_ptr< InterModuleEventBase > |
Pointer type to store an inter-module event (InterModuleEventBase). | |
Public Member Functions | |
| InterModuleEvent ()=default | |
| Constructs an inter-module event. | |
| InterModuleEvent (const InterModuleEventBase &Other, ItemIDType CommunicatorID) | |
| Copy-constrcuts an inter-module event setting the CommunicatorID. | |
| virtual | ~InterModuleEvent () |
| virtual InterModuleEventPtrType | Clone (ItemIDType CommunicatorID) const override final |
| Creates a deep copy of this inter-module instance. | |
| virtual size_t | GetID () const noexcept override final |
| Returns the unique ID of this event type. | |
| virtual std::string | GetName () const override |
| Returns the name of this event type. | |
Public Member Functions inherited from DynExp::InterModuleEventBase | |
| InterModuleEventBase () | |
| Constructs an inter-module event. | |
| InterModuleEventBase (const InterModuleEventBase &Other, ItemIDType CommunicatorID) | |
| Copy-constrcuts an inter-module event setting the CommunicatorID. | |
| virtual | ~InterModuleEventBase ()=0 |
| auto | GetCommunicatorID () const noexcept |
| Getter for CommunicatorID. | |
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. Only to be called from ModuleBase. | |
Static Public Member Functions | |
| static auto | ID () |
| Getter for EventID. | |
| static size_t | Publish (InterModuleEventLibrary &Library) |
Publishes this event type to the InterModuleEventLibrary. This function should not be called manually. | |
| static InterModuleEventPtrType | Make () |
Factory function for events of type DerivedEvent. | |
| template<typename CallableT > | |
| static void | Register (const ModuleBase &Listener, CallableT EventFunc, ItemIDType CommunicatorID=ItemIDNotSet) |
Registers/Subscribes module Listener to the event with the event function EventFunc. Indirectly calls ModuleBase::AddRegisteredEvent(). If a module-communicator combination has already been registered, this registration is updated. | |
| static void | Deregister (const ModuleBase &Listener) |
Deregisters/unsubscribes module Listener from the event, regardless of the inter-module communicator instance used to register Listener to the event. Indirectly calls ModuleBase::RemoveRegisteredEvent(). | |
| static void | Deregister (const ModuleBase &Listener, ItemIDType CommunicatorID) |
Deregisters/unsubscribes module Listener from the event, removing a single registration for a particular module/inter-module communicator combination. Indirectly calls ModuleBase::RemoveRegisteredEvent(). | |
Private Member Functions | |
| virtual void | InvokeChild (ModuleInstance &Instance) const override final |
Invokes the event passing the receiving module's instance reference to it. Only to be called from ModuleBase. | |
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. | |
Static Private Attributes | |
| static const size_t | EventID = InterModuleEvent<DerivedEvent, EventFuncArgs...>::Publish(InterModuleEventLibrary::Get()) |
| Unique ID assigned to this inter-module event. | |
| static EventListenersType | Listeners |
Holds one EventListenersType instance per derived event, which manages all the subscribers of DerivedEvent. | |
Typed base class for inter-module events to realize CRTP.
| DerivedEvent | Type of the class derived from InterModuleEvent |
| ...EventFuncArgs | Types of the arguments to be passed to event functions registered/subscribed to DerivedEvent. |
| 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.
|
default |
Constructs an inter-module event.
|
inline |
Copy-constrcuts an inter-module event setting the CommunicatorID.
| Other | Inter-module event to copy. |
| CommunicatorID | ID of the DynExpInstr::InterModuleCommunicator instance that sends the event. |
|
inlinevirtual |
|
inlinefinaloverridevirtual |
Creates a deep copy of this inter-module instance.
| CommunicatorID | ID of the DynExpInstr::InterModuleCommunicator instance that sends the event. |
Implements DynExp::InterModuleEventBase.
|
inlinestatic |
Deregisters/unsubscribes module Listener from the event, regardless of the inter-module communicator instance used to register Listener to the event. Indirectly calls ModuleBase::RemoveRegisteredEvent().
| Listener | Module to deregister/unsubscribe. |
|
inlinestatic |
Deregisters/unsubscribes module Listener from the event, removing a single registration for a particular module/inter-module communicator combination. Indirectly calls ModuleBase::RemoveRegisteredEvent().
| Listener | Module to deregister/unsubscribe. |
| CommunicatorID | Refer to TypedEventListeners::Deregister(). |
|
inlinefinaloverridevirtualnoexcept |
Returns the unique ID of this event type.
Implements DynExp::InterModuleEventBase.
|
inlineoverridevirtual |
Returns the name of this event type.
Implements DynExp::InterModuleEventBase.
Reimplemented in DynExpModule::FinishedEvent, DynExpModule::SetFilenameEvent, DynExpModule::StartEvent, DynExpModule::StopEvent, and DynExpModule::TriggerEvent.
|
inlinestatic |
|
inlinefinaloverrideprivatevirtual |
Invokes the event passing the receiving module's instance reference to it. Only to be called from ModuleBase.
| Instance | Module instance handle. |
Implements DynExp::EventBase.
|
privatepure virtual |
Called by InvokeChild(). Override to call EventFunc with Instance as the first argument and with further arguments of type EventFuncArgs.
| Instance | Handle to the module thread's data of the module EventFunc is invoked on. |
| EventFunc | Event function to invoke. |
|
inlinestatic |
|
static |
Publishes this event type to the InterModuleEventLibrary. This function should not be called manually.
| Library | InterModuleEventLibrary instance to publish this event type to. |
|
inlinestatic |
Registers/Subscribes module Listener to the event with the event function EventFunc. Indirectly calls ModuleBase::AddRegisteredEvent(). If a module-communicator combination has already been registered, this registration is updated.
| CallableT | Type of the event function (member function of Listener's derived type) to invoke for Listener when the event is triggered. |
| Listener | Module to register/subscribe. |
| EventFunc | Event function to invoke on module Listener when the event is triggered. |
| CommunicatorID | Refer to TypedEventListeners::Register(). |
|
staticprivate |
Unique ID assigned to this inter-module event.
Initializes the static InterModuleEvent::EventID variable to the unique type ID of DerivedEvent. Also ensures that InterModuleEvent::Publish() is called for each inter-module event type.
|
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.