Forward iterator for View traversal. More...
Declaration
struct helios::ecs::PartialView::Iterator<TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator { ... }
Public Member Typedefs Index
Public Constructors Index
| Iterator ()=default |
|
Default constructor creating an invalid iterator. More...
|
|
| Iterator (LeadIterator current, LeadIterator end, const PartialView *view) |
|
Constructs an iterator with the given range and view. More...
|
|
Public Operators Index
Public Member Functions Index
| bool | isValid () const |
|
Validates if the current entity matches all filter criteria. More...
|
|
| void | advance () |
|
Advances to the next valid entity. More...
|
|
Public Member Attributes Index
Description
Forward iterator for View traversal.
Uses the first component type as the "lead" iterator and validates each entity against all include/exclude criteria before yielding.
Definition at line 274 of file View.ixx.
Public Member Typedefs
Entity_type
| using helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::Entity_type = Entity<TEntityManager> |
|
LeadComponent
| using helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::LeadComponent = std::tuple_element_t<0, std::tuple<TRequired...> > |
|
The first component type determines iteration order.
Definition at line 281 of file View.ixx.
LeadIterator
| using helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::LeadIterator = typename SparseSet<LeadComponent>::Iterator |
|
Public Constructors
Iterator()
| helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::Iterator () |
|
default
|
Default constructor creating an invalid iterator.
Definition at line 295 of file View.ixx.
Iterator()
| helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::Iterator (LeadIterator current, LeadIterator end, const PartialView * view) |
|
inline
|
Constructs an iterator with the given range and view.
- Parameters
-
| current | Iterator to the current position. |
| end | Iterator to the end position. |
| view | Pointer to the owning View for filter access. |
Definition at line 304 of file View.ixx.
305 : current_(current), end_(end), view_(view) {}
Public Operators
operator!=()
| bool helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::operator!= (const Iterator & other) |
|
inline
noexcept
|
Inequality comparison.
- Parameters
-
| other | The iterator to compare against. |
- Returns
True if iterators point to different positions.
Definition at line 394 of file View.ixx.
395 return current_ != other.current_;
396 }
operator*()
| auto helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::operator* () |
|
inline
|
Dereference operator.
- Returns
A tuple containing: 1) Entity_type, 2) pointers to all required components, 3) pointers to all optional components.
Optional component pointers may be nullptr when the current entity does not own the respective component.
Returns by value to support C++17 structured binding.
Definition at line 411 of file View.ixx.
412 EntityId entityId = current_.entityId();
413 auto handle = view_->em_->handle(entityId);
414
415
416 return std::tuple_cat(
418 std::apply([entityId](auto*... sets) {
419 return std::make_tuple(sets->get(entityId)...);
420 }, view_->includeSets_),
421
422 std::apply([
423 entityId
424 ](auto*... sets) {
425 return std::make_tuple(
426 ([entityId, &sets]() {
427 if (!sets || !sets->contains(entityId)) {
428 return nullptr;
429 }
430
431 return sets->get(entityId);
432 }())...
433
434 );
435 }, view_->optionalSets_)
436
437 );
438 }
operator++()
| Iterator & helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::operator++ () |
|
inline
noexcept
|
Pre-increment operator.
- Returns
Reference to this iterator after advancing.
Definition at line 382 of file View.ixx.
383 advance();
384 return *this;
385 }
operator==()
| bool helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::operator== (const Iterator & other) |
|
inline
noexcept
|
Definition at line 440 of file View.ixx.
440 [[nodiscard]] bool operator==(const Iterator& other) const noexcept {
441 return current_ == other.current_;
442 }
Public Member Functions
advance()
| void helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::advance () |
|
inline
|
Advances to the next valid entity.
Increments the underlying iterator and skips invalid entities until a valid one is found or end is reached.
Definition at line 371 of file View.ixx.
372 do {
373 ++current_;
374 } while (current_ != end_ && !isValid());
375 }
isValid()
| bool helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::isValid () |
|
inline
|
Validates if the current entity matches all filter criteria.
Performs the following checks in order:
- Entity validity in the registry
- Include check - entity has all required components
- Exclude check - entity has none of the excluded components
- Returns
True if the entity passes all checks, false otherwise.
Definition at line 317 of file View.ixx.
318 if (current_ == end_) {
319 return true;
320 }
321
322
323 EntityId entityId = current_.entityId();
324
325 if (!view_->em_->isValid(entityId)) {
326 return false;
327 }
328
329
330
331 const bool hasAllIncludes = std::apply([entityId](auto*... sets) {
332 return ((sets && sets->contains(entityId)) && ...);
333 }, view_->includeSets_);
334
335 if (view_->filterActiveOnly_ && (!view_->activeSet_ || !view_->activeSet_->contains(entityId))) {
336 return false;
337 }
338
339 if (!hasAllIncludes) {
340 return false;
341 }
342
343
344 if constexpr (sizeof...(TDirty) > 0) {
345 const bool hasAnyDirtyIncludes = std::apply([entityId](auto*... sets) {
346 return ((sets && sets->contains(entityId)) || ...);
347 }, view_->anyDirtySets_);
348
349 if (!hasAnyDirtyIncludes) {
350 return false;
351 }
352 }
353
354
355 for (const auto& excludeCheck : view_->excludeChecks_) {
356 if (excludeCheck(entityId)) {
357 return false;
358 }
359 }
360
361
362 return true;
363 }
Public Member Attributes
current_
| LeadIterator helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::current_ |
|
end_
| LeadIterator helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::end_ |
|
view_
| const PartialView* helios::ecs::PartialView< TEntityManager, std::tuple< TRequired... >, std::tuple< TDirty... >, std::tuple< TOptional... > >::Iterator::view_ |
|
The documentation for this struct was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.