Skip to content

Engine → ECS → entity_handle.h

component_ref

Syntax

template <typename ComponentType> class component_ref

Constructors

AccessSignatureDescription
publiccomponent_ref() noexcept = default;A reference to nothing.
publiccomponent_ref( world &target, entity owner) noexcept;
publiccomponent_ref( const component_ref &) noexcept = default;

Destructors

AccessSignatureDescription
public~component_ref() = default;

Variables

AccessNameTypeDefaultDescription
privatemEntityentity{}
privatemWorldworld *nullptr

Functions

Public

is_valid

[[nodiscard]] bool is_valid() const noexcept;

True while the entity is alive and holds the component.

owner

[[nodiscard]] entity owner() const noexcept;

The entity this reference points at.

read

[[nodiscard]] const ComponentType *read() const noexcept;

The component for reading; nullptr when dead or missing. Never stamps.

set

[[nodiscard]] core::result<void> set(
    ComponentType value);

Replaces the value. ENTITY_NOT_ALIVE / COMPONENT_NOT_PRESENT when the reference is invalid.

valid

[[deprecated("use is_valid()")]] [[nodiscard]] bool valid() const noexcept;

The former name of is_valid(), kept for one wave; returns is_valid().

write

[[nodiscard]] ComponentType *write() noexcept;

The component for writing; stamps its chunk column. nullptr when dead or missing.

Operator Overloads

Public

operator=

component_ref &operator=(
    const component_ref &) noexcept = default;