EntityMutationCommandBuffer.ixx File
Deferred command buffer for structural entity mutations (add/remove components, activate/deactivate). More...
Included Headers
#include <memory>
#include <vector>
#include <cassert>
#include "helios-engine-config.h"
#include <helios.engine.runtime.world.UpdateContext>
#include <helios.engine.runtime.timing.TimerManager>
#include <helios.engine.runtime.messaging.command.tags>
#include <helios.engine.runtime.messaging.command.CommandHandlerRegistry>
#include <helios.engine.runtime.messaging.command.CommandBufferRegistry>
#include <helios.engine.runtime.messaging.command.types.CommandBufferTypeId>
#include <helios.engine.runtime.messaging.command.TypedCommandBuffer>
#include <helios.engine.runtime.messaging.command.CommandBuffer>
#include <helios.engine.runtime.world.EntityMutationManager>
#include <helios.ecs.commands>
#include <helios.engine.runtime.world.ManagerRegistry>
Namespaces Index
| namespace | helios |
| namespace | engine |
| namespace | runtime |
| namespace | messaging |
| namespace | command |
Classes Index
| class | EntityMutationCommandBuffer<TEntityManager> |
|
Collects deferred entity-mutation commands and dispatches them in bulk. More... | |
| class | InternalBuffer<TCommandType> |
|
Per-command-type storage and dispatch unit. More... | |
Description
Deferred command buffer for structural entity mutations (add/remove components, activate/deactivate).
File Listing
The file content with the documentation metadata removed is:
12#include "helios-engine-config.h"
30using namespace helios::engine::runtime::world;
31using namespace helios::engine::runtime::timing;
32using namespace helios::engine::runtime::messaging::command::types;
33using namespace helios::engine::runtime::messaging::command::tags;
34export namespace helios::engine::runtime::messaging::command {
49 class EntityMutationCommandBuffer {
52 CommandBufferRegistry commandBufferRegistry_{};
55 CommandHandlerRegistry* commandHandlerRegistry_{nullptr};
58 ManagerRegistry* managerRegistry_{nullptr};
73 CommandHandlerRegistry* commandHandlerRegistry_{nullptr};
76 ManagerRegistry* managerRegistry_{nullptr};
82 EntityMutationManager<TEntityManager>* entityMutationManager_{nullptr};
88 using EngineRoleTag = CommandBufferRole;
92 commands_.reserve(DEFAULT_ENTITY_MUTATION_COMMAND_BUFFER_CAPACITY);
102 void flush(UpdateContext& updateContext) {
105 auto* entityMutationManager_ = managerRegistry_->item<EntityMutationManager<TEntityManager>>();
106 assert(entityMutationManager_ && "EntityMutationManager for the specified handle is not initialized.");
107 commandHandlerRegistry_->handleCommands<TCommandType>(*entityMutationManager_);
111 for (auto& cmd : commands_) {
112 commandHandlerRegistry_->submit<TCommandType>(std::move(cmd));
129 void init(CommandHandlerRegistry& commandHandlerRegistry, ManagerRegistry& managerRegistry) {
140 template<typename ... TArgs>
141 void add(TArgs&&... args) {
156 auto* model = commandBufferRegistry_.item<InternalBuffer<TCommand>>();
159 auto& created =
160 commandBufferRegistry_.add<InternalBuffer<TCommand>>(
164 assert(commandHandlerRegistry_
167 created.init(*commandHandlerRegistry_,*managerRegistry_);
169 return &created;
178 using Handle_type = typename TEntityManager::Handle_type;
181 using EngineRoleTag = CommandBufferRole;
196 auto* model = modelFor<TCommand>();
210 auto* bufferForCommand() {
211 return modelFor<TCommand>();
222 void init(CommandHandlerRegistry& commandHandlerRegistry, ManagerRegistry& managerRegistry) {
227 for (auto* buffer : commandBufferRegistry_.items()) {
237 void flush(UpdateContext& updateContext) {
238 for (auto* buffer : commandBufferRegistry_.items()) {
239 buffer->flush(updateContext);
247 for (auto* buffer : commandBufferRegistry_.items()) {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.