![]() |
Lysa
0.0
Lysa 3D Engine
|
Generic object/resources manager using ID-based access.
Manages a contiguous pool (vector) of resources of type T addressed by a small integral unique identifier (unique_id). Instances are created into available slots and retrieved via their ID. Destruction returns the slot to a free list for reuse.
The manager does not perform dynamic growth; capacity is fixed at construction. All accessors are O(1) by direct indexing. This class is intended to be used as a base for concrete resource managers (e.g., textures, meshes, materials).
Public Member Functions | |
| template<typename... Args> | |
| T & | create (Args &&...args) |
| T & | operator[] (const unique_id id) |
| const T & | operator[] (const unique_id id) const |
| virtual | ~ResourcesManager () |
| ResourcesManager (ResourcesManager &) = delete | |
| ResourcesManager & | operator= (ResourcesManager &) = delete |
| virtual bool | destroy (const unique_id id) |
| virtual bool | destroy (const T &res) |
| void | use (const unique_id id) |
| bool | have (const unique_id id) const |
| unique_id | getCapacity () const |
Protected Member Functions | |
| ResourcesManager (const size_t capacity, const std::string &name) | |
| T & | allocate (std::unique_ptr< T > instance) |
| bool | isFull () const |
Protected Attributes | |
| std::vector< std::unique_ptr< T > > | resources |
|
inlinevirtual |
|
delete |
|
inlineprotected |
|
inlineprotected |
|
inline |
Create a new unique resource
|
inlinevirtual |
Reimplemented in lysa::MeshManager::destroy(), lysa::ImageManager::destroy()
|
inlinevirtual |
|
inline |
|
inline |
|
inlineprotected |
|
delete |
|
inline |
Bracket operator for mutable access without bounds checking.
| id | The unique identifier of the resource. |
|
inline |
Bracket operator for const access without bounds checking.
| id | The unique identifier of the resource. |
|
inline |
|
protected |