CommonLibSSE (Parapets fork)
GFxResourceWeakLib.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/G/GAtomic.h"
4 #include "RE/G/GFxResourceLib.h"
6 #include "RE/G/GHashSet.h"
7 
8 namespace RE
9 {
11  {
12  public:
14 
15  struct ResourceNode
16  {
17  enum class NodeType
18  {
19  kResource,
20  kResolver,
21  };
22 
24 
25  union
26  {
29  };
30 
31  bool operator==(const GFxResourceKey& a_src) const
32  {
33  assert(resource);
34  if (type == NodeType::kResource) {
35  return resource->GetKey() == a_src;
36  }
37  return resolver->GetKey() == a_src;
38  }
39 
40  bool operator!=(const GFxResourceKey& a_src) const
41  {
42  return operator!=(a_src);
43  }
44 
45  struct HashOp
46  {
47  UPInt operator()(const ResourceNode& a_node) const
48  {
49  assert(a_node.resource);
50  GFxResourceKey key =
51  (a_node.type == NodeType::kResource) ? a_node.resource->GetKey() : a_node.resolver->GetKey();
52  }
53 
54  UPInt operator()(const GFxResourceKey& a_key) const
55  {
56  return GFxResourceKey::HashOp()(a_key);
57  }
58  };
59  };
60 
61  // override (GFxResourceLibBase)
62  void RemoveResourceOnRelease(GFxResource* a_res) override; // 01
63  void PinResource(GFxResource* a_res) override; // 02
64  void UnpinResource(GFxResource* a_res) override; // 03
65 
66  // members
71  };
72  static_assert(sizeof(GFxResourceWeakLib) == 0x50);
73 }
Definition: GFxResourceKey.h:34
Definition: GFxResourceKey.h:6
Definition: GFxResourceLibBase.h:11
Definition: GFxResourceLib.h:19
const GFxResourceKey & GetKey() const
Definition: GFxResourceLib.h:28
Definition: GFxResourceLib.h:16
Definition: GFxResourceWeakLib.h:11
GPtr< GMemoryHeap > imageHeap
Definition: GFxResourceWeakLib.h:70
void RemoveResourceOnRelease(GFxResource *a_res) override
void PinResource(GFxResource *a_res) override
GHashSet< ResourceNode, ResourceNode::HashOp > resources
Definition: GFxResourceWeakLib.h:69
GFxResourceLib * strongLib
Definition: GFxResourceWeakLib.h:67
void UnpinResource(GFxResource *a_res) override
GLock resourceLock
Definition: GFxResourceWeakLib.h:68
Definition: GFxResource.h:15
virtual GFxResourceKey GetKey()
Definition: GHashSet.h:18
Definition: GAtomic.h:6
Definition: GPtr.h:7
Definition: AbsorbEffect.h:6
std::size_t UPInt
Definition: SFTypes.h:5
Definition: GFxResourceWeakLib.h:46
UPInt operator()(const GFxResourceKey &a_key) const
Definition: GFxResourceWeakLib.h:54
UPInt operator()(const ResourceNode &a_node) const
Definition: GFxResourceWeakLib.h:47
Definition: GFxResourceWeakLib.h:16
GFxResource * resource
Definition: GFxResourceWeakLib.h:28
ResourceSlot * resolver
Definition: GFxResourceWeakLib.h:27
bool operator!=(const GFxResourceKey &a_src) const
Definition: GFxResourceWeakLib.h:40
NodeType type
Definition: GFxResourceWeakLib.h:23
NodeType
Definition: GFxResourceWeakLib.h:18
bool operator==(const GFxResourceKey &a_src) const
Definition: GFxResourceWeakLib.h:31