Skip to main content

EntityMutationCommandBuffer Class Template

Collects deferred entity-mutation commands and dispatches them in bulk. More...

Declaration

template <typename TEntityManager> class helios::engine::runtime::messaging::command::EntityMutationCommandBuffer<TEntityManager> { ... }

Public Member Typedefs Index

template <typename TEntityManager>
usingHandle_type = typename TEntityManager::Handle_type

The entity handle type this buffer operates on. More...

template <typename TEntityManager>
usingEngineRoleTag = CommandBufferRole

Role tag marking this as a command buffer for the engine registry. More...

Public Member Functions Index

template <typename TCommand, typename... Args>
voidadd (Args &&... args)

Enqueues a command of type TCommand, constructing it from args. More...

template <typename TCommand>
auto *bufferForCommand ()

Returns a raw pointer to the InternalBuffer for TCommand. More...

template <typename TEntityManager>
voidinit (CommandHandlerRegistry &commandHandlerRegistry, ManagerRegistry &managerRegistry)

Initialises this buffer and all already-registered internal buffers. More...

template <typename TEntityManager>
voidflush (UpdateContext &updateContext)

Flushes all internal buffers, dispatching every queued command. More...

template <typename TEntityManager>
voidclear ()

Discards all queued commands across every internal buffer without dispatching. More...

Private Member Functions Index

template <typename TCommand>
auto *modelFor ()

Returns (or lazily creates) the InternalBuffer for TCommand. More...

Private Member Attributes Index

template <typename TEntityManager>
CommandBufferRegistrycommandBufferRegistry_ {}

Registry of lazily created per-command-type InternalBuffer instances. More...

template <typename TEntityManager>
CommandHandlerRegistry *commandHandlerRegistry_ {nullptr}

Registry used to route submitted commands to their handlers. More...

template <typename TEntityManager>
ManagerRegistry *managerRegistry_ {nullptr}

Registry providing the EntityMutationManager during handler registration. More...

Description

Collects deferred entity-mutation commands and dispatches them in bulk.

Commands are enqueued during system execution and forwarded to the EntityMutationManager during the flush phase, decoupling structural ECS mutations from hot iteration loops.

Each concrete command type gets its own InternalBuffer, created lazily on first use and stored in an internal CommandBufferRegistry.

Template Parameters
TEntityManager

Entity manager type that identifies the target registry.

Definition at line 49 of file EntityMutationCommandBuffer.ixx.

Public Member Typedefs

EngineRoleTag

template <typename TEntityManager>
using helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::EngineRoleTag = CommandBufferRole

Role tag marking this as a command buffer for the engine registry.

Definition at line 181 of file EntityMutationCommandBuffer.ixx.

Handle_type

template <typename TEntityManager>
using helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::Handle_type = typename TEntityManager::Handle_type

The entity handle type this buffer operates on.

Definition at line 178 of file EntityMutationCommandBuffer.ixx.

178 using Handle_type = typename TEntityManager::Handle_type;

Public Member Functions

add()

template <typename TCommand, typename... Args>
void helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::add (Args &&... args)
inline

Enqueues a command of type TCommand, constructing it from args.

TCommand::Handle_type must match THandle.

Template Parameters
TCommand

ECS command type to enqueue.

Args

Constructor argument types.

Parameters
args

Arguments forwarded to the command constructor.

Definition at line 194 of file EntityMutationCommandBuffer.ixx.

194 void add(Args&&... args) {
195
196 auto* model = modelFor<TCommand>();
197
198 model->add(std::forward<Args>(args)...);
199 }

Reference helios::engine::runtime::registerComponents.

bufferForCommand()

template <typename TCommand>
auto * helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::bufferForCommand ()
inline

Returns a raw pointer to the InternalBuffer for TCommand.

Useful when a caller needs direct access to the buffer (e.g. for batched inserts).

Template Parameters
TCommand

Command type whose buffer is requested.

Returns

Non-owning pointer to the internal buffer.

Definition at line 210 of file EntityMutationCommandBuffer.ixx.

211 return modelFor<TCommand>();
212 }

Reference helios::engine::runtime::registerComponents.

clear()

template <typename TEntityManager>
void helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::clear ()
inline

Discards all queued commands across every internal buffer without dispatching.

Definition at line 246 of file EntityMutationCommandBuffer.ixx.

246 void clear() {
247 for (auto* buffer : commandBufferRegistry_.items()) {
248 buffer->clear();
249 }
250 }

Reference helios::engine::core::container::ConceptModelRegistry< AnyT, IdProvider >::items.

flush()

template <typename TEntityManager>
void helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::flush (UpdateContext & updateContext)
inline

Flushes all internal buffers, dispatching every queued command.

Parameters
updateContext

Frame-local update context forwarded to each buffer's flush.

Definition at line 237 of file EntityMutationCommandBuffer.ixx.

238 for (auto* buffer : commandBufferRegistry_.items()) {
239 buffer->flush(updateContext);
240 }
241 }

References helios::engine::core::container::ConceptModelRegistry< AnyT, IdProvider >::items and helios::engine::runtime::registerComponents.

init()

template <typename TEntityManager>
void helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::init (CommandHandlerRegistry & commandHandlerRegistry, ManagerRegistry & managerRegistry)
inline

Initialises this buffer and all already-registered internal buffers.

Must be called once before the first add() or flush().

Parameters
commandHandlerRegistry

Registry used to route commands to handlers.

managerRegistry

Registry providing the EntityMutationManager<Handle_type>.

Definition at line 222 of file EntityMutationCommandBuffer.ixx.

222 void init(CommandHandlerRegistry& commandHandlerRegistry, ManagerRegistry& managerRegistry) {
223
224 commandHandlerRegistry_ = &commandHandlerRegistry;
225 managerRegistry_ = &managerRegistry;
226
227 for (auto* buffer : commandBufferRegistry_.items()) {
228 buffer->init(commandHandlerRegistry, managerRegistry);
229 }
230 }

Reference helios::engine::core::container::ConceptModelRegistry< AnyT, IdProvider >::items.

Private Member Functions

modelFor()

template <typename TCommand>
auto * helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::modelFor ()
inline

Returns (or lazily creates) the InternalBuffer for TCommand.

Template Parameters
TCommand

Command type whose buffer is requested.

Returns

Non-owning pointer to the buffer.

Definition at line 154 of file EntityMutationCommandBuffer.ixx.

154 auto* modelFor() {
155
156 auto* model = commandBufferRegistry_.item<InternalBuffer<TCommand>>();
157
158 if (!model) {
159 auto& created =
160 commandBufferRegistry_.add<InternalBuffer<TCommand>>(
162 );
163
164 assert(commandHandlerRegistry_
165 && managerRegistry_
166 && "CommandHandlerRegistry and ManagerRegistry must be initialized before adding commands.");
167 created.init(*commandHandlerRegistry_,*managerRegistry_);
168
169 return &created;
170 }
171
172 return model;
173 }

Private Member Attributes

commandBufferRegistry_

template <typename TEntityManager>
CommandBufferRegistry helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::commandBufferRegistry_ {}

Registry of lazily created per-command-type InternalBuffer instances.

Definition at line 52 of file EntityMutationCommandBuffer.ixx.

52 CommandBufferRegistry commandBufferRegistry_{};

commandHandlerRegistry_

template <typename TEntityManager>
CommandHandlerRegistry* helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::commandHandlerRegistry_ {nullptr}

Registry used to route submitted commands to their handlers.

Definition at line 55 of file EntityMutationCommandBuffer.ixx.

55 CommandHandlerRegistry* commandHandlerRegistry_{nullptr};

managerRegistry_

template <typename TEntityManager>
ManagerRegistry* helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::managerRegistry_ {nullptr}

Registry providing the EntityMutationManager during handler registration.

Definition at line 58 of file EntityMutationCommandBuffer.ixx.

58 ManagerRegistry* managerRegistry_{nullptr};

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.