Cogs.Core
Classes | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Cogs::Core::ResourcePointerMap Struct Reference

Structure to hold a set of pointers with constant time insertion and removal. More...

Classes

struct  PointerEntry
 

Public Member Functions

uint32_t insert (ResourceBase *ptr)
 
void remove (uint32_t slot)
 
size_t size () const
 
std::span< const PointerEntryview () const
 

Static Public Attributes

static constexpr uint32_t NoSlot = static_cast<uint32_t>(-1)
 
static constexpr uint32_t NotFree = static_cast<uint32_t>(-2)
 

Private Attributes

std::vector< PointerEntryslots
 
uint32_t free = NoSlot
 
size_t numUsed = 0u
 

Detailed Description

Structure to hold a set of pointers with constant time insertion and removal.

The pointers are stored in a contiguous array which can be iterated over.

Definition at line 30 of file ResourceManagerBase.cpp.

Member Function Documentation

◆ insert()

uint32_t Cogs::Core::ResourcePointerMap::insert ( ResourceBase ptr)
inline

Insert the given pointer into the map. The returned index can be used to remove the pointer at a later time.

Definition at line 42 of file ResourceManagerBase.cpp.

◆ remove()

void Cogs::Core::ResourcePointerMap::remove ( uint32_t  slot)
inline

Remove the pointer at the given index. Typical problem if code asserts is double release.

Definition at line 63 of file ResourceManagerBase.cpp.

◆ size()

size_t Cogs::Core::ResourcePointerMap::size ( ) const
inline

Definition at line 79 of file ResourceManagerBase.cpp.

◆ view()

std::span< const PointerEntry > Cogs::Core::ResourcePointerMap::view ( ) const
inline

Returns a view to the stored slots. Includes both active and deleted entries. Must check resource != nullptr

Definition at line 86 of file ResourceManagerBase.cpp.

Member Data Documentation

◆ free

uint32_t Cogs::Core::ResourcePointerMap::free = NoSlot
private

Definition at line 93 of file ResourceManagerBase.cpp.

◆ NoSlot

constexpr uint32_t Cogs::Core::ResourcePointerMap::NoSlot = static_cast<uint32_t>(-1)
staticconstexpr

Definition at line 32 of file ResourceManagerBase.cpp.

◆ NotFree

constexpr uint32_t Cogs::Core::ResourcePointerMap::NotFree = static_cast<uint32_t>(-2)
staticconstexpr

Definition at line 33 of file ResourceManagerBase.cpp.

◆ numUsed

size_t Cogs::Core::ResourcePointerMap::numUsed = 0u
private

Definition at line 94 of file ResourceManagerBase.cpp.

◆ slots

std::vector<PointerEntry> Cogs::Core::ResourcePointerMap::slots
private

Definition at line 92 of file ResourceManagerBase.cpp.


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