SpiecsEngine
 
Loading...
Searching...
No Matches
Spices::ResourcePool< T > Class Template Reference

Template ResourcePool Class. This class will assign Every Type of Resource per Pool. When we ask for resource, we will get from here instead of load it from disk indirectly. Now we use file path as resource identity. More...

#include <ResourcePool.h>

Public Member Functions

 ResourcePool ()=default
 Constructor Function.
 
virtual ~ResourcePool ()=default
 Destructor Function.
 
 ResourcePool (const ResourcePool &)=delete
 Copy Constructor Function.
 
ResourcePooloperator= (const ResourcePool &)=delete
 Copy Constructor Function.
 

Static Public Member Functions

template<typename Ty , typename ... Args>
static std::shared_ptr< T > Load (const std::string &path, Args... args)
 Load a resource by path. When we need a resource, we call this API. Load if resource is not found.
 
static std::shared_ptr< T > Access (const std::string &path)
 Access a resource by path directly. Do nothing if resource is not found.
 
static void UnLoad (const std::string &path)
 UnLoad a resource by path.
 
static bool Has (const std::string &name)
 Determine if specific resource is exist.
 
static void Registry (const std::string &name, std::shared_ptr< T > resource)
 Registry a resource to this Pool.
 
static void Destroy ()
 Destroy this resource pool. Release all Resource Pointer, which means resource can be destructed after called this API.
 

Static Private Attributes

static std::unordered_map< std::string, std::unique_ptr< Resource > > m_Resources
 Static variable stores all specific resources in a basic type Pool.
 
static std::shared_mutex m_Mutex
 Mutex for this pool.
 

Detailed Description

template<typename T>
class Spices::ResourcePool< T >

Template ResourcePool Class. This class will assign Every Type of Resource per Pool. When we ask for resource, we will get from here instead of load it from disk indirectly. Now we use file path as resource identity.

Template Parameters
TResource basic Class.
Todo
Use UUID as resource identity instead.

Definition at line 27 of file ResourcePool.h.


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