Skip to main content

InternalBuffer Class Template

Per-command-type storage and dispatch unit. More...

Declaration

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

Public Member Typedefs Index

template <typename TCommandType>
usingEngineRoleTag = CommandBufferRole

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

Public Constructors Index

template <typename TCommandType>
InternalBuffer ()

Reserves default capacity for the command vector. More...

Public Member Functions Index

template <typename TCommandType>
voidflush (UpdateContext &updateContext)

Forwards all buffered commands to the handler registry and clears the buffer. More...

template <typename TCommandType>
voidclear ()

Discards all buffered commands without dispatching them. More...

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

Wires this buffer to the handler and manager registries. More...

template <typename ... TArgs>
voidadd (TArgs &&... args)

Enqueues a new command, constructing it in-place from args. More...

Private Member Attributes Index

template <typename TCommandType>
CommandHandlerRegistry *commandHandlerRegistry_ {nullptr}

Registry used to submit commands to their handlers on first flush. More...

template <typename TCommandType>
ManagerRegistry *managerRegistry_ {nullptr}

Registry used to resolve the EntityMutationManager on first flush. More...

template <typename TCommandType>
boolhandlerRegistered_ {false}

true once the handler for TCommandType has been registered. More...

template <typename TCommandType>
EntityMutationManager< TEntityManager > *entityMutationManager_ {nullptr}

Cached pointer to the EntityMutationManager; resolved lazily on first flush. More...

template <typename TCommandType>
std::vector< TCommandType >commands_

Description

Per-command-type storage and dispatch unit.

Created lazily by EntityMutationCommandBuffer::modelFor<TCommand>(). On flush() every buffered command is forwarded to the CommandHandlerRegistry, which routes it to the EntityMutationManager.

Template Parameters
TCommandType

ECS command struct to buffer (e.g. AddComponentCommand<C>).

Definition at line 70 of file EntityMutationCommandBuffer.ixx.

Public Member Typedefs

EngineRoleTag

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

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

Definition at line 88 of file EntityMutationCommandBuffer.ixx.

Public Constructors

InternalBuffer()

template <typename TCommandType>
helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::InternalBuffer< TCommandType >::InternalBuffer ()
inline

Reserves default capacity for the command vector.

Definition at line 91 of file EntityMutationCommandBuffer.ixx.

91 InternalBuffer() {
93 }

Public Member Functions

add()

template <typename ... TArgs>
void helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::InternalBuffer< TCommandType >::add (TArgs &&... args)
inline

Enqueues a new command, constructing it in-place from args.

Template Parameters
TArgs

Constructor argument types for TCommandType.

Parameters
args

Arguments forwarded to the TCommandType constructor.

Definition at line 141 of file EntityMutationCommandBuffer.ixx.

141 void add(TArgs&&... args) {
142 commands_.emplace_back(std::forward<TArgs>(args)...);
143 }

clear()

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

Discards all buffered commands without dispatching them.

Definition at line 119 of file EntityMutationCommandBuffer.ixx.

119 void clear() {
120 commands_.clear();
121 }

flush()

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

Forwards all buffered commands to the handler registry and clears the buffer.

info

This method must not be called in parallel running tasks.

Parameters
updateContext

Frame-local update context (passed through to handlers).

Definition at line 102 of file EntityMutationCommandBuffer.ixx.

102 void flush(UpdateContext& updateContext) {
103
104 if (!handlerRegistered_) {
105 auto* entityMutationManager_ = managerRegistry_->item<EntityMutationManager<TEntityManager>>();
106 assert(entityMutationManager_ && "EntityMutationManager for the specified handle is not initialized.");
107 commandHandlerRegistry_->handleCommands<TCommandType>(*entityMutationManager_);
108 handlerRegistered_ = true;
109 }
110
111 for (auto& cmd : commands_) {
112 commandHandlerRegistry_->submit<TCommandType>(std::move(cmd));
113 }
114
115 clear();
116 }

init()

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

Wires this buffer to the handler and manager registries.

Parameters
commandHandlerRegistry

Registry used to route commands to their handlers.

managerRegistry

Registry providing the EntityMutationManager<>.

Definition at line 129 of file EntityMutationCommandBuffer.ixx.

129 void init(CommandHandlerRegistry& commandHandlerRegistry, ManagerRegistry& managerRegistry) {
130 commandHandlerRegistry_ = &commandHandlerRegistry;
131 managerRegistry_ = &managerRegistry;
132 }

Private Member Attributes

commandHandlerRegistry_

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

Registry used to submit commands to their handlers on first flush.

Definition at line 73 of file EntityMutationCommandBuffer.ixx.

73 CommandHandlerRegistry* commandHandlerRegistry_{nullptr};

commands_

template <typename TCommandType>
std::vector<TCommandType> helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::InternalBuffer< TCommandType >::commands_

Definition at line 84 of file EntityMutationCommandBuffer.ixx.

84 std::vector<TCommandType> commands_;

entityMutationManager_

template <typename TCommandType>
EntityMutationManager<TEntityManager>* helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::InternalBuffer< TCommandType >::entityMutationManager_ {nullptr}

Cached pointer to the EntityMutationManager; resolved lazily on first flush.

Definition at line 82 of file EntityMutationCommandBuffer.ixx.

82 EntityMutationManager<TEntityManager>* entityMutationManager_{nullptr};

handlerRegistered_

template <typename TCommandType>
bool helios::engine::runtime::messaging::command::EntityMutationCommandBuffer< TEntityManager >::InternalBuffer< TCommandType >::handlerRegistered_ {false}

true once the handler for TCommandType has been registered.

Definition at line 79 of file EntityMutationCommandBuffer.ixx.

79 bool handlerRegistered_{false};

managerRegistry_

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

Registry used to resolve the EntityMutationManager on first flush.

Definition at line 76 of file EntityMutationCommandBuffer.ixx.

76 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.