25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.4 KiB

  1. #pragma once
  2. #include <ecs/config.h>
  3. #include <ecs/core/utils/scope_guard.h>
  4. #include "./step_proxy.h"
  5. beg_namespace_ecs_context
  6. {
  7. namespace __impl
  8. {
  9. template<typename T_settings>
  10. struct context_t
  11. : public step_proxy_t<T_settings>
  12. {
  13. private:
  14. using settings_type = T_settings;
  15. using step_proxy_type = step_proxy_t<settings_type>;
  16. private:
  17. void refresh()
  18. {
  19. }
  20. public:
  21. template<typename T_step_func>
  22. inline decltype(auto) step(T_step_func&& step_func)
  23. {
  24. ecs_make_scope_guard([this]{
  25. this->refresh();
  26. });
  27. std::forward<T_step_func>(step_func)(static_cast<step_proxy_type&>(*this));
  28. }
  29. };
  30. struct make_t
  31. {
  32. template<typename T_settings>
  33. constexpr decltype(auto) operator()(T_settings) const noexcept
  34. { return context_t<T_settings> { }; }
  35. };
  36. struct make_uptr_t
  37. {
  38. template<typename T_settings>
  39. constexpr decltype(auto) operator()(T_settings) const noexcept
  40. { return std::make_unique<context_t<T_settings>>(); }
  41. };
  42. }
  43. constexpr decltype(auto) make = __impl::make_t { };
  44. constexpr decltype(auto) make_uptr = __impl::make_uptr_t { };
  45. }
  46. end_namespace_ecs_context