address_maker.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. //
  3. // Copyright (c) 2019-2022 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 address_maker_plugin_t
  10. *
  11. * \brief create actor's addresses
  12. *
  13. * The plugin is executed on very early stage of actor creation
  14. * to assing its main address as soon as possible.
  15. *
  16. * If additional addresses are needed by the actor, they can be
  17. * asked via the plugin.
  18. *
  19. */
  20. struct ROTOR_API address_maker_plugin_t : public plugin_base_t {
  21. using plugin_base_t::plugin_base_t;
  22. /** The plugin unique identity to allow further static_cast'ing*/
  23. static const void *class_identity;
  24. const void *identity() const noexcept override;
  25. void activate(actor_base_t *actor) noexcept override;
  26. void deactivate() noexcept override;
  27. /** \brief smart identity setter
  28. *
  29. * It can set the actor identity, and optionally append actor's main addres
  30. * to let it be something like "net::http10 0x7fc0d0013c60"
  31. *
  32. */
  33. void set_identity(std::string_view name, bool append_addr = true) noexcept;
  34. /** \brief creates additional actor address (on demand)
  35. *
  36. * This is just a shortcut method to create_address() of supervisor
  37. *
  38. */
  39. virtual address_ptr_t create_address() noexcept;
  40. /** generates default identity like "actor 0x7fc0d0013c60" */
  41. virtual void generate_identity() noexcept;
  42. };
  43. } // namespace rotor::plugin