access.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // Copyright (c) 2019-2021 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 internal_infos {};
  16. struct mine_handlers {};
  17. struct actors_map {};
  18. struct points {};
  19. struct locality_leader {};
  20. struct parent_supervisor {};
  21. struct registry {};
  22. struct queue {};
  23. struct own_subscriptions {};
  24. struct request_map {};
  25. struct resources {};
  26. struct last_req_id {};
  27. struct promises {};
  28. struct discovery_map {};
  29. struct forget_link {};
  30. struct tag {};
  31. struct timers_map {};
  32. } // namespace to
  33. } // namespace
  34. bool empty(rotor::subscription_t &subs) noexcept;
  35. } // namespace rotor::test
  36. namespace rotor {
  37. template <> inline auto &actor_base_t::access<test::to::timers_map>() noexcept { return timers_map; }
  38. template <> inline auto &actor_base_t::access<test::to::state>() noexcept { return state; }
  39. template <> inline auto &actor_base_t::access<test::to::resources>() noexcept { return resources; }
  40. template <> inline auto rotor::actor_base_t::access<test::to::get_plugin, const void *>(const void *identity) noexcept {
  41. return get_plugin(identity);
  42. }
  43. template <>
  44. inline auto rotor::actor_base_t::access<test::to::on_timer_trigger, request_id_t, bool>(request_id_t request_id,
  45. bool cancelled) noexcept {
  46. on_timer_trigger(request_id, cancelled);
  47. }
  48. template <> inline auto rotor::subscription_info_t::access<test::to::tag, const void *>(const void *arg) noexcept {
  49. return tag(arg);
  50. }
  51. template <> inline auto &rotor::subscription_t::access<test::to::internal_infos>() noexcept { return internal_infos; }
  52. template <> inline auto &rotor::subscription_t::access<test::to::mine_handlers>() noexcept { return mine_handlers; }
  53. template <> inline auto &rotor::plugin::plugin_base_t::access<test::to::own_subscriptions>() noexcept {
  54. return own_subscriptions;
  55. }
  56. template <> inline auto &plugin::child_manager_plugin_t::access<test::to::actors_map>() noexcept { return actors_map; }
  57. template <> inline auto &plugin::lifetime_plugin_t::access<test::to::points>() noexcept { return points; }
  58. template <> inline auto &plugin::resources_plugin_t::access<test::to::resources>() noexcept { return resources; }
  59. template <> inline auto &plugin::registry_plugin_t::access<test::to::discovery_map>() noexcept { return discovery_map; }
  60. template <> inline auto &rotor::supervisor_t::access<test::to::locality_leader>() noexcept { return locality_leader; }
  61. template <> inline auto &rotor::supervisor_t::access<test::to::parent_supervisor>() noexcept { return parent; }
  62. template <> inline auto &rotor::supervisor_t::access<test::to::registry>() noexcept { return registry_address; }
  63. template <> inline auto &rotor::supervisor_t::access<test::to::queue>() noexcept { return queue; }
  64. template <> inline auto &rotor::supervisor_t::access<test::to::request_map>() noexcept { return request_map; }
  65. template <> inline auto &rotor::supervisor_t::access<test::to::last_req_id>() noexcept { return last_req_id; }
  66. template <> inline auto &rotor::registry_t::access<test::to::promises>() noexcept { return promises; }
  67. } // namespace rotor