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.concepts.Traits>
#include <helios.ecs.Entity>
#include <helios.ecs.EntityManager>
#include <helios.ecs.types.TypeDefs>
#include <helios.ecs.SparseSet>
#include <helios.ecs.components>
Namespaces Index
| namespace | helios |
| namespace | ecs |
Classes Index
Description
Lightweight view for iterating entities with specific components.
File Listing
The file content with the documentation metadata removed is:
21using namespace helios::ecs::types;
22using namespace helios::ecs::components;
23using namespace helios::ecs::concepts::traits;
24export namespace helios::ecs {
57 template<typename TEntityManager, typename TRequiredComponents, typename TDirtyComponents, typename TOptionalComponents>
58 class PartialView;
69 using View = PartialView<TEntityManager, std::tuple<TRequired...>, std::tuple<>, std::tuple<>>;
71 template<typename TEntityManager, typename... TRequired, typename... TDirty, typename... TOptional>
72 class PartialView<TEntityManager, std::tuple<TRequired...>, std::tuple<TDirty...>, std::tuple<TOptional...>> {
98 std::vector<std::function<bool(EntityId)>> excludeChecks_;
103 SparseSet<Active<typename TEntityManager::Handle_type>>* activeSet_ = nullptr;
116 explicit PartialView(TEntityManager* em)
133 explicit PartialView(
135 std::tuple<SparseSet<TRequired>*...> includeSets,
136 std::vector<std::function<bool(EntityId)>> excludeChecks,
138 SparseSet<Active<typename TEntityManager::Handle_type>>* activeSet
146 anyDirtySets_(std::make_tuple(em_->template sparseSet<DirtyComponentSpec<TDirty>>()...))
172 auto withOptional()
175 return PartialView<
195 auto whereAnyDirty() requires (sizeof...(TOptional) == 0 && sizeof...(TDirty) == 0) {
197 return PartialView<
232 PartialView& exclude() {
236 excludeChecks_.emplace_back([set](EntityId entityId) {
261 PartialView& withActive() {
274 struct Iterator {
276 using Entity_type = Entity<TEntityManager>;
281 using LeadComponent = std::tuple_element_t<0, std::tuple<TRequired...>>;
286 using LeadIterator = typename SparseSet<LeadComponent>::Iterator;
290 const PartialView* view_;
304 Iterator(LeadIterator current, LeadIterator end, const PartialView* view)
323 EntityId entityId = current_.entityId();
335 if (view_->filterActiveOnly_ && (!view_->activeSet_ || !view_->activeSet_->contains(entityId))) {
382 Iterator& operator++() noexcept {
394 bool operator!=(const Iterator& other) const noexcept {
412 EntityId entityId = current_.entityId();
417 std::make_tuple(Entity_type(handle, view_->em_)),
440 [[nodiscard]] bool operator==(const Iterator& other) const noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.