184 return load(std::move(inputStream), resourceID) | [](
HResource&& resource) {
275 if constexpr(std::is_constructible_v<
T,
ResourceData&, Args...>) {
296 return import(url, std::move(importOptions)) | [](
HResource&& resource) {
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
A context for function object execution.
Definition ExecutionContext.hpp:90
A helper class that wraps and protects a value from non-synchronized access.
Definition Threading.hpp:516
Definition Optional.hpp:17
A stream that provides write-only stream functionality.
Definition Stream.hpp:307
A manager that handles packages, their loading, saving and other runtime related tasks.
Definition PackageManager.hpp:18
An object, provided by the resource manager, to view and alter data from the resource itself.
Definition Resource.hpp:89
Definition ResourceHandle.hpp:23
Definition ResourceHandle.hpp:166
A registry that keeps track of all resource importers for a ResourceManager.
Definition ResourceImporterRegistry.hpp:19
The ResourceManager is the main class responsible for managing and handling all resources in the engi...
Definition ResourceManager.hpp:47
Async< ResourceHandle< T > > load(const ResourceURL url, const Optional< ResourceID > resourceID={})
Definition ResourceManager.hpp:169
PackageManager * getPackageManager() const noexcept
The package manager associated with this resource manager.
Definition ResourceManager.hpp:325
LockedObject< SavingResourcesList > mSavingResources
A list of saving resources.
Definition ResourceManager.hpp:99
ResourceHandle< T > create(Args &&... args)
Create a new resource by constructing it with Args and registers it with the manager.
Definition ResourceManager.hpp:244
void setBaseURL(const ResourceURL &baseURL)
The base URL used to load resources from.
HResource createWithID(const UUID &uuid, ResourcePtr &&resourcePtr)
Registers a new resource with the manager.
Async save(ResourceURL url, HResource resource)
Saves a resource to a URL.
void notifyStrongHandleDestroy(ResourceHandleData *resourceHandleData)
Notifies the manager that the resource pointed by the resource handle is no longer referenced by any ...
Async< HResource > load(ResourceID id)
Loads a resource using a UUID.
ResourceHandle< T > getResource(const StringView name)
Definition ResourceManager.hpp:130
LockedObject< LoadingResourcesList > mLoadingResources
A list of loading resources.
Definition ResourceManager.hpp:89
Async< ResourceHandle< T > > load(InputStream inputStream, const Optional< ResourceID > resourceID={})
Definition ResourceManager.hpp:183
URLSession & mURLSession
The URL session to be used to load resources.
Definition ResourceManager.hpp:52
PackageManager * mPackageManager
The package manager associated with this resource manager.
Definition ResourceManager.hpp:62
LockedObject< LoadedResourceMap > mResources
A map that maps every loaded resource by it's UUID.
Definition ResourceManager.hpp:79
Async< ResourceHandle< T > > locate(const StringView name)
Definition ResourceManager.hpp:149
HResource create(const ResourcePtr &resource)
Registers a new resource with the manager.
Definition ResourceManager.hpp:252
URLSession & getURLSession() const noexcept
The URL session to be used to load resources.
Definition ResourceManager.hpp:319
List< ImportingResource > ImportingResourcesList
A list of importing resources.
Definition ResourceManager.hpp:106
HashMap< UUID, LoadedResource > LoadedResourceMap
A map that maps every loaded resource by it's UUID.
Definition ResourceManager.hpp:76
ResourceURL mBaseURL
The base URL used to load resources from.
Definition ResourceManager.hpp:69
const ResourceURL & getBaseURL() const noexcept
The base URL used to load resources from.
Definition ResourceManager.hpp:313
ResourceDataPtr createResourceData(const UUID &uuid=UUID())
Creates a new ResourceData object for a resource.
HResource createInternal(ResourceData &resourceData, ResourcePtr &&resource)
HResource getResource(const UUID &uuid)
Locates an existing resource by it's UUID.
LockedObject< ImportingResourcesList > mImportingResources
A list of importing resources.
Definition ResourceManager.hpp:109
HResource createWithID(const UUID &uuid, const ResourcePtr &resource)
Registers a new resource with the manager using a known UUID.
Definition ResourceManager.hpp:288
Async< HResource > load(ResourceURL url, Optional< ResourceID > resourceID={})
Loads a resource using a URL.
ResourceHandle< T > getResource(const UUID &uuid)
Definition ResourceManager.hpp:133
Async save(OutputStream outputStream, HResource resource)
Saves a resource to an output stream.
ResourceHandle< T > createWithID(const UUID &uuid, Args &&... args)
Create a new resource by constructing it with Args and registers it with the manager.
Definition ResourceManager.hpp:274
Async< ResourceHandle< T > > load(const ResourceID id)
Definition ResourceManager.hpp:176
HResource getResource(StringView name)
Locates an existing resource by it's name.
List< LoadingResource > LoadingResourcesList
A list of loading resources.
Definition ResourceManager.hpp:86
Async< HResource > load(InputStream inputStream, Optional< ResourceID > resourceID={})
Loads a resource using an existing input stream.
ResourceImporterRegistry importers
The registry that keeps track of registered importers.
Definition ResourceManager.hpp:113
void notifyHandleDestroy(const ResourceHandleData *resourceHandleData)
Notifies the manager that the last resource handle was destroyed.
ExecutionContext & getExecutionContext() const noexcept
The execution context to perform asynchronous resource operations on.
Definition ResourceManager.hpp:322
const SerializationContext & mSerializationContext
A context for the serializer and deserializer to operate on.
Definition ResourceManager.hpp:58
List< SavingResource > SavingResourcesList
A list of saving resources.
Definition ResourceManager.hpp:96
Async< HResource > locate(StringView name)
Loads a resource by it's name.
ResourceManager(URLSession &urlSession, ExecutionContext &executionContext, const SerializationContext &serializationContext=SerializationContext::getDefault())
Creates a new resource manager instance.
~ResourceManager()
Destroys the resource manager and all it's managed resources.
LockedObject< HashMap< UUID, ResourceHandleData * > > mResourceHandles
A map of active resource handles, mapped by their UUID.
Definition ResourceManager.hpp:66
HResource create(ResourcePtr &&resourcePtr)
Registers a new resource with the manager.
ExecutionContext & mExecutionContext
The execution context to perform asynchronous resource operations on.
Definition ResourceManager.hpp:55
A context that is shared between multiple serializer and deserializer instances.
Definition Serialization.hpp:196
static const SerializationContext & getDefault()
Gets the default serialization context to be used in case the user doesn't provide one himself.
A Uniform Resource Identifier (URI) is a unique sequence of characters that identifies a logical or p...
Definition URI.hpp:54
An object that coordinates a group of related, network data transfer tasks.
Definition URLSession.hpp:399
Definition Application.hpp:19
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
cti::continuable< Args... > Async
Defines a non-copyable continuation type which uses the function2 backend for type erasure.
Definition Async.hpp:22
std::list< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > List
List is a container that supports constant time insertion and removal of elements from anywhere in th...
Definition List.hpp:21
std::unordered_map< Key, T, Hash, KeyEqual, ScopedAllocatorAdaptor< StdAllocator< Pair< const Key, T >, RawAllocator > > > HashMap
HashMap is an associative container that contains key-value pairs with unique keys.
Definition Map.hpp:33
SPtr< Resource > ResourcePtr
Definition Forward.hpp:47
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Type that uniquely represents a resource in the resource system.
Definition Resource.hpp:37
A structure that describes options for the loading of a resource.
Definition ResourceManager.hpp:31
Optional< ResourceID > resourceID
A ID to be used as a hint for the loader.
Definition ResourceManager.hpp:34
A structure that describes options for the saving of a resource.
Definition ResourceManager.hpp:38
Represents a universally unique identifier (UUID).
Definition UUID.hpp:27