9#include "../subscription.h"
10#include "rotor/messages.hpp"
14namespace rotor::plugin {
16enum class config_phase_t { PREINIT = 0b01, INITIALIZING = 0b10 };
29 SHUTDOWN = 0b00000010,
30 SUBSCRIPTION = 0b00000100,
48 virtual const std::type_index &
identity() const noexcept = 0;
146 template <typename Plugin, typename Fn>
147 void with_casted(Fn &&fn, config_phase_t desired_phase = config_phase_t::INITIALIZING) noexcept {
148 int phase_match =
static_cast<int>(phase) &
static_cast<int>(desired_phase);
149 if (phase_match &&
identity() == Plugin::class_identity) {
150 auto &
final =
static_cast<Plugin &
>(*this);
164 template <
typename T>
auto &
access() noexcept;
168 template <typename Handler>
187 reaction_underlying_t reaction = 0;
188 config_phase_t phase = config_phase_t::PREINIT;
namespace for rotor core messages (which just transform payloads)
Definition messages.hpp:317
intrusive_ptr_t< extended_error_t > extended_error_ptr_t
intrusive pointer to extended error type
Definition extended_error.h:25
intrusive_ptr_t< message_base_t > message_ptr_t
intrusive pointer for message
Definition message.h:118
intrusive_ptr_t< address_t > address_ptr_t
intrusive pointer for address
Definition address.hpp:57
intrusive_ptr_t< subscription_info_t > subscription_info_ptr_t
intrusive pointer for subscription_info_t
Definition subscription_point.h:121
universal primitive of concurrent computation
Definition actor_base.h:47
std::underlying_type_t< reaction_t > reaction_underlying_t
the underlying type of reaction_t
Definition plugin_base.h:35
virtual bool handle_unsubscription(const subscription_point_t &point, bool external) noexcept
polls plugin, whether it is done with unsubscription
reaction_t
possible plugin's reactions on actor lifetime events
Definition plugin_base.h:27
reaction_underlying_t get_reaction() const noexcept
returns the current set of plugin reactions
Definition plugin_base.h:156
virtual void activate(actor_base_t *actor) noexcept
invoked by actor upon initialization.
virtual bool handle_shutdown(message::shutdown_request_t *message) noexcept
polls plugin, whether it is done with shutdown
auto & access() noexcept
generic non-public fields accessor
plugin_base_t()=default
default plugin ctor
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
void reaction_on(reaction_t value) noexcept
turns on the specified reaction of the plugin
Definition plugin_base.h:159
actor_base_t * actor
non-owning actor pointer
Definition plugin_base.h:179
virtual const std::type_index & identity() const noexcept=0
returns pointer, which uniquely identifiess plugin type
virtual void handle_start(message::start_trigger_t *message) noexcept
polls plugin, whether it is done with start
virtual bool handle_init(message::init_request_t *message) noexcept
polls plugin, whether it is done with initialization
void reaction_off(reaction_t value) noexcept
turns off the specified reaction of the plugin
Definition plugin_base.h:162
virtual void deactivate() noexcept
deactivates plugin from an actor
virtual bool forget_subscription(const subscription_point_t &point) noexcept
remove subscription point from internal storage
virtual bool handle_subscription(message::subscription_t &message) noexcept
polls plugin, whether it is done with subscription
subscription_info_ptr_t subscribe(Handler &&handler, const address_ptr_t &address) noexcept
subscribes plugin to the custom plugin handler on the specified address
Definition supervisor.h:415
static constexpr reaction_underlying_t REACTION_MASK
the bit mask for all reactions enabled
Definition plugin_base.h:38
void with_casted(Fn &&fn, config_phase_t desired_phase=config_phase_t::INITIALIZING) noexcept
invokes the callback if plugin type and phase mach
Definition plugin_base.h:147
plugin_base_t(const plugin_base_t &)=delete
copy ctor is not allowed
list of subscription_info_ptr_t with possibility to find via subscription_point_t
Definition subscription_point.h:126
pair of handler_base_t linked to particular address_t
Definition subscription_point.h:49
Holds and classifies message handlers on behalf of supervisor.
Definition subscription.h:30