ECSTASY
All in the name
Loading...
Searching...
No Matches
ecstasy::DeletionStack Class Reference

Helper to manage entity deletion safely within an iteration. More...

#include <DeletionStack.hpp>

Collaboration diagram for ecstasy::DeletionStack:

Public Member Functions

 DeletionStack (Registry &registry)
 Construct a new Deletion Stack attached to a given registry.
 
 DeletionStack (const DeletionStack &other)=delete
 Deleted copy constructor.
 
 ~DeletionStack ()
 Destroy the Deletion Stack, calling Registry::eraseEntities() with all the entity marked for deletion using push().
 
void push (Entity entity)
 Mark an entity for deletion upon destruction of this instance.
 
size_t size () const noexcept
 Return the number of entities marked for deletion.
 

Private Attributes

Registry_registry
 Registry attached to this stack.
 
std::vector< Entity_killed
 Entities marked for deletion.
 

Detailed Description

Helper to manage entity deletion safely within an iteration.

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-21)

Definition at line 30 of file DeletionStack.hpp.

Constructor & Destructor Documentation

◆ DeletionStack() [1/2]

ecstasy::DeletionStack::DeletionStack ( Registry registry)

Construct a new Deletion Stack attached to a given registry.

Parameters
[in]registryRegistry attached with the entities to delete.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-21)

Definition at line 17 of file DeletionStack.cpp.

17 : _registry(registry)
18 {
19 }
Registry & _registry
Registry attached to this stack.

◆ DeletionStack() [2/2]

ecstasy::DeletionStack::DeletionStack ( const DeletionStack other)
delete

Deleted copy constructor.

Parameters
[in]otherStack to copy.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-21)

◆ ~DeletionStack()

ecstasy::DeletionStack::~DeletionStack ( )

Destroy the Deletion Stack, calling Registry::eraseEntities() with all the entity marked for deletion using push().

Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-21)

Definition at line 21 of file DeletionStack.cpp.

22 {
23 if (_killed.size() > 0)
25 }
std::vector< Entity > _killed
Entities marked for deletion.
size_t eraseEntities(std::span< Entity > entities)
Instantly erase multiple entities and their components from the registry.
Definition Registry.cpp:62

Member Function Documentation

◆ push()

void ecstasy::DeletionStack::push ( Entity  entity)

Mark an entity for deletion upon destruction of this instance.

Parameters
[in]entityentity to delete.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-21)

Definition at line 27 of file DeletionStack.cpp.

28 {
29 _killed.push_back(entity);
30 }

◆ size()

size_t ecstasy::DeletionStack::size ( ) const
noexcept

Return the number of entities marked for deletion.

Returns
size_t number of entities marked for deletion.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-21)

Definition at line 32 of file DeletionStack.cpp.

33 {
34 return _killed.size();
35 }

Member Data Documentation

◆ _killed

std::vector<Entity> ecstasy::DeletionStack::_killed
private

Entities marked for deletion.

Definition at line 85 of file DeletionStack.hpp.

◆ _registry

Registry& ecstasy::DeletionStack::_registry
private

Registry attached to this stack.

Definition at line 83 of file DeletionStack.hpp.


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