Helper to guard against recursion when evaluating references.
More...
#include "donner/svg/graph/RecursionGuard.h"
|
|
| RecursionGuard ()=default |
| | efault constructor.
|
| bool | hasRecursion (Entity entity) const |
| | Returns true if this entity has been seen before, indicating a cycle has been detected.
|
| void | add (Entity entity) |
| | Add the given entity to the set of entities that have been seen.
|
| RecursionGuard | with (Entity entity) const |
| | Create a new RecursionGuard with the given entity added to the set of entities that have been seen.
|
Helper to guard against recursion when evaluating references.
This is used to prevent infinite recursion when reference hierarchies contain cycles.
Usage:
while (current) {
Entity target = getTarget(current);
break;
}
current = target;
}
entt::entity Entity
Entity type for the Registry, a std::uint32_t alias.
Definition EcsRegistry.h:22
RecursionGuard()=default
efault constructor.
bool hasRecursion(Entity entity) const
Returns true if this entity has been seen before, indicating a cycle has been detected.
Definition RecursionGuard.h:50
void add(Entity entity)
Add the given entity to the set of entities that have been seen.
Definition RecursionGuard.h:57
There is also a shorthand when passing a RecursionGuard as a parameter:
Entity next = getNext(current);
if (next != entt::null) {
doSomething(next, guard.
with(next));
}
}
RecursionGuard with(Entity entity) const
Create a new RecursionGuard with the given entity added to the set of entities that have been seen.
Definition RecursionGuard.h:68
◆ add()
| void donner::svg::RecursionGuard::add |
( |
Entity | entity | ) |
|
|
inline |
Add the given entity to the set of entities that have been seen.
- Parameters
-
◆ hasRecursion()
| bool donner::svg::RecursionGuard::hasRecursion |
( |
Entity | entity | ) |
const |
|
inline |
Returns true if this entity has been seen before, indicating a cycle has been detected.
- Parameters
-
◆ with()
Create a new RecursionGuard with the given entity added to the set of entities that have been seen.
- Parameters
-
The documentation for this struct was generated from the following file: