rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
rotor::plugin::plugin_base_t Struct Referenceabstract

base class for all actor plugins More...

#include <plugin_base.h>

Inheritance diagram for rotor::plugin::plugin_base_t:
rotor::plugin::address_maker_plugin_t rotor::plugin::child_manager_plugin_t rotor::plugin::delivery_plugin_base_t rotor::plugin::foreigners_support_plugin_t rotor::plugin::init_shutdown_plugin_t rotor::plugin::lifetime_plugin_t rotor::plugin::link_client_plugin_t rotor::plugin::link_server_plugin_t rotor::plugin::locality_plugin_t rotor::plugin::registry_plugin_t rotor::plugin::resources_plugin_t rotor::plugin::starter_plugin_t

Public Types

enum  reaction_t : unsigned { INIT = 0b00000001 , SHUTDOWN = 0b00000010 , SUBSCRIPTION = 0b00000100 , START = 0b00001000 }
 possible plugin's reactions on actor lifetime events
 
using reaction_underlying_t = std::underlying_type_t< reaction_t >
 the underlying type of reaction_t
 

Public Member Functions

 plugin_base_t ()=default
 default plugin ctor
 
 plugin_base_t (const plugin_base_t &)=delete
 copy ctor is not allowed
 
virtual const std::type_index & identity () const noexcept=0
 returns pointer, which uniquely identifiess plugin type
 
virtual void activate (actor_base_t *actor) noexcept
 invoked by actor upon initialization.
 
virtual void deactivate () noexcept
 deactivates plugin from an actor
 
virtual bool handle_init (message::init_request_t *message) noexcept
 polls plugin, whether it is done with initialization
 
virtual bool handle_shutdown (message::shutdown_request_t *message) noexcept
 polls plugin, whether it is done with shutdown
 
virtual void handle_start (message::start_trigger_t *message) noexcept
 polls plugin, whether it is done with start
 
virtual bool handle_subscription (message::subscription_t &message) noexcept
 polls plugin, whether it is done with subscription
 
virtual bool handle_unsubscription (const subscription_point_t &point, bool external) noexcept
 polls plugin, whether it is done with unsubscription
 
virtual bool forget_subscription (const subscription_point_t &point) noexcept
 remove subscription point from internal storage
 
virtual void forget_subscription (const subscription_info_ptr_t &info) noexcept
 commits unsubscription via supervisor
 
template<typename Plugin , typename Fn >
void with_casted (Fn &&fn, config_phase_t desired_phase=config_phase_t::INITIALIZING) noexcept
 invokes the callback if plugin type and phase mach
 
reaction_underlying_t get_reaction () const noexcept
 returns the current set of plugin reactions
 
void reaction_on (reaction_t value) noexcept
 turns on the specified reaction of the plugin
 
void reaction_off (reaction_t value) noexcept
 turns off the specified reaction of the plugin
 
template<typename T >
auto & access () noexcept
 generic non-public fields accessor
 

Static Public Attributes

static constexpr reaction_underlying_t REACTION_MASK = 0b00001111
 the bit mask for all reactions enabled
 

Protected Member Functions

template<typename Handler >
subscription_info_ptr_t subscribe (Handler &&handler, const address_ptr_t &address) noexcept
 subscribes plugin to the custom plugin handler on the specified address
 
template<typename Handler >
subscription_info_ptr_t subscribe (Handler &&handler) noexcept
 subscribes plugin to the custom plugin handler on the main actor address
 
extended_error_ptr_t make_error (const std::error_code &ec, const extended_error_ptr_t &next={}, const message_ptr_t &request={}) noexcept
 makes an error within the context of actor
 

Protected Attributes

actor_base_tactor
 non-owning actor pointer
 

Detailed Description

base class for all actor plugins

Member Function Documentation

◆ activate()

virtual void rotor::plugin::plugin_base_t::activate ( actor_base_t actor)
virtualnoexcept

invoked by actor upon initialization.

It it responsible for setting up reactions and further installation, e.g. messages subscriptions and may calling back actor's configuration (which can be postponed).

Before the activate is invoked, the plugin is in PREINIT phase, after the activate is called, the plugin is in INITIALIZING phase. This might be useful for early/late (double) plugin configuration in actor.

Reimplemented in rotor::plugin::address_maker_plugin_t, rotor::plugin::child_manager_plugin_t, rotor::plugin::delivery_plugin_base_t, rotor::plugin::foreigners_support_plugin_t, rotor::plugin::init_shutdown_plugin_t, rotor::plugin::lifetime_plugin_t, rotor::plugin::link_client_plugin_t, rotor::plugin::link_server_plugin_t, rotor::plugin::locality_plugin_t, rotor::plugin::registry_plugin_t, rotor::plugin::resources_plugin_t, and rotor::plugin::starter_plugin_t.

◆ deactivate()

virtual void rotor::plugin::plugin_base_t::deactivate ( )
virtualnoexcept

deactivates plugin from an actor

The method can be intercepted by descendants to do not deactivate too early, and called when needed.

The plugin_base_t implementation unsubscribes from all plugin subscriptions and when no subscription left commits deactivation to an actor.

Reimplemented in rotor::plugin::address_maker_plugin_t, rotor::plugin::child_manager_plugin_t, rotor::plugin::foreigners_support_plugin_t, rotor::plugin::lifetime_plugin_t, and rotor::plugin::starter_plugin_t.

◆ forget_subscription() [1/2]

virtual void rotor::plugin::plugin_base_t::forget_subscription ( const subscription_info_ptr_t info)
virtualnoexcept

commits unsubscription via supervisor

Used for foreign subscriptions.

◆ forget_subscription() [2/2]

virtual bool rotor::plugin::plugin_base_t::forget_subscription ( const subscription_point_t point)
virtualnoexcept

remove subscription point from internal storage

If there is no any subscription left, the plugin is deactivated

◆ handle_init()

virtual bool rotor::plugin::plugin_base_t::handle_init ( message::init_request_t message)
virtualnoexcept

polls plugin, whether it is done with initialization

The method is invoked only when init reaction was set on.

The true is returned, that means plugin is done with init and will not be longer polled in future.

Reimplemented in rotor::plugin::child_manager_plugin_t, rotor::plugin::starter_plugin_t, rotor::plugin::init_shutdown_plugin_t, rotor::plugin::link_client_plugin_t, rotor::plugin::registry_plugin_t, and rotor::plugin::resources_plugin_t.

◆ handle_shutdown()

virtual bool rotor::plugin::plugin_base_t::handle_shutdown ( message::shutdown_request_t message)
virtualnoexcept

polls plugin, whether it is done with shutdown

The method is invoked only when shutdown reaction was set on.

The true is returned, that means plugin is done with shutdown and will not be longer polled in future.

Reimplemented in rotor::plugin::child_manager_plugin_t, rotor::plugin::init_shutdown_plugin_t, rotor::plugin::lifetime_plugin_t, rotor::plugin::link_client_plugin_t, rotor::plugin::link_server_plugin_t, rotor::plugin::registry_plugin_t, and rotor::plugin::resources_plugin_t.

◆ handle_start()

virtual void rotor::plugin::plugin_base_t::handle_start ( message::start_trigger_t message)
virtualnoexcept

polls plugin, whether it is done with start

The method is invoked only when start reaction was set on.

The true is returned, that means plugin is done with start and will not be longer polled in future.

Reimplemented in rotor::plugin::child_manager_plugin_t, rotor::plugin::link_server_plugin_t, and rotor::plugin::starter_plugin_t.

◆ handle_subscription()

virtual bool rotor::plugin::plugin_base_t::handle_subscription ( message::subscription_t message)
virtualnoexcept

polls plugin, whether it is done with subscription

The method is invoked only when subscription reaction was set on.

The true is returned, that means plugin is done with start and will not be longer polled in future.

Reimplemented in rotor::plugin::starter_plugin_t.

◆ handle_unsubscription()

virtual bool rotor::plugin::plugin_base_t::handle_unsubscription ( const subscription_point_t point,
bool  external 
)
virtualnoexcept

polls plugin, whether it is done with unsubscription

All plugins are polled for unsubscription, no special handling is needed unless you know what your are doing.

The true is returned, that means plugin is done with unsubscription and will not be longer polled in future. The default is false.

Reimplemented in rotor::plugin::child_manager_plugin_t, and rotor::plugin::lifetime_plugin_t.

◆ identity()

◆ with_casted()

template<typename Plugin , typename Fn >
void rotor::plugin::plugin_base_t::with_casted ( Fn &&  fn,
config_phase_t  desired_phase = config_phase_t::INITIALIZING 
)
inlinenoexcept

invokes the callback if plugin type and phase mach

Upon successful match plugin is casted to the final type, and only then passed by reference to the callback. Used in the generic actors plugin configuration to inject custom (per-plugin-type) configuration.

Member Data Documentation

◆ actor

actor_base_t* rotor::plugin::plugin_base_t::actor
protected

non-owning actor pointer

It is non-null only after plugin activation.


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