12#include <detail/preprocessor.hpp>
32#define LIBER_RESOURCE_REPOSITORY(NAME) NAME,
34#include <coresystem/file/resource_repositories.inl>
36#undef LIBER_RESOURCE_REPOSITORY
47 FD4_SINGLETON_CLASS(
CSFile);
49 virtual ~CSFile() LIBER_INTERFACE_ONLY;
57 return this->file_repository;
130 : path(file), type(type) {
131 this->init_request();
153 : path(file), type(type) {
154 this->init_request();
164 this->is_ready.test_and_set();
165 this->is_ready.notify_all();
180 return is_ready.test();
198 this->is_ready.wait(
false);
199 return this->
check();
212 return this->file_cap;
220 void*,
void*,
void*,
void*);
223 LIBERAPI
void init_request();
225 std::filesystem::path path;
227 bool is_vfs_path =
false;
228 bool unload_file =
false;
229 enum class file_extension_type :
char {
233 } file_extension = file_extension_type::ANY;
236 mutable std::atomic_flag is_ready = ATOMIC_FLAG_INIT;
238 file_request_task(
file_request& request) : request(request) {}
239 LIBERAPI
void eztask_execute(FD4::FD4TaskData*)
override;
240 file_request& request;
243 from::make_unique<file_request_task>(*
this);
268 const std::wstring& resource,
269 const std::filesystem::path& source = std::filesystem::path{})
270 : repository(repository), resource(resource),
273 this->task->register_task(CS::CSTaskGroup::FileStepUpdate_End);
284 std::wstring&& resource,
285 const std::filesystem::path& source = std::filesystem::path{})
286 : repository(repository), resource(resource),
289 this->task->register_task(CS::CSTaskGroup::FileStepUpdate_End);
292 resource_request(
const resource_request&) =
delete;
293 resource_request(resource_request&&) noexcept = delete;
295 resource_request& operator=(const resource_request&) = delete;
296 resource_request& operator=(resource_request&&) noexcept = delete;
298 ~resource_request() noexcept {
299 this->is_ready.test_and_set();
300 this->is_ready.notify_all();
315 return is_ready.test();
333 this->is_ready.wait(
false);
334 return this->
check();
349 return *this->res_cap;
354 std::wstring resource;
355 std::unique_ptr<file_request> file;
357 mutable std::atomic_flag is_ready = ATOMIC_FLAG_INIT;
360 LIBERAPI
void eztask_execute(FD4::FD4TaskData*)
override;
361 resource_request& request;
364 from::make_unique<resource_request_task>(*
this);
Inherit from this minimal task interface to create a custom task.
Definition task.hpp:51
File repository for Wwise banks.
Definition file.hpp:70
A singleton responsible for file management.
Definition file.hpp:45
FD4::FD4ResRep * get_file_repository() noexcept
Get the file repository.
Definition file.hpp:56
Abstract file capsule class.
Definition resource.hpp:239
The base of any resource, which can also be a file or a repository.
Definition resource.hpp:120
Abstract resource repository class.
Definition resource.hpp:316
Asynchronous file loading using the file capsule system.
Definition file.hpp:90
file_request(const std::filesystem::path &file, file_request_type type)
Construct a new file request.
Definition file.hpp:129
bool ready() const noexcept
Check if the file request is ready.
Definition file.hpp:179
FD4::FD4FileCap *(*)(CS::CSFile *, const wchar_t *, void *, void *, void *, void *) loader_type
File capsule loader callback signature, for internal use.
Definition file.hpp:220
liber::optref< FD4::FD4FileCap > check() const noexcept
Get the request result whether it had finished or not.
Definition file.hpp:211
file_request(std::filesystem::path &&file, file_request_type type)
Construct a new file request (path move constructor).
Definition file.hpp:152
liber::optref< FD4::FD4FileCap > get() const noexcept
Block until the file request is ready and get the result.
Definition file.hpp:197
file_request_type
Supported request types.
Definition file.hpp:105
Asynchronous resource loading using the resource capsule system.
Definition file.hpp:258
liber::optref< FD4::FD4ResCap > check() const noexcept
Get the request result whether it had finished or not.
Definition file.hpp:346
bool ready() const noexcept
Check if the resource request is ready.
Definition file.hpp:314
liber::optref< FD4::FD4ResCap > get() const noexcept
Block until the resource request is ready and get the result.
Definition file.hpp:332
resource_request(CS::CSResourceRepository repository, std::wstring &&resource, const std::filesystem::path &source=std::filesystem::path{})
Construct a new resource request (string move constructor).
Definition file.hpp:283
resource_request(CS::CSResourceRepository repository, const std::wstring &resource, const std::filesystem::path &source=std::filesystem::path{})
Construct a new resource request.
Definition file.hpp:267
CSResourceRepository
All resource repositories supported by libER.
Definition file.hpp:31
from::shared_ptr based on std::shared_ptr
from::unique_ptr based on std::unique_ptr
std::unique_ptr< T, from::delay_delete< T, AllocatorTag > > unique_ptr
std::unique_ptr with from::allocator and from::delay_delete.
Definition from_unique_ptr.hpp:22
Optional references based on std::optional.
FD4_SINGLETON_CLASS implementation.
A std::optional<std::reference_wrapper<T>> wrapper for lvalue references.
Definition optref.hpp:31
Namespace CS task interface.