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