![]() |
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 an 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. Accessors are O(1) by direct indexing.
Public Typedefs | |
| using | UsageGuards = std::vector< std::weak_ptr< const void > > |
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 | destroy (const std::vector< unique_id > &ids) |
| void | use (const unique_id id) |
| bool | have (const unique_id id) const |
| unique_id | getCapacity () const |
| void | setRetirementProvider (std::function< UsageGuards ()> provider) |
| void | collectRetired () |
| void | requireAvailable (const size_t count) |
| template<typename Func > | |
| void | forEach (Func &&func) |
| template<typename Func > | |
| void | forEach (Func &&func) const |
Protected Member Functions | |
| void | enableGrowth (size_t maximum=std::numeric_limits< uint32 >::max ()) |
| 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 |
| std::recursive_mutex | resourcesMutex |
| using UsageGuards = std::vector<std::weak_ptr<const void> > |
Weak frame leases : expiration proves that all submitted GPU uses completed.
|
inlinevirtual |
|
delete |
|
inlineprotected |
|
inlineprotected |
|
inline |
Reclaim slots whose submitted GPU users have completed.
|
inline |
Create a new unique resource
|
inline |
Releases a batch of resources by ID. Each resource is destroyed individually; slots are freed as their reference counters reach zero.
| ids | List of unique identifiers to destroy. |
|
inlinevirtual |
Releases a resource by reference, decrementing its reference counter.
| res | Resource to destroy. |
Reimplemented in lysa::MeshManager::destroy(), lysa::ImageManager::destroy()
|
inlinevirtual |
Releases a resource by ID, decrementing its reference counter. The slot is returned to the free list only when the counter reaches zero.
| id | Unique identifier of the resource to destroy. |
Reimplemented in lysa::MaterialManager::destroy(), lysa::MeshManager::destroy(), lysa::ImageManager::destroy()
|
inline |
|
inline |
|
inline |
|
inline |
returns true if the id is valid
|
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 |
Check that a batch fits before constructing any resources.
|
inline |
Configure deferred slot reuse for managers with GPU-visible IDs.
|
inline |
Increments the reference counter of the resources
|
protected |
|
mutableprotected |