Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::ecs::AccessPolicy Class Reference

Stores data access requirements for a system at compile time. More...

#include <access_policy.hpp>

Public Member Functions

constexpr AccessPolicy () noexcept=default
constexpr AccessPolicy (const AccessPolicy &)=default
constexpr AccessPolicy (AccessPolicy &&) noexcept=default
constexpr ~AccessPolicy ()=default
constexpr AccessPolicyoperator= (const AccessPolicy &)=default
constexpr AccessPolicyoperator= (AccessPolicy &&) noexcept=default
constexpr void Merge (const AccessPolicy &other)
 Merges data access declarations from another policy.
constexpr void Merge (AccessPolicy &&other)
 Merges data access declarations from another policy.
constexpr auto GetQueryConflictsWith (const AccessPolicy &other) const -> std::vector< ComponentConflictInfo >
 Returns all component conflicts between this policy and another.
constexpr auto GetResourceConflictsWith (const AccessPolicy &other) const -> std::vector< ResourceConflictInfo >
 Returns all resource conflicts between this policy and another.
constexpr bool ConflictsWith (const AccessPolicy &other) const noexcept
 Checks if this policy conflicts with another policy at all.
constexpr bool HasQueryConflictWith (const AccessPolicy &other) const noexcept
 Checks if this policy has a component access conflict with another.
constexpr bool HasResourceConflictWith (const AccessPolicy &other) const noexcept
 Checks if this policy has a resource access conflict with another.
constexpr bool HasComponents () const noexcept
 Checks if this policy declares any component access.
constexpr bool HasResources () const noexcept
 Checks if this policy declares any resource access.
constexpr bool HasReadComponent (ComponentTypeIndex type_index) const noexcept
 Checks if this policy declares read access to a component.
constexpr bool HasWriteComponent (ComponentTypeIndex type_index) const noexcept
 Checks if this policy declares write access to a component.
constexpr bool HasReadResource (ResourceTypeIndex type_index) const noexcept
 Checks if this policy declares read access to a resource.
constexpr bool HasWriteResource (ResourceTypeIndex type_index) const noexcept
 Checks if this policy declares write access to a resource.
constexpr auto GetReadComponents () const noexcept -> std::span< const ComponentTypeId >
 Returns all component types declared for reading (sorted).
constexpr auto GetWriteComponents () const noexcept -> std::span< const ComponentTypeId >
 Returns all component types declared for writing (sorted).
constexpr auto GetReadResources () const noexcept -> std::span< const ResourceTypeId >
 Returns all resource types declared for reading (sorted).
constexpr auto GetWriteResources () const noexcept -> std::span< const ResourceTypeId >
 Returns all resource types declared for writing (sorted).

Friends

class AccessPolicyBuilder

Detailed Description

Stores data access requirements for a system at compile time.

Components and resources are each kept in two flat sorted sets (read / write), deduped across all Query / ReadResources / WriteResources declarations. This mirrors how resources have always been stored and removes the per-query descriptor indirection.

AccessPolicy is used to:

  • Enable automatic scheduling and conflict detection

It is compile-time scheduling metadata only. Runtime access validation is not implemented yet.

Definition at line 119 of file access_policy.hpp.

Constructor & Destructor Documentation

◆ AccessPolicy() [1/3]

helios::ecs::AccessPolicy::AccessPolicy ( )
constexprdefaultnoexcept

◆ AccessPolicy() [2/3]

helios::ecs::AccessPolicy::AccessPolicy ( const AccessPolicy & )
constexprdefault

◆ AccessPolicy() [3/3]

helios::ecs::AccessPolicy::AccessPolicy ( AccessPolicy && )
constexprdefaultnoexcept

◆ ~AccessPolicy()

helios::ecs::AccessPolicy::~AccessPolicy ( )
constexprdefault

Member Function Documentation

◆ ConflictsWith()

bool helios::ecs::AccessPolicy::ConflictsWith ( const AccessPolicy & other) const
inlinenodiscardconstexprnoexcept

Checks if this policy conflicts with another policy at all.

Shorthand for HasQueryConflictWith || HasResourceConflictWith.

Parameters
otherOther access policy to check against
Returns
True if any conflict exists, false otherwise

Definition at line 172 of file access_policy.hpp.

◆ GetQueryConflictsWith()

auto helios::ecs::AccessPolicy::GetQueryConflictsWith ( const AccessPolicy & other) const -> std::vector< ComponentConflictInfo >
nodiscardconstexpr

Returns all component conflicts between this policy and another.

Each entry in the returned vector describes one conflicting component type and which side(s) write it. The same component type appears at most once in the result.

Parameters
otherOther access policy to inspect
Returns
Vector of ComponentConflictInfo, empty when no conflicts exist

Definition at line 335 of file access_policy.hpp.

◆ GetReadComponents()

auto helios::ecs::AccessPolicy::GetReadComponents ( ) const -> std::span< const ComponentTypeId >
inlinenodiscardconstexprnoexcept

Returns all component types declared for reading (sorted).

Returns
A std::span view of the read component types

Definition at line 250 of file access_policy.hpp.

◆ GetReadResources()

auto helios::ecs::AccessPolicy::GetReadResources ( ) const -> std::span< const ResourceTypeId >
inlinenodiscardconstexprnoexcept

Returns all resource types declared for reading (sorted).

Returns
A std::span view of the read resource types

Definition at line 268 of file access_policy.hpp.

◆ GetResourceConflictsWith()

auto helios::ecs::AccessPolicy::GetResourceConflictsWith ( const AccessPolicy & other) const -> std::vector< ResourceConflictInfo >
nodiscardconstexpr

Returns all resource conflicts between this policy and another.

Each entry describes one conflicting resource type and which side(s) write it. The same resource type appears at most once.

Parameters
otherOther access policy to inspect
Returns
Vector of ResourceConflictInfo, empty when no conflicts exist

Definition at line 383 of file access_policy.hpp.

◆ GetWriteComponents()

auto helios::ecs::AccessPolicy::GetWriteComponents ( ) const -> std::span< const ComponentTypeId >
inlinenodiscardconstexprnoexcept

Returns all component types declared for writing (sorted).

Returns
A std::span view of the write component types

Definition at line 259 of file access_policy.hpp.

◆ GetWriteResources()

auto helios::ecs::AccessPolicy::GetWriteResources ( ) const -> std::span< const ResourceTypeId >
inlinenodiscardconstexprnoexcept

Returns all resource types declared for writing (sorted).

Returns
A std::span view of the write resource types

Definition at line 277 of file access_policy.hpp.

◆ HasComponents()

bool helios::ecs::AccessPolicy::HasComponents ( ) const
inlinenodiscardconstexprnoexcept

Checks if this policy declares any component access.

Returns
True if any read or write component has been declared

Definition at line 202 of file access_policy.hpp.

◆ HasQueryConflictWith()

bool helios::ecs::AccessPolicy::HasQueryConflictWith ( const AccessPolicy & other) const
nodiscardconstexprnoexcept

Checks if this policy has a component access conflict with another.

Conflict exists when:

  • Both policies write the same component (write–write), or
  • One writes a component the other reads (write–read / read–write).
    Parameters
    otherOther access policy to check against
    Returns
    True if a component conflict exists, false otherwise

Definition at line 425 of file access_policy.hpp.

◆ HasReadComponent()

bool helios::ecs::AccessPolicy::HasReadComponent ( ComponentTypeIndex type_index) const
nodiscardconstexprnoexcept

Checks if this policy declares read access to a component.

Parameters
type_indexComponent type index to look up
Returns
True if the component is in the read set

Definition at line 482 of file access_policy.hpp.

◆ HasReadResource()

bool helios::ecs::AccessPolicy::HasReadResource ( ResourceTypeIndex type_index) const
nodiscardconstexprnoexcept

Checks if this policy declares read access to a resource.

Parameters
type_indexResource type index to look up
Returns
True if the resource is in the read set

Definition at line 498 of file access_policy.hpp.

◆ HasResourceConflictWith()

bool helios::ecs::AccessPolicy::HasResourceConflictWith ( const AccessPolicy & other) const
nodiscardconstexprnoexcept

Checks if this policy has a resource access conflict with another.

Conflict exists when both policies access the same resource and at least one of them writes it.

Parameters
otherOther access policy to check against
Returns
True if a resource conflict exists, false otherwise

Definition at line 452 of file access_policy.hpp.

◆ HasResources()

bool helios::ecs::AccessPolicy::HasResources ( ) const
inlinenodiscardconstexprnoexcept

Checks if this policy declares any resource access.

Returns
True if any read or write resource has been declared

Definition at line 210 of file access_policy.hpp.

◆ HasWriteComponent()

bool helios::ecs::AccessPolicy::HasWriteComponent ( ComponentTypeIndex type_index) const
nodiscardconstexprnoexcept

Checks if this policy declares write access to a component.

Parameters
type_indexComponent type index to look up
Returns
True if the component is in the write set

Definition at line 490 of file access_policy.hpp.

◆ HasWriteResource()

bool helios::ecs::AccessPolicy::HasWriteResource ( ResourceTypeIndex type_index) const
nodiscardconstexprnoexcept

Checks if this policy declares write access to a resource.

Parameters
type_indexResource type index to look up
Returns
True if the resource is in the write set

Definition at line 506 of file access_policy.hpp.

◆ Merge() [1/2]

void helios::ecs::AccessPolicy::Merge ( AccessPolicy && other)
constexpr

Merges data access declarations from another policy.

Performs set-union merge for component and resource read/write sets while keeping them sorted and deduplicated.

Parameters
otherSource policy to merge from

Definition at line 331 of file access_policy.hpp.

◆ Merge() [2/2]

void helios::ecs::AccessPolicy::Merge ( const AccessPolicy & other)
constexpr

Merges data access declarations from another policy.

Performs set-union merge for component and resource read/write sets while keeping them sorted and deduplicated.

Parameters
otherSource policy to merge from

Definition at line 301 of file access_policy.hpp.

◆ operator=() [1/2]

AccessPolicy & helios::ecs::AccessPolicy::operator= ( AccessPolicy && )
constexprdefaultnoexcept

◆ operator=() [2/2]

AccessPolicy & helios::ecs::AccessPolicy::operator= ( const AccessPolicy & )
constexprdefault

◆ AccessPolicyBuilder

friend class AccessPolicyBuilder
friend

Definition at line 298 of file access_policy.hpp.