Skip to main content

ResourceRegistry Class

Unified type-indexed registry for all engine resources. More...

Declaration

class helios::engine::runtime::world::ResourceRegistry { ... }

Public Member Functions Index

template <class T, class... Args>
T &emplace (Args &&... args)

Registers and constructs a resource of type T. More...

template <class T>
boolhas () const noexcept

Checks if a resource of type T is registered. More...

template <class T>
T *tryGet () const noexcept

Retrieves a registered resource by type. More...

template <class T>
T &get () const noexcept

Retrieves a registered resource by type (checked). More...

std::span< Manager *const >managers () const noexcept

Returns a read-only span of all registered Managers. More...

std::span< Manager * >managers () noexcept

Returns a read-only span of all registered Managers. More...

std::span< CommandBuffer *const >commandBuffers () const noexcept

Returns a read-only span of all registered CommandBuffers. More...

std::span< CommandBuffer * >commandBuffers () noexcept

Returns a read-only span of all registered CommandBuffers. More...

Private Member Attributes Index

ManagerRegistrymanagerRegistry_

Registry for Manager instances. More...

CommandBufferRegistrycommandBufferRegistry_

Registry for CommandBuffer instances. More...

Description

Unified type-indexed registry for all engine resources.

ResourceRegistry acts as the central access point for Managers and CommandBuffers. It delegates to a ManagerRegistry and a CommandBufferRegistry internally, routing registration and lookup based on compile-time concept checks (IsManagerLike / IsCommandBufferLike).

See Also

ManagerRegistry

See Also

CommandBufferRegistry

See Also

GameWorld

Definition at line 48 of file ResourceRegistry.ixx.

Public Member Functions

commandBuffers()

std::span< CommandBuffer *const > helios::engine::runtime::world::ResourceRegistry::commandBuffers ()
inline noexcept

Returns a read-only span of all registered CommandBuffers.

Returns

Span of CommandBuffer pointers in registration order.

Definition at line 178 of file ResourceRegistry.ixx.

178 std::span<CommandBuffer* const> commandBuffers() const noexcept {
179 return commandBufferRegistry_.items();
180 }

commandBuffers()

std::span< CommandBuffer * > helios::engine::runtime::world::ResourceRegistry::commandBuffers ()
inline noexcept

Returns a read-only span of all registered CommandBuffers.

Returns

Span of CommandBuffer pointers in registration order.

Definition at line 185 of file ResourceRegistry.ixx.

185 std::span<CommandBuffer*> commandBuffers() noexcept {
186 return commandBufferRegistry_.items();
187 }

emplace()

template <class T, class... Args>
T & helios::engine::runtime::world::ResourceRegistry::emplace (Args &&... args)
inline

Registers and constructs a resource of type T.

Routes to ManagerRegistry or CommandBufferRegistry based on whether T satisfies IsManagerLike or IsCommandBufferLike. The resource is constructed in-place with forwarded arguments.

Template Parameters
T

The resource type. Must satisfy IsManagerLike or IsCommandBufferLike.

Args

Constructor argument types.

Parameters
args

Arguments forwarded to the T constructor.

Returns

Reference to the newly registered resource.

Definition at line 78 of file ResourceRegistry.ixx.

78 T& emplace(Args&&... args) {
79
80 if constexpr (IsManagerLike<T>) {
81 return managerRegistry_.template add<T>(std::forward<Args>(args)...);
82 }
83
84 if constexpr (IsCommandBufferLike<T>) {
85 return commandBufferRegistry_.template add<T>(std::forward<Args>(args)...);
86 }
87
88 assert(false);
89 }

get()

template <class T>
T & helios::engine::runtime::world::ResourceRegistry::get ()
inline noexcept

Retrieves a registered resource by type (checked).

Asserts that the resource is registered before returning.

Template Parameters
T

The resource type.

Returns

Reference to the resource.

Precondition

The resource must be registered.

Definition at line 144 of file ResourceRegistry.ixx.

144 T& get() const noexcept {
145 assert(has<T>() && "Resource not found");
146 if constexpr (IsManagerLike<T>) {
147 return *managerRegistry_.item<T>();
148 }
149
150 if constexpr (IsCommandBufferLike<T>) {
151 return *commandBufferRegistry_.item<T>();
152 }
153
154 assert(false);
155 }

Reference has.

has()

template <class T>
bool helios::engine::runtime::world::ResourceRegistry::has ()
inline noexcept

Checks if a resource of type T is registered.

Template Parameters
T

The resource type.

Returns

True if the resource is registered.

Definition at line 99 of file ResourceRegistry.ixx.

99 bool has() const noexcept {
100 if constexpr (IsManagerLike<T>) {
101 return managerRegistry_.has<T>();
102 }
103
104 if constexpr (IsCommandBufferLike<T>) {
105 return commandBufferRegistry_.has<T>();
106 }
107
108 return false;
109 }

Referenced by get.

managers()

std::span< Manager *const > helios::engine::runtime::world::ResourceRegistry::managers ()
inline nodiscard noexcept

Returns a read-only span of all registered Managers.

Returns

Span of Manager pointers in registration order.

Definition at line 162 of file ResourceRegistry.ixx.

162 [[nodiscard]] std::span<Manager* const> managers() const noexcept {
163 return managerRegistry_.items();
164 }

managers()

std::span< Manager * > helios::engine::runtime::world::ResourceRegistry::managers ()
inline noexcept

Returns a read-only span of all registered Managers.

Returns

Span of Manager pointers in registration order.

Definition at line 169 of file ResourceRegistry.ixx.

169 std::span<Manager*> managers() noexcept {
170 return managerRegistry_.items();
171 }

tryGet()

template <class T>
T * helios::engine::runtime::world::ResourceRegistry::tryGet ()
inline noexcept

Retrieves a registered resource by type.

Template Parameters
T

The resource type.

Returns

Pointer to the resource, or nullptr if not registered.

Definition at line 119 of file ResourceRegistry.ixx.

119 T* tryGet() const noexcept {
120 if constexpr (IsManagerLike<T>) {
121 return managerRegistry_.item<T>();
122 }
123
124 if constexpr (IsCommandBufferLike<T>) {
125 return commandBufferRegistry_.item<T>();
126 }
127
128 return nullptr;
129 }

Private Member Attributes

commandBufferRegistry_

CommandBufferRegistry helios::engine::runtime::world::ResourceRegistry::commandBufferRegistry_

Registry for CommandBuffer instances.

Definition at line 58 of file ResourceRegistry.ixx.

58 CommandBufferRegistry commandBufferRegistry_;

managerRegistry_

ManagerRegistry helios::engine::runtime::world::ResourceRegistry::managerRegistry_

Registry for Manager instances.

Definition at line 53 of file ResourceRegistry.ixx.

53 ManagerRegistry managerRegistry_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.