Skip to main content

HierarchyComponent Class Template

Stores parent-child relationships for hierarchical entity graphs. More...

Declaration

template <typename THandle> class helios::ecs::components::HierarchyComponent<THandle> { ... }

Public Member Functions Index

template <typename THandle>
voidaddChild (const THandle child)

Adds a child entity to this hierarchy node. More...

template <typename THandle>
voidsetParent (const THandle parent)

Sets the parent entity for this hierarchy node. More...

template <typename THandle>
auto parent () const noexcept -> std::optional< THandle >

Returns the parent entity handle if set. More...

template <typename THandle>
auto children () noexcept -> std::span< const THandle >

Returns a span over all child entity handles. More...

template <typename THandle>
voidmarkDirty ()

Marks the hierarchy as requiring propagation. More...

template <typename THandle>
voidclearDirty ()

Clears the dirty flag after propagation. More...

template <typename THandle>
boolisDirty () const noexcept

Checks whether the hierarchy needs propagation. More...

Private Member Attributes Index

template <typename THandle>
std::vector< THandle >children_

Child entity handles. More...

template <typename THandle>
std::optional< THandle >parent_

Optional parent entity handle. More...

template <typename THandle>
boolisDirty_ = false

Dirty flag indicating pending hierarchy updates. More...

template <typename THandle>
boolisEnabled_ = true

Whether this component is enabled. More...

Description

Stores parent-child relationships for hierarchical entity graphs.

HierarchyComponent enables entities to form tree structures where state changes (e.g., activation, transformation) can propagate from parent to child entities. The dirty flag signals that the hierarchy has changed and needs propagation.

Template Parameters
THandle

The entity handle type used for parent/child references.

Definition at line 28 of file HierarchyComponent.ixx.

Public Member Functions

addChild()

template <typename THandle>
void helios::ecs::components::HierarchyComponent< THandle >::addChild (const THandle child)
inline

Adds a child entity to this hierarchy node.

Parameters
child

Handle of the child entity to add.

Definition at line 57 of file HierarchyComponent.ixx.

57 void addChild(const THandle child) {
58 children_.push_back(child);
59 }

children()

template <typename THandle>
std::span< const THandle > helios::ecs::components::HierarchyComponent< THandle >::children ()
inline nodiscard noexcept

Returns a span over all child entity handles.

Returns

Read-only span of child handles.

Definition at line 84 of file HierarchyComponent.ixx.

84 [[nodiscard]] std::span<const THandle> children() noexcept {
85 return children_;
86 }

clearDirty()

template <typename THandle>
void helios::ecs::components::HierarchyComponent< THandle >::clearDirty ()
inline

Clears the dirty flag after propagation.

Definition at line 98 of file HierarchyComponent.ixx.

98 void clearDirty() {
99 isDirty_ = false;
100 }

isDirty()

template <typename THandle>
bool helios::ecs::components::HierarchyComponent< THandle >::isDirty ()
inline nodiscard noexcept

Checks whether the hierarchy needs propagation.

Returns

True if dirty, false otherwise.

Definition at line 107 of file HierarchyComponent.ixx.

107 [[nodiscard]] bool isDirty() const noexcept {
108 return isDirty_;
109 }

markDirty()

template <typename THandle>
void helios::ecs::components::HierarchyComponent< THandle >::markDirty ()
inline

Marks the hierarchy as requiring propagation.

Definition at line 91 of file HierarchyComponent.ixx.

91 void markDirty() {
92 isDirty_ = true;
93 }

parent()

template <typename THandle>
std::optional< THandle > helios::ecs::components::HierarchyComponent< THandle >::parent ()
inline nodiscard noexcept

Returns the parent entity handle if set.

Returns

Optional containing the parent handle, or std::nullopt.

Definition at line 75 of file HierarchyComponent.ixx.

75 [[nodiscard]] std::optional<THandle> parent() const noexcept {
76 return parent_;
77 }

setParent()

template <typename THandle>
void helios::ecs::components::HierarchyComponent< THandle >::setParent (const THandle parent)
inline

Sets the parent entity for this hierarchy node.

Parameters
parent

Handle of the parent entity.

Definition at line 66 of file HierarchyComponent.ixx.

66 void setParent(const THandle parent) {
67 parent_ = parent;
68 }

Private Member Attributes

children_

template <typename THandle>
std::vector<THandle> helios::ecs::components::HierarchyComponent< THandle >::children_

Child entity handles.

Definition at line 33 of file HierarchyComponent.ixx.

33 std::vector<THandle> children_;

isDirty_

template <typename THandle>
bool helios::ecs::components::HierarchyComponent< THandle >::isDirty_ = false

Dirty flag indicating pending hierarchy updates.

Definition at line 43 of file HierarchyComponent.ixx.

43 bool isDirty_ = false;

isEnabled_

template <typename THandle>
bool helios::ecs::components::HierarchyComponent< THandle >::isEnabled_ = true

Whether this component is enabled.

Definition at line 48 of file HierarchyComponent.ixx.

48 bool isEnabled_ = true;

parent_

template <typename THandle>
std::optional<THandle> helios::ecs::components::HierarchyComponent< THandle >::parent_

Optional parent entity handle.

Definition at line 38 of file HierarchyComponent.ixx.

38 std::optional<THandle> parent_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.