Skip to content

Commit 5db5f88

Browse files
committed
C++ execution options view
1 parent d4069af commit 5db5f88

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

ecsact/runtime/core.hh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,86 @@
11
#pragma once
22

33
#include <type_traits>
4+
#include <span>
5+
#if __has_include(<ranges>)
6+
# include <ranges>
7+
#endif
48
#include "ecsact/runtime/core.h"
59

610
namespace ecsact::core {
711

12+
class execution_options_view {
13+
ecsact_execution_options& _c_exec_opts;
14+
15+
public:
16+
inline execution_options_view(ecsact_execution_options& options)
17+
: _c_exec_opts(options) {
18+
}
19+
20+
inline auto add_components() -> std::span<ecsact_component> {
21+
return std::span(
22+
_c_exec_opts.add_components,
23+
static_cast<size_t>(_c_exec_opts.add_components_length)
24+
);
25+
}
26+
27+
inline auto add_components_entities() -> std::span<ecsact_entity_id> {
28+
return std::span(
29+
_c_exec_opts.add_components_entities,
30+
static_cast<size_t>(_c_exec_opts.add_components_length)
31+
);
32+
}
33+
34+
inline auto update_components() -> std::span<ecsact_component> {
35+
return std::span(
36+
_c_exec_opts.update_components,
37+
static_cast<size_t>(_c_exec_opts.update_components_length)
38+
);
39+
}
40+
41+
inline auto update_components_entities() -> std::span<ecsact_entity_id> {
42+
return std::span(
43+
_c_exec_opts.update_components_entities,
44+
static_cast<size_t>(_c_exec_opts.update_components_length)
45+
);
46+
}
47+
48+
inline auto remove_components() -> std::span<ecsact_component_id> {
49+
return std::span(
50+
_c_exec_opts.remove_components,
51+
static_cast<size_t>(_c_exec_opts.remove_components_length)
52+
);
53+
}
54+
55+
inline auto remove_components_entities() -> std::span<ecsact_entity_id> {
56+
return std::span(
57+
_c_exec_opts.remove_components_entities,
58+
static_cast<size_t>(_c_exec_opts.remove_components_length)
59+
);
60+
}
61+
62+
inline auto actions() -> std::span<ecsact_action> {
63+
return std::span(
64+
_c_exec_opts.actions,
65+
static_cast<size_t>(_c_exec_opts.actions_length)
66+
);
67+
}
68+
69+
#ifdef __cpp_lib_ranges_zip
70+
inline auto add_components_zip() {
71+
return std::views::zip(add_components_entities(), add_components());
72+
}
73+
74+
inline auto update_components_zip() {
75+
return std::views::zip(update_components_entities(), update_components());
76+
}
77+
78+
inline auto remove_components_zip() {
79+
return std::views::zip(remove_components_entities(), remove_components());
80+
}
81+
#endif
82+
};
83+
884
class registry {
985
ecsact_registry_id _id;
1086
bool _owned = false;

0 commit comments

Comments
 (0)