您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

95 行
2.6 KiB

  1. #pragma once
  2. #include <ecs/config.h>
  3. #include <ecs/core/system/data_proxy/base.h>
  4. namespace ecs {
  5. namespace core {
  6. namespace system {
  7. namespace data_proxy {
  8. /**
  9. * data proxy to execute system non-parallel
  10. *
  11. * @tparam T_context context type of the ECS environment
  12. * @tparam T_instance system instance type
  13. */
  14. template<typename T_context, typename T_instance>
  15. struct single
  16. : public base<T_context, T_instance>
  17. {
  18. private:
  19. using context_type = T_context;
  20. using instance_type = T_instance;
  21. using base_type = base<context_type, instance_type>;
  22. public:
  23. using base_type::base_type;
  24. /**
  25. * execute the given function for all entities handled by this data proxy
  26. *
  27. * @tparam T_func function type to execute
  28. *
  29. * @param func function to execute
  30. */
  31. template<typename T_func>
  32. inline void for_entities(T_func&& func) const;
  33. /**
  34. * execute the given function for all entities not handled by this data proxy
  35. *
  36. * @tparam T_func function type to execute
  37. *
  38. * @param func function to execute
  39. */
  40. template<typename T_func>
  41. inline void for_other_entities(T_func&& func) const;
  42. /**
  43. * execute the given function for all entities
  44. *
  45. * @tparam T_func function type to execute
  46. *
  47. * @param func function to execute
  48. */
  49. template<typename T_func>
  50. inline void for_all_entities(T_func&& func) const;
  51. /**
  52. * get the number of entities handled by this data proxy
  53. *
  54. * @return number of entities handle by this data proxy
  55. */
  56. inline size_t entity_count() const;
  57. /**
  58. * get the number of entities not handled by this data proxy
  59. *
  60. * @return number of entities not handle by this data proxy
  61. */
  62. inline size_t other_entity_count() const;
  63. /**
  64. * get the number of all entities
  65. *
  66. * @return number of all entities
  67. */
  68. inline size_t all_entity_count() const;
  69. };
  70. /**
  71. * create a single data proxy (data proxy that does not execute in parallel)
  72. *
  73. * @tparam T_context context type
  74. * @tparam T_instance instance type
  75. *
  76. * @param context context
  77. * @param instance instance
  78. *
  79. * @return single data proxy
  80. */
  81. template<typename T_context, typename T_instance>
  82. constexpr decltype(auto) make_single(T_context&& context, T_instance&& instance);
  83. } } } }