You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 rivejä
3.4 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 multi
  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: // private:
  23. size_t _index;
  24. size_t _begin;
  25. size_t _end;
  26. public:
  27. /**
  28. * create the multi data proxy
  29. *
  30. * @param p_context context of the ECS environment
  31. * @param p_instance system instance
  32. * @param p_index index of this data proxy
  33. * @param p_begin index of the first entity to process
  34. * @param p_end index of the first entity not to process
  35. */
  36. inline multi(context_type& p_context, instance_type& p_instance, size_t p_index, size_t p_begin, size_t p_end);
  37. /**
  38. * execute the given function for all entities handled by this data proxy
  39. *
  40. * @tparam T_func function type to execute
  41. *
  42. * @param func function to execute
  43. */
  44. template<typename T_func>
  45. inline void for_entities(T_func&& func) const;
  46. /**
  47. * execute the given function for all entities not handled by this data proxy
  48. *
  49. * @tparam T_func function type to execute
  50. *
  51. * @param func function to execute
  52. */
  53. template<typename T_func>
  54. void for_other_entities(T_func&& func) const;
  55. /**
  56. * execute the given function for all entities
  57. *
  58. * @tparam T_func function type to execute
  59. *
  60. * @param func function to execute
  61. */
  62. template<typename T_func>
  63. void for_all_entities(T_func&& func) const;
  64. /**
  65. * get the number of entities handled by this data proxy
  66. *
  67. * @return number of entities handle by this data proxy
  68. */
  69. inline size_t entity_count() const;
  70. /**
  71. * get the number of entities not handled by this data proxy
  72. *
  73. * @return number of entities not handle by this data proxy
  74. */
  75. inline size_t other_entity_count() const;
  76. /**
  77. * get the number of all entities
  78. *
  79. * @return number of all entities
  80. */
  81. inline size_t all_entity_count() const;
  82. };
  83. /**
  84. * create a multi data proxy (data proxy that does not execute in parallel)
  85. *
  86. * @tparam T_context context type
  87. * @tparam T_instance instance type
  88. *
  89. * @param context context
  90. * @param instance instance
  91. * @param index index of this data proxy
  92. * @param begin index of the first entity to process
  93. * @param end index of the first entity not to process
  94. *
  95. * @return multi data proxy
  96. */
  97. template<typename T_context, typename T_instance>
  98. constexpr decltype(auto) make_multi(T_context&& context, T_instance&& instance, size_t index, size_t begin, size_t end);
  99. } } } }