View.ixx File
Lightweight view for iterating entities with specific components. More...
Included Headers
#include <tuple>
#include <vector>
#include <functional>
#include <helios.ecs.types.EntityHandle>
#include <helios.ecs.Entity>
#include <helios.ecs.EntityManager>
#include <helios.ecs.types.TypeDefs>
#include <helios.ecs.SparseSet>
Namespaces Index
| namespace | helios |
| namespace | ecs |
Classes Index
| class | PartialView<TEntityManager, std::tuple< TRequired... >, std::tuple< TOptional... >> |
| struct | Iterator<TEntityManager, std::tuple< TRequired... >, std::tuple< TOptional... > >::Iterator |
|
Forward iterator for View traversal. More... | |
Description
Lightweight view for iterating entities with specific components.
File Listing
The file content with the documentation metadata removed is:
19using namespace helios::ecs::types;
20export namespace helios::ecs {
53 class PartialView;
64 using View = PartialView<TEntityManager, std::tuple<TRequired...>, std::tuple<>>;
67 class PartialView<TEntityManager, std::tuple<TRequired...>, std::tuple<TOptional...>> {
85 std::vector<std::function<bool(EntityId)>> excludeChecks_;
100 explicit PartialView(TEntityManager* em) : em_(em) {
106 explicit PartialView(
108 std::tuple<SparseSet<TRequired>*...> includeSets,
109 std::vector<std::function<bool(EntityId)>> excludeChecks,
111 ) : em_(em), includeSets_(includeSets), excludeChecks_(std::move(excludeChecks)), filterEnabledOnly_(filterEnabledOnly) {
112 static_assert(sizeof...(TOptional) == 0, "withOptional() should provide all optional components types in a single call.");
139 PartialView<TEntityManager, std::tuple<TRequired...>, std::tuple<TNewOptional...>> withOptional() {
140 return PartialView<TEntityManager, std::tuple<TRequired...>, std::tuple<TNewOptional...>>(
165 PartialView& exclude() {
169 excludeChecks_.emplace_back([set](EntityId entityId) {
192 PartialView& whereEnabled() {
204 struct Iterator {
206 using Entity_type = Entity<TEntityManager>;
211 using LeadComponent = std::tuple_element_t<0, std::tuple<TRequired...>>;
216 using LeadIterator = typename SparseSet<LeadComponent>::Iterator;
220 const PartialView* view_;
234 Iterator(LeadIterator current, LeadIterator end, const PartialView* view)
254 EntityId entityId = current_.entityId();
325 Iterator& operator++() noexcept {
337 bool operator!=(const Iterator& other) const noexcept {
356 EntityId entityId = current_.entityId();
361 std::make_tuple(Entity_type(handle, view_->em_)),
390 [[nodiscard]] bool operator==(const Iterator& other) const noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.