starter.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. //
  3. // Copyright (c) 2019-2020 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
  4. //
  5. // Distributed under the MIT Software License
  6. //
  7. #include "plugin_base.h"
  8. namespace rotor::plugin {
  9. /** \struct starter_plugin_t
  10. *
  11. * \brief allows custom (actor) subscriptions and it is responsibe
  12. * for starting actor when it receives {@link message::start_trigger_t}.
  13. *
  14. */
  15. struct starter_plugin_t : public plugin_base_t {
  16. using plugin_base_t::plugin_base_t;
  17. /** The plugin unique identity to allow further static_cast'ing*/
  18. static const void *class_identity;
  19. const void *identity() const noexcept override;
  20. void activate(actor_base_t *actor) noexcept override;
  21. void deactivate() noexcept override;
  22. /** \brief subscribes *actor* handler on main actor address */
  23. template <typename Handler> subscription_info_ptr_t subscribe_actor(Handler &&handler) noexcept;
  24. /** \brief subscribes *actor* handler on arbitrary address */
  25. template <typename Handler>
  26. subscription_info_ptr_t subscribe_actor(Handler &&handler, const address_ptr_t &addr) noexcept;
  27. bool handle_init(message::init_request_t *) noexcept override;
  28. void handle_start(message::start_trigger_t *message) noexcept override;
  29. bool handle_subscription(message::subscription_t &message) noexcept override;
  30. /** \brief start mesage reaction */
  31. void on_start(message::start_trigger_t &message) noexcept;
  32. private:
  33. subscription_container_t tracked;
  34. bool configured = false;
  35. };
  36. } // namespace rotor::plugin