access.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // Copyright (c) 2019-2023 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
  3. //
  4. // Distributed under the MIT Software License
  5. //
  6. #pragma once
  7. #include "rotor.hpp"
  8. #include "rotor/registry.h"
  9. namespace rotor::test {
  10. namespace {
  11. namespace to {
  12. struct get_plugin {};
  13. struct on_timer_trigger {};
  14. struct state {};
  15. struct active_requests {};
  16. struct internal_infos {};
  17. struct mine_handlers {};
  18. struct actors_map {};
  19. struct points {};
  20. struct locality_leader {};
  21. struct parent_supervisor {};
  22. struct supervisor {};
  23. struct registry {};
  24. struct queue {};
  25. struct inbound_queue {};
  26. struct own_subscriptions {};
  27. struct request_map {};
  28. struct resources {};
  29. struct last_req_id {};
  30. struct promises {};
  31. struct discovery_map {};
  32. struct forget_link {};
  33. struct tag {};
  34. struct timers_map {};
  35. } // namespace to
  36. } // namespace
  37. bool empty(rotor::subscription_t &subs) noexcept;
  38. } // namespace rotor::test
  39. namespace rotor {
  40. template <> inline auto &actor_base_t::access<test::to::timers_map>() noexcept { return timers_map; }
  41. template <> inline auto &actor_base_t::access<test::to::state>() noexcept { return state; }
  42. template <> inline auto &actor_base_t::access<test::to::active_requests>() noexcept { return active_requests; }
  43. template <> inline auto &actor_base_t::access<test::to::resources>() noexcept { return resources; }
  44. template <>
  45. inline auto
  46. rotor::actor_base_t::access<test::to::get_plugin, const std::type_index *>(const std::type_index *identity_) noexcept {
  47. return get_plugin(*identity_);
  48. }
  49. template <>
  50. inline auto rotor::actor_base_t::access<test::to::on_timer_trigger, request_id_t, bool>(request_id_t request_id,
  51. bool cancelled) noexcept {
  52. on_timer_trigger(request_id, cancelled);
  53. }
  54. template <> inline auto rotor::subscription_info_t::access<test::to::tag, const void *>(const void *arg) noexcept {
  55. return tag(arg);
  56. }
  57. template <> inline auto &rotor::subscription_t::access<test::to::internal_infos>() noexcept { return internal_infos; }
  58. template <> inline auto &rotor::subscription_t::access<test::to::mine_handlers>() noexcept { return mine_handlers; }
  59. template <> inline auto &rotor::plugin::plugin_base_t::access<test::to::own_subscriptions>() noexcept {
  60. return own_subscriptions;
  61. }
  62. template <> inline auto &plugin::child_manager_plugin_t::access<test::to::actors_map>() noexcept { return actors_map; }
  63. template <> inline auto &plugin::lifetime_plugin_t::access<test::to::points>() noexcept { return points; }
  64. template <> inline auto &plugin::resources_plugin_t::access<test::to::resources>() noexcept { return resources; }
  65. template <> inline auto &plugin::registry_plugin_t::access<test::to::discovery_map>() noexcept { return discovery_map; }
  66. template <> inline auto &rotor::supervisor_t::access<test::to::locality_leader>() noexcept { return locality_leader; }
  67. template <> inline auto &rotor::supervisor_t::access<test::to::parent_supervisor>() noexcept { return parent; }
  68. template <> inline auto &rotor::supervisor_t::access<test::to::registry>() noexcept { return registry_address; }
  69. template <> inline auto &rotor::supervisor_t::access<test::to::queue>() noexcept { return queue; }
  70. template <> inline auto &rotor::supervisor_t::access<test::to::inbound_queue>() noexcept { return inbound_queue; }
  71. template <> inline auto &rotor::supervisor_t::access<test::to::request_map>() noexcept { return request_map; }
  72. template <> inline auto &rotor::supervisor_t::access<test::to::last_req_id>() noexcept { return last_req_id; }
  73. template <> inline auto &rotor::registry_t::access<test::to::promises>() noexcept { return promises; }
  74. template <> inline auto &rotor::system_context_t::access<test::to::supervisor>() noexcept { return supervisor; }
  75. } // namespace rotor