CommonLibSSE (powerof3)
ExtraDataList.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSAtomic.h"
4 #include "RE/B/BSExtraData.h"
5 #include "RE/B/BSPointerHandle.h"
6 #include "RE/E/ExtraDataTypes.h"
7 #include "RE/E/ExtraFlags.h"
8 #include "RE/F/FormTypes.h"
9 #include "RE/M/MemoryManager.h"
10 #include "RE/S/SoulLevels.h"
11 
12 namespace RE
13 {
14  class InventoryChanges;
15  class TESBoundObject;
16 
18  {
19  public:
21  {
22  public:
23  [[nodiscard]] bool HasType(std::uint32_t a_type) const;
24  void MarkType(std::uint32_t a_type, bool a_cleared);
25 
26  // members
27  std::uint8_t bits[0x18]; // 00
28  };
29  static_assert(sizeof(PresenceBitfield) == 0x18);
30 
31  virtual ~BaseExtraList(); // 00
32 
33  // members
34  BSExtraData* data = nullptr; // 08
35  PresenceBitfield* presence = nullptr; // 10
36  };
37  static_assert(sizeof(BaseExtraList) == 0x18);
38 
40  {
41  public:
42  template <class T>
44  {
45  public:
46  using difference_type = std::ptrdiff_t;
47  using value_type = T;
48  using pointer = value_type*;
50  using iterator_category = std::forward_iterator_tag;
51 
52  constexpr iterator_base() noexcept :
53  _cur(nullptr)
54  {}
55 
56  constexpr iterator_base(pointer a_node) noexcept :
57  _cur(a_node)
58  {}
59 
60  constexpr iterator_base(const iterator_base& a_rhs) noexcept :
61  _cur(a_rhs._cur)
62  {}
63 
64  constexpr iterator_base(iterator_base&& a_rhs) noexcept :
65  _cur(std::move(a_rhs._cur))
66  {
67  a_rhs._cur = nullptr;
68  }
69 
70  ~iterator_base() = default;
71 
72  constexpr iterator_base& operator=(const iterator_base& a_rhs) noexcept
73  {
74  if (this != std::addressof(a_rhs)) {
75  _cur = a_rhs._cur;
76  }
77  return *this;
78  }
79 
80  constexpr iterator_base& operator=(iterator_base&& a_rhs) noexcept
81  {
82  if (this != std::addressof(a_rhs)) {
83  _cur = a_rhs._cur;
84  a_rhs._cur = nullptr;
85  }
86  return *this;
87  }
88 
89  [[nodiscard]] constexpr reference operator*() const noexcept { return *_cur; }
90  [[nodiscard]] constexpr pointer operator->() const noexcept { return _cur; }
91 
92  [[nodiscard]] constexpr friend bool operator==(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return a_lhs._cur == a_rhs._cur; }
93  [[nodiscard]] constexpr friend bool operator!=(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return !(a_lhs == a_rhs); }
94 
95  // prefix
96  constexpr iterator_base& operator++() noexcept
97  {
98  assert(_cur != nullptr);
99  _cur = _cur->next;
100  return *this;
101  }
102 
103  // postfix
104  [[nodiscard]] constexpr iterator_base operator++(int) noexcept
105  {
106  iterator_base tmp{ *this };
107  ++(*this);
108  return tmp;
109  }
110 
111  inline friend void swap(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept
112  {
113  std::swap(a_lhs._cur, a_rhs._cur);
114  }
115 
116  private:
117  pointer _cur;
118  };
119 
122 
124 
131 
133  const BSExtraData* GetByType(ExtraDataType a_type) const;
134 
135  template <class T>
136  inline T* GetByType()
137  {
138  return static_cast<T*>(GetByType(T::EXTRADATATYPE));
139  }
140 
141  template <class T>
142  inline const T* GetByType() const
143  {
144  return static_cast<const T*>(GetByType(T::EXTRADATATYPE));
145  }
146 
147  bool HasType(ExtraDataType a_type) const;
148 
149  template <class T>
150  inline bool HasType() const
151  {
152  return HasType(T::EXTRADATATYPE);
153  }
154 
155  bool Remove(ExtraDataType a_type, BSExtraData* a_toRemove);
156 
157  template <class T>
158  inline bool Remove(T* a_toRemove)
159  {
160  return Remove(T::EXTRADATATYPE, a_toRemove);
161  }
162 
164 
167  std::int32_t GetCount() const;
168  const char* GetDisplayName(TESBoundObject* a_baseObject);
174  void SetExtraFlags(ExtraFlags::Flag a_flags, bool a_enable);
176  void SetOwner(TESForm* a_owner);
177 
178  private:
179  BSExtraData* GetByTypeImpl(ExtraDataType a_type) const;
180  void MarkType(std::uint32_t a_type, bool a_cleared);
181  void MarkType(ExtraDataType a_type, bool a_cleared);
182 
183  // members
184  BaseExtraList _extraData; // 00
185  mutable BSReadWriteLock _lock; // 18
186  };
187  static_assert(sizeof(ExtraDataList) == 0x20);
188 }
Definition: BGSEncounterZone.h:43
Definition: BGSKeyword.h:10
Definition: BSExtraData.h:9
Definition: BSAtomic.h:69
Definition: ExtraDataList.h:18
virtual ~BaseExtraList()
PresenceBitfield * presence
Definition: ExtraDataList.h:35
BSExtraData * data
Definition: ExtraDataList.h:34
Definition: ExtraDataList.h:44
constexpr reference operator*() const noexcept
Definition: ExtraDataList.h:89
value_type & reference
Definition: ExtraDataList.h:49
value_type * pointer
Definition: ExtraDataList.h:48
constexpr iterator_base & operator++() noexcept
Definition: ExtraDataList.h:96
std::ptrdiff_t difference_type
Definition: ExtraDataList.h:46
constexpr iterator_base & operator=(iterator_base &&a_rhs) noexcept
Definition: ExtraDataList.h:80
constexpr friend bool operator!=(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:93
constexpr iterator_base() noexcept
Definition: ExtraDataList.h:52
constexpr iterator_base(iterator_base &&a_rhs) noexcept
Definition: ExtraDataList.h:64
friend void swap(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:111
std::forward_iterator_tag iterator_category
Definition: ExtraDataList.h:50
constexpr iterator_base operator++(int) noexcept
Definition: ExtraDataList.h:104
constexpr friend bool operator==(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:92
T value_type
Definition: ExtraDataList.h:47
constexpr iterator_base & operator=(const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:72
constexpr iterator_base(const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:60
constexpr pointer operator->() const noexcept
Definition: ExtraDataList.h:90
constexpr iterator_base(pointer a_node) noexcept
Definition: ExtraDataList.h:56
Definition: ExtraDataList.h:40
const_iterator cbegin() const
const_iterator end() const
const T * GetByType() const
Definition: ExtraDataList.h:142
const BSExtraData * GetByType(ExtraDataType a_type) const
bool HasType() const
Definition: ExtraDataList.h:150
iterator begin()
BSExtraData * GetByType(ExtraDataType a_type)
ObjectRefHandle GetAshPileRef()
ExtraTextDisplayData * GetExtraTextDisplayData()
void SetOwner(TESForm *a_owner)
BSExtraData * Add(BSExtraData *a_toAdd)
BGSEncounterZone * GetEncounterZone()
const_iterator cend() const
bool RemoveByType(ExtraDataType a_type)
TESObjectREFR * GetLinkedRef(BGSKeyword *a_keyword)
const_iterator begin() const
SOUL_LEVEL GetSoulLevel() const
bool HasType(ExtraDataType a_type) const
const char * GetDisplayName(TESBoundObject *a_baseObject)
bool Remove(T *a_toRemove)
Definition: ExtraDataList.h:158
TESForm * GetOwner()
bool Remove(ExtraDataType a_type, BSExtraData *a_toRemove)
std::int32_t GetCount() const
T * GetByType()
Definition: ExtraDataList.h:136
void SetInventoryChanges(InventoryChanges *a_changes)
void SetExtraFlags(ExtraFlags::Flag a_flags, bool a_enable)
Flag
Definition: ExtraFlags.h:15
Definition: ExtraTextDisplayData.h:14
Definition: InventoryChanges.h:13
Definition: TESBoundObject.h:24
Definition: TESForm.h:34
Definition: TESObjectREFR.h:103
Definition: AbsorbEffect.h:6
SOUL_LEVEL
Definition: SoulLevels.h:6
void swap(BSTTuple< T1, T2 > &a_lhs, BSTTuple< T1, T2 > &a_rhs) noexcept(noexcept(a_lhs.swap(a_rhs))) requires(std
Definition: BSTTuple.h:212
ExtraDataType
Definition: ExtraDataTypes.h:173
Definition: ExtraDataList.h:21
bool HasType(std::uint32_t a_type) const
void MarkType(std::uint32_t a_type, bool a_cleared)
std::uint8_t bits[0x18]
Definition: ExtraDataList.h:27