Diligent Engine  v.2.4.g
ResourceMapping.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include "DeviceObject.h"
34 
36 
37 // {6C1AC7A6-B429-4139-9433-9E54E93E384A}
38 static const INTERFACE_ID IID_ResourceMapping =
39  {0x6c1ac7a6, 0xb429, 0x4139, {0x94, 0x33, 0x9e, 0x54, 0xe9, 0x3e, 0x38, 0x4a}};
40 
43 {
44  // clang-format off
45 
47  const Char* Name DEFAULT_INITIALIZER(nullptr);
48 
51 
52  Uint32 ArrayIndex DEFAULT_INITIALIZER(0);
53 
54 
55 #if DILIGENT_CPP_INTERFACE
56  ResourceMappingEntry() noexcept {}
57 
59 
63  ResourceMappingEntry (const Char* _Name, IDeviceObject* _pObject, Uint32 _ArrayIndex = 0)noexcept :
64  Name { _Name },
65  pObject { _pObject },
66  ArrayIndex{_ArrayIndex}
67  {}
68  // clang-format on
69 #endif
70 };
72 
73 
76 {
81 
82 #if DILIGENT_CPP_INTERFACE
84  {}
85 
86  explicit ResourceMappingDesc(ResourceMappingEntry* _pEntries) noexcept :
87  pEntries{_pEntries}
88  {}
89 #endif
90 };
92 
93 #define DILIGENT_INTERFACE_NAME IResourceMapping
94 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
95 
96 #define IResourceMappingInclusiveMethods \
97  IObjectInclusiveMethods; \
98  IResourceMappingMethods ResourceMapping
99 
100 // clang-format off
101 
103 
108 {
110 
119  VIRTUAL void METHOD(AddResource)(THIS_
120  const Char* Name,
121  IDeviceObject* pObject,
122  bool bIsUnique) PURE;
123 
124 
126 
137  VIRTUAL void METHOD(AddResourceArray)(THIS_
138  const Char* Name,
139  Uint32 StartIndex,
140  IDeviceObject* const* ppObjects,
141  Uint32 NumElements,
142  bool bIsUnique) PURE;
143 
144 
146 
149  VIRTUAL void METHOD(RemoveResourceByName)(THIS_
150  const Char* Name,
151  Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE;
152 
154 
162  VIRTUAL void METHOD(GetResource)(THIS_
163  const Char* Name,
164  IDeviceObject** ppResource,
165  Uint32 ArrayIndex DEFAULT_VALUE(0)) PURE;
166 
168  VIRTUAL size_t METHOD(GetSize)(THIS) PURE;
169 };
171 
172 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
173 
174 #if DILIGENT_C_INTERFACE
175 
176 // clang-format off
177 
178 # define IResourceMapping_AddResource(This, ...) CALL_IFACE_METHOD(ResourceMapping, AddResource, This, __VA_ARGS__)
179 # define IResourceMapping_AddResourceArray(This, ...) CALL_IFACE_METHOD(ResourceMapping, AddResourceArray, This, __VA_ARGS__)
180 # define IResourceMapping_RemoveResourceByName(This, ...) CALL_IFACE_METHOD(ResourceMapping, RemoveResourceByName, This, __VA_ARGS__)
181 # define IResourceMapping_GetResource(This, ...) CALL_IFACE_METHOD(ResourceMapping, GetResource, This, __VA_ARGS__)
182 # define IResourceMapping_GetSize(This) CALL_IFACE_METHOD(ResourceMapping, GetSize, This)
183 
184 // clang-format on
185 
186 #endif
187 
188 DILIGENT_END_NAMESPACE // namespace Diligent
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
VIRTUAL
#define VIRTUAL
Definition: DefineInterfaceHelperMacros.h:83
Diligent::Char
char Char
Definition: BasicTypes.h:64
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
Diligent::ResourceMappingDesc
Resource mapping description.
Definition: ResourceMapping.h:75
Diligent::IDeviceObject
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:52
THIS
#define THIS
Definition: DefineInterfaceHelperMacros.h:81
PURE
#define PURE
Definition: DefineInterfaceHelperMacros.h:85
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
Diligent::ResourceMappingDesc::ResourceMappingDesc
ResourceMappingDesc() noexcept
Definition: ResourceMapping.h:83
Diligent::ResourceMappingEntry::ResourceMappingEntry
ResourceMappingEntry() noexcept
Definition: ResourceMapping.h:56
Diligent::ResourceMappingDesc::ResourceMappingDesc
ResourceMappingDesc(ResourceMappingEntry *_pEntries) noexcept
Definition: ResourceMapping.h:86
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
DEFAULT_INITIALIZER
#define DEFAULT_INITIALIZER(x)
Definition: CommonDefinitions.h:93
Diligent::ResourceMappingEntry::ResourceMappingEntry
ResourceMappingEntry(const Char *_Name, IDeviceObject *_pObject, Uint32 _ArrayIndex=0) noexcept
Initializes the structure members.
Definition: ResourceMapping.h:63
DeviceObject.h
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
DEFAULT_VALUE
#define DEFAULT_VALUE(x)
Definition: CommonDefinitions.h:99
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
Diligent::ResourceMappingEntry
Describes the resourse mapping object entry.
Definition: ResourceMapping.h:42
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
THIS_
#define THIS_
Definition: DefineInterfaceHelperMacros.h:82
Diligent::IResourceMapping
Resouce mapping.
Definition: ResourceMapping.h:107