CommonLibSSE (Parapets fork)
Loading...
Searching...
No Matches
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"
7#include "RE/E/ExtraFlags.h"
8#include "RE/F/FormTypes.h"
10#include "RE/S/SoulLevels.h"
11
12namespace 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#if !defined(SKYRIMVR) && !defined(SKYRIMSE_PRE_1_6_629)
32 virtual ~BaseExtraList(); // 00
33#endif
34
35 // members
36 BSExtraData* data = nullptr; // 08
37 PresenceBitfield* presence = nullptr; // 10
38 };
39#if !defined(SKYRIMVR) && !defined(SKYRIMSE_PRE_1_6_629)
40 static_assert(sizeof(BaseExtraList) == 0x18);
41#else
42 static_assert(sizeof(BaseExtraList) == 0x10);
43#endif
44
46 {
47 public:
48 template <class T>
50 {
51 public:
52 using difference_type = std::ptrdiff_t;
53 using value_type = T;
56 using iterator_category = std::forward_iterator_tag;
57
58 constexpr iterator_base() noexcept :
59 _cur(nullptr)
60 {}
61
62 constexpr iterator_base(pointer a_node) noexcept :
63 _cur(a_node)
64 {}
65
66 constexpr iterator_base(const iterator_base& a_rhs) noexcept :
67 _cur(a_rhs._cur)
68 {}
69
70 constexpr iterator_base(iterator_base&& a_rhs) noexcept :
71 _cur(std::move(a_rhs._cur))
72 {
73 a_rhs._cur = nullptr;
74 }
75
76 ~iterator_base() = default;
77
78 constexpr iterator_base& operator=(const iterator_base& a_rhs) noexcept
79 {
80 if (this != std::addressof(a_rhs)) {
81 _cur = a_rhs._cur;
82 }
83 return *this;
84 }
85
86 constexpr iterator_base& operator=(iterator_base&& a_rhs) noexcept
87 {
88 if (this != std::addressof(a_rhs)) {
89 _cur = a_rhs._cur;
90 a_rhs._cur = nullptr;
91 }
92 return *this;
93 }
94
95 [[nodiscard]] constexpr reference operator*() const noexcept { return *_cur; }
96 [[nodiscard]] constexpr pointer operator->() const noexcept { return _cur; }
97
98 [[nodiscard]] constexpr friend bool operator==(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return a_lhs._cur == a_rhs._cur; }
99 [[nodiscard]] constexpr friend bool operator!=(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return !(a_lhs == a_rhs); }
100
101 // prefix
102 constexpr iterator_base& operator++() noexcept
103 {
104 assert(_cur != nullptr);
105 _cur = _cur->next;
106 return *this;
107 }
108
109 // postfix
110 [[nodiscard]] constexpr iterator_base operator++(int) noexcept
111 {
112 iterator_base tmp{ *this };
113 ++(*this);
114 return tmp;
115 }
116
117 inline friend void swap(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept
118 {
119 std::swap(a_lhs._cur, a_rhs._cur);
120 }
121
122 private:
123 pointer _cur;
124 };
125
128
130
137
139 const BSExtraData* GetByType(ExtraDataType a_type) const;
140
141 template <class T>
142 inline T* GetByType()
143 {
144 return static_cast<T*>(GetByType(T::EXTRADATATYPE));
145 }
146
147 template <class T>
148 inline const T* GetByType() const
149 {
150 return static_cast<const T*>(GetByType(T::EXTRADATATYPE));
151 }
152
153 bool HasType(ExtraDataType a_type) const;
154
155 template <class T>
156 inline bool HasType() const
157 {
158 return HasType(T::EXTRADATATYPE);
159 }
160
161 bool Remove(ExtraDataType a_type, BSExtraData* a_toRemove);
162
163 template <class T>
164 inline bool Remove(T* a_toRemove)
165 {
166 return Remove(T::EXTRADATATYPE, a_toRemove);
167 }
168
170
173 std::int32_t GetCount() const;
174 const char* GetDisplayName(TESBoundObject* a_baseObject);
180 void SetCount(std::uint16_t a_count);
181 void SetExtraFlags(ExtraFlags::Flag a_flags, bool a_enable);
183 void SetOwner(TESForm* a_owner);
184
185 private:
186 BSExtraData* GetByTypeImpl(ExtraDataType a_type) const;
187 void MarkType(std::uint32_t a_type, bool a_cleared);
188 void MarkType(ExtraDataType a_type, bool a_cleared);
189
190 // members
191 BaseExtraList _extraData; // 00
192 mutable BSReadWriteLock _lock; // 18
193 };
194#if !defined(SKYRIMVR) && !defined(SKYRIMSE_PRE_1_6_629)
195 static_assert(sizeof(ExtraDataList) == 0x20);
196#else
197 static_assert(sizeof(ExtraDataList) == 0x18);
198#endif
199}
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:37
BSExtraData * data
Definition: ExtraDataList.h:36
Definition: ExtraDataList.h:50
constexpr reference operator*() const noexcept
Definition: ExtraDataList.h:95
value_type & reference
Definition: ExtraDataList.h:55
constexpr iterator_base & operator++() noexcept
Definition: ExtraDataList.h:102
constexpr iterator_base & operator=(iterator_base &&a_rhs) noexcept
Definition: ExtraDataList.h:86
constexpr iterator_base & operator=(const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:78
value_type * pointer
Definition: ExtraDataList.h:54
std::ptrdiff_t difference_type
Definition: ExtraDataList.h:52
constexpr friend bool operator!=(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:99
constexpr iterator_base() noexcept
Definition: ExtraDataList.h:58
constexpr iterator_base(iterator_base &&a_rhs) noexcept
Definition: ExtraDataList.h:70
friend void swap(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:117
std::forward_iterator_tag iterator_category
Definition: ExtraDataList.h:56
constexpr iterator_base operator++(int) noexcept
Definition: ExtraDataList.h:110
constexpr friend bool operator==(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:98
T value_type
Definition: ExtraDataList.h:53
constexpr iterator_base(const iterator_base &a_rhs) noexcept
Definition: ExtraDataList.h:66
constexpr pointer operator->() const noexcept
Definition: ExtraDataList.h:96
constexpr iterator_base(pointer a_node) noexcept
Definition: ExtraDataList.h:62
Definition: ExtraDataList.h:46
const_iterator cbegin() const
BSExtraData * Add(BSExtraData *a_toAdd)
const_iterator end() const
TESForm * GetOwner()
bool HasType() const
Definition: ExtraDataList.h:156
BSExtraData * GetByType(ExtraDataType a_type)
iterator begin()
ObjectRefHandle GetAshPileRef()
void SetOwner(TESForm *a_owner)
const_iterator cend() const
TESObjectREFR * GetLinkedRef(BGSKeyword *a_keyword)
bool RemoveByType(ExtraDataType a_type)
const T * GetByType() const
Definition: ExtraDataList.h:148
const_iterator begin() const
SOUL_LEVEL GetSoulLevel() const
bool HasType(ExtraDataType a_type) const
T * GetByType()
Definition: ExtraDataList.h:142
bool Remove(T *a_toRemove)
Definition: ExtraDataList.h:164
void SetCount(std::uint16_t a_count)
const BSExtraData * GetByType(ExtraDataType a_type) const
const char * GetDisplayName(TESBoundObject *a_baseObject)
ExtraTextDisplayData * GetExtraTextDisplayData()
bool Remove(ExtraDataType a_type, BSExtraData *a_toRemove)
std::int32_t GetCount() const
BGSEncounterZone * GetEncounterZone()
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:105
Definition: AbsorbEffect.h:6
SOUL_LEVEL
Definition: SoulLevels.h:6
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