API Documentation
Loading...
Searching...
No Matches
ResourceResolver.h
Go to the documentation of this file.
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/Buffer.h>
4#include <NDEVR/String.h>
5namespace NDEVR
6{
7 /**--------------------------------------------------------------------------------------------------
8 Class: ResourceResolver
9
10 \brief This class resolves resources, or data identified by a string. The data absolute path is then passed
11 on to an on_finished function. Resources may be online, in a packed file, or in a spot not easily
12 accessable. static Class stores any number of resolvers who take in a resource, and try to find it.
13
14 Author: Tyler Parke
15
16 Date: 2024-11-15
17 *-----------------------------------------------------------------------------------------------**/
19 {
20 public:
21 /**--------------------------------------------------------------------------------------------------
22 Fn: ResourceResolver::resolveResource(const String& resource, const std::function<void(bool, const String&)>& on_finished, bool ensure_unzipped);
23
24 \brief Attempts to resolved a resource. Resource could be in an online or offline database, inside a resource
25 or rcc file, or in a local file. Funciton is ascynchronous and resource may not be resolved on return.
26 on_finished is used as a callback for when the resource is resolved, or fails to resolve
27
28 Parameters:
29 resource - The resource to be resolved.
30 on_finished - The callback which will be called, likely asyncronously, when the resource is resolved.
31 The first parameter is a bool representing success, the second is a string with the absolute
32 resource location.
33 ensure_unzipped - If true, the resource will be unzipped and placed in a path where it can be instantly
34 accessed. If true, the second parameter will be a file path.
35
36 Returns: true if the resource MAY be resolved, false if it will certainly not be resolved.
37 Date: 2024-11-15
38 *-----------------------------------------------------------------------------------------------**/
39 static bool ResolveResource(const String& resource, const std::function<void(bool, const String&)>& on_finished = nullptr, bool ensure_unzipped = false);
40
41 /**--------------------------------------------------------------------------------------------------
42 Fn: ResourceResolver::CheckAndUnzipResource(const String& resource, const std::function<void(bool, const String&)>& on_finished);
43
44 \brief Same as ResolveResource(xx,xx, true)
45
46 Parameters:
47 resource - The resource to be resolved.
48 on_finished - he callback which will be called, likely asyncronously, when the resource is resolved.
49 The first parameter is a bool representing success, the second is a string with the absolute
50 resource location.
51
52 Returns: true if the resource MAY be resolved, false if it will certainly not be resolved.
53 Date: 2024-11-15
54 *-----------------------------------------------------------------------------------------------**/
55 static bool CheckAndUnzipResource(const String& resource, const std::function<void(bool, const String&)>& on_finished = nullptr);
56
57
58 static void AddResolver(ResourceResolver* resolver);
59 protected:
60 virtual bool resolveResource(const String& resource, const std::function<void(bool, const String&)>& on_finished = nullptr, bool ensure_unzipped = false) = 0;
61 protected:
63 };
64}
#define NDEVR_BASE_API
Definition DLLInfo.h:78
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
This class resolves resources, or data identified by a string. The data absolute path is then passed ...
Definition ResourceResolver.h:19
virtual bool resolveResource(const String &resource, const std::function< void(bool, const String &)> &on_finished=nullptr, bool ensure_unzipped=false)=0
static Buffer< ResourceResolver * > s_resolvers
Definition ResourceResolver.h:62
Definition String.h:40
Definition ACIColor.h:37