1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/*
* Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#ifndef RESOURCE_PROVIDER_H
#define RESOURCE_PROVIDER_H
/*!
\file
\brief class ResourceProvider
*/
#include "ApexUsingNamespace.h"
namespace nvidia
{
namespace apex
{
class ResourceCallback;
PX_PUSH_PACK_DEFAULT
/*!
\brief A user provided class for mapping names to pointers or integers
Named resource provider - a name-to-pointer utility. User must provide the pointed-to data.
- also supports name-to-integer
*/
class ResourceProvider
{
public:
/**
\brief Register a callback
Register a callback function for unresolved named resources. This function will be called by APEX when
an unresolved named resource is requested. The function will be called at most once for each named
resource. The function must directly return the pointer to the resource or NULL.
*/
virtual void registerCallback(ResourceCallback* impl) = 0;
/**
\brief Provide the pointer for the specified named resource
*/
virtual void setResource(const char* nameSpace, const char* name, void* resource, bool incRefCount = false) = 0;
/**
\brief Provide the unsigned integer for the specified named resource
*/
virtual void setResourceU32(const char* nameSpace, const char* name, uint32_t id, bool incRefCount = false) = 0;
/**
\brief Retrieve the pointer to the specified named resource.
The game application (level loader) may use this to find assets by
name, as a convenience. If the named resource has not yet been
loaded it will trigger a call to ResourceCallback::requestResource(),
assuming an ResourceCallback instance was registered with the APEX SDK.
If the named resource has already been loaded, getResource will not
increment the reference count.
*/
virtual void* getResource(const char* nameSpace, const char* name) = 0;
/**
\brief Releases all resources in this namespace.
\return the total number of resources released.
*/
virtual uint32_t releaseAllResourcesInNamespace(const char* nameSpace) = 0;
/**
\brief Releases a single resource.
\return the outstanding referernce count after the release is performed.
*/
virtual uint32_t releaseResource(const char* nameSpace, const char* name) = 0;
/**
\brief Reports if a current resource exists and, if so, the reference count.
*/
virtual bool findRefCount(const char* nameSpace, const char* name, uint32_t& refCount) = 0;
/**
\brief Locates an existing resource
This function will *not* call back to the application if the resource does not exist.
Only reports currently set resources.
*/
virtual void* findResource(const char* nameSpace, const char* name) = 0;
/**
\brief Locates an existing integer resource.
*/
virtual uint32_t findResourceU32(const char* nameSpace, const char* name) = 0;
/**
\brief Returns a list of all resources in a particular namespace.
*/
virtual void** findAllResources(const char* nameSpace, uint32_t& count) = 0;
/**
\brief Returns a list of the names of all resources within a particular namespace
*/
virtual const char** findAllResourceNames(const char* nameSpace, uint32_t& count) = 0;
/**
\brief Returns a list of all registered namespaces.
*/
virtual const char** findNameSpaces(uint32_t& count) = 0;
/**
\brief Write contents of resource table to error stream.
*/
virtual void dumpResourceTable() = 0;
/**
\brief Returns if the resource provider is operating in a case sensitive mode.
\note By default the resource provider is NOT case sensitive
\note It's not possible to change the case sensitivity of the NRP
once the APEX SDK is created, so the the switch is available in the
ApexSDKDesc::resourceProviderIsCaseSensitive member variable.
*/
virtual bool isCaseSensitive() = 0;
};
PX_POP_PACK
}
} // end namespace nvidia::apex
#endif // RESOURCE_PROVIDER_H
|