CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::EntityIDAllocator Class Reference

#include <CeresEngine/Entity/EntityID.hpp>

Public Member Functions

EntityID allocate () noexcept
 Allocates a new entity ID from the allocator.
 
Vector< EntityIDallocate (EntityIndex n) noexcept
 Allocates n new entity IDs.
 
void release (EntityID entityID) noexcept
 Releases a previously allocated entity ID.
 
EntityVersion getLatestVersion (EntityIndex index) const noexcept
 Gets the latest version of a given entity index.
 

Private Attributes

HashMap< EntityIndex, EntityVersionmEntityVersions
 A map of entity versions, indexed by their entity indexes.
 
EntityIndex mNextEntityIndex = 0
 The EntityIndex for the next entity allocation if the freeList is empty.
 
Vector< EntityIDmFreeList
 A list of free entities that are ready to be reused.
 

Member Function Documentation

◆ allocate() [1/2]

EntityID CeresEngine::EntityIDAllocator::allocate ( )
noexcept

Allocates a new entity ID from the allocator.

Returns
The newly allocated entity ID.

◆ allocate() [2/2]

Vector< EntityID > CeresEngine::EntityIDAllocator::allocate ( EntityIndex  n)
noexcept

Allocates n new entity IDs.

Parameters
nThe number of entity IDs to allocate
Returns
A vector of the n allocated entity IDs

◆ getLatestVersion()

EntityVersion CeresEngine::EntityIDAllocator::getLatestVersion ( EntityIndex  index) const
noexcept

Gets the latest version of a given entity index.

◆ release()

void CeresEngine::EntityIDAllocator::release ( EntityID  entityID)
noexcept

Releases a previously allocated entity ID.

Parameters
entityIDThe entity ID to be released.

Member Data Documentation

◆ mEntityVersions

HashMap<EntityIndex, EntityVersion> CeresEngine::EntityIDAllocator::mEntityVersions
private

A map of entity versions, indexed by their entity indexes.

◆ mFreeList

Vector<EntityID> CeresEngine::EntityIDAllocator::mFreeList
private

A list of free entities that are ready to be reused.

◆ mNextEntityIndex

EntityIndex CeresEngine::EntityIDAllocator::mNextEntityIndex = 0
private

The EntityIndex for the next entity allocation if the freeList is empty.


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