libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
from::resource_request Class Reference

Asynchronous resource loading using the resource capsule system. More...

#include <file.hpp>

Public Member Functions

 resource_request (CS::CSResourceRepository repository, const std::wstring &resource, const std::filesystem::path &source=std::filesystem::path{})
 Construct a new resource request.
 
 resource_request (CS::CSResourceRepository repository, std::wstring &&resource, const std::filesystem::path &source=std::filesystem::path{})
 Construct a new resource request (string move constructor).
 
 resource_request (const resource_request &)=delete
 
 resource_request (resource_request &&) noexcept=delete
 
resource_requestoperator= (const resource_request &)=delete
 
resource_requestoperator= (resource_request &&) noexcept=delete
 
bool ready () const noexcept
 Check if the resource request is ready.
 
liber::optref< FD4::FD4ResCapget () const noexcept
 Block until the resource request is ready and get the result.
 
liber::optref< FD4::FD4ResCapcheck () const noexcept
 Get the request result whether it had finished or not.
 

Detailed Description

Asynchronous resource loading using the resource capsule system.

Request a resource to be loaded/unloaded/reloaded from a specified resource repository and a file (if provided). The operation is executed asynchronously and the result may be acquired from the request whenever it is ready.

Note
Has a throwing constructor (from::file_request): if a file on disk is not found, or if a file extension is not supported, an std::filesystem::filesystem_error is thrown.

Constructor & Destructor Documentation

◆ resource_request() [1/2]

from::resource_request::resource_request ( CS::CSResourceRepository  repository,
const std::wstring &  resource,
const std::filesystem::path &  source = std::filesystem::path{} 
)
inline

Construct a new resource request.

Parameters
repositorythe repository to search for the resource
resourcethe name of the resource
sourcea file path passed to from::file_request (optional)

◆ resource_request() [2/2]

from::resource_request::resource_request ( CS::CSResourceRepository  repository,
std::wstring &&  resource,
const std::filesystem::path &  source = std::filesystem::path{} 
)
inline

Construct a new resource request (string move constructor).

Parameters
repositorythe repository to search for the resource
resourcethe name of the resource
sourcea file path passed to from::file_request (optional)

Member Function Documentation

◆ check()

liber::optref< FD4::FD4ResCap > from::resource_request::check ( ) const
inlinenoexcept

Get the request result whether it had finished or not.

The absense of a value does not indicate that the request is still not ready, as it simply may have failed to find the resource. Use from::resource_request::ready for that purpose instead.

Returns
liber::optref<FD4::FD4ResCap>

◆ get()

liber::optref< FD4::FD4ResCap > from::resource_request::get ( ) const
inlinenoexcept

Block until the resource request is ready and get the result.

Note
Polling may be preferrable to blocking in an environment where a deadlock may occur. Never call this method from a task.

A resource request finishing does not mean it contains a value; it's possible the file was not found.

See also
Polling options: from::resource_request::ready, from::file_request::check
Returns
liber::optref<FD4::FD4ResCap>

◆ ready()

bool from::resource_request::ready ( ) const
inlinenoexcept

Check if the resource request is ready.

Does not block.

Note
A resource request finishing does not mean it contains a value; it's possible the resource was not found.
Returns
true
false

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