CommonLibSSE (powerof3)
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"
9#include "RE/F/FormTypes.h"
10#include "RE/M/MemoryManager.h"
11#include "RE/S/SoulLevels.h"
12
13namespace RE
14{
15 class InventoryChanges;
16 class TESBoundObject;
17
19 {
20 public:
22 {
23 public:
24 [[nodiscard]] bool HasType(std::uint32_t a_type) const;
25 void MarkType(std::uint32_t a_type, bool a_cleared);
26
27 // members
28 std::uint8_t bits[0x18]; // 00
29 };
30 static_assert(sizeof(PresenceBitfield) == 0x18);
31
32#ifndef SKYRIM_SUPPORT_AE
34#else
35 virtual ~BaseExtraList(); // 00
36#endif
37
38 // members
39 BSExtraData* data = nullptr; // 08
40 PresenceBitfield* presence = nullptr; // 10
41 };
42#ifndef SKYRIM_SUPPORT_AE
43 static_assert(sizeof(BaseExtraList) == 0x10);
44#else
45 static_assert(sizeof(BaseExtraList) == 0x18);
46#endif
47
49 {
50 public:
51 template <class T>
53 {
54 public:
55 using difference_type = std::ptrdiff_t;
56 using value_type = T;
59 using iterator_category = std::forward_iterator_tag;
60
61 constexpr iterator_base() noexcept :
62 _cur(nullptr)
63 {}
64
65 constexpr iterator_base(pointer a_node) noexcept :
66 _cur(a_node)
67 {}
68
69 constexpr iterator_base(const iterator_base& a_rhs) noexcept :
70 _cur(a_rhs._cur)
71 {}
72
73 constexpr iterator_base(iterator_base&& a_rhs) noexcept :
74 _cur(std::move(a_rhs._cur))
75 {
76 a_rhs._cur = nullptr;
77 }
78
79 ~iterator_base() = default;
80
81 constexpr iterator_base& operator=(const iterator_base& a_rhs) noexcept
82 {
83 if (this != std::addressof(a_rhs)) {
84 _cur = a_rhs._cur;
85 }
86 return *this;
87 }
88
89 constexpr iterator_base& operator=(iterator_base&& a_rhs) noexcept
90 {
91 if (this != std::addressof(a_rhs)) {
92 _cur = a_rhs._cur;
93 a_rhs._cur = nullptr;
94 }
95 return *this;
96 }
97
98 [[nodiscard]] constexpr reference operator*() const noexcept { return *_cur; }
99 [[nodiscard]] constexpr pointer operator->() const noexcept { return _cur; }
100
101 [[nodiscard]] constexpr friend bool operator==(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return a_lhs._cur == a_rhs._cur; }
102 [[nodiscard]] constexpr friend bool operator!=(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept { return !(a_lhs == a_rhs); }
103
104 // prefix
105 constexpr iterator_base& operator++() noexcept
106 {
107 assert(_cur != nullptr);
108 _cur = _cur->next;
109 return *this;
110 }
111
112 // postfix
113 [[nodiscard]] constexpr iterator_base operator++(int) noexcept
114 {
115 iterator_base tmp{ *this };
116 ++(*this);
117 return tmp;
118 }
119
120 inline friend void swap(const iterator_base& a_lhs, const iterator_base& a_rhs) noexcept
121 {
122 std::swap(a_lhs._cur, a_rhs._cur);
123 }
124
125 private:
126 pointer _cur;
127 };
128
131
133
140
142 const BSExtraData* GetByType(ExtraDataType a_type) const;
143
144 template <class T>
145 inline T* GetByType()
146 {
147 return static_cast<T*>(GetByType(T::EXTRADATATYPE));
148 }
149
150 template <class T>
151 inline const T* GetByType() const
152 {
153 return static_cast<const T*>(GetByType(T::EXTRADATATYPE));
154 }
155
156 bool HasType(ExtraDataType a_type) const;
157
158 template <class T>
159 inline bool HasType() const
160 {
161 return HasType(T::EXTRADATATYPE);
162 }
163
164 bool Remove(ExtraDataType a_type, BSExtraData* a_toRemove);
165
166 template <class T>
167 inline bool Remove(T* a_toRemove)
168 {
169 return Remove(T::EXTRADATATYPE, a_toRemove);
170 }
171
173
176 std::int32_t GetCount() const;
177 const char* GetDisplayName(TESBoundObject* a_baseObject);
185 void SetCount(std::uint16_t a_count);
187 void SetExtraFlags(ExtraFlags::Flag a_flags, bool a_enable);
191 void SetLinkedRef(TESObjectREFR* a_targetRef, BGSKeyword* a_keyword);
192 void SetOwner(TESForm* a_owner);
193
194 private:
195 BSExtraData* GetByTypeImpl(ExtraDataType a_type) const;
196 void MarkType(std::uint32_t a_type, bool a_cleared);
197 void MarkType(ExtraDataType a_type, bool a_cleared);
198
199 // members
200 BaseExtraList _extraData; // 00
201 mutable BSReadWriteLock _lock; // 18
202 };
203#ifndef SKYRIM_SUPPORT_AE
204 static_assert(sizeof(ExtraDataList) == 0x18);
205#else
206 static_assert(sizeof(ExtraDataList) == 0x20);
207#endif
208}
Definition BGSEncounterZone.h:43
Definition BGSKeyword.h:10
Definition BSExtraData.h:9
Definition BSAtomic.h:112
Definition ExtraDataList.h:19
PresenceBitfield * presence
Definition ExtraDataList.h:40
BSExtraData * data
Definition ExtraDataList.h:39
Definition ExtraDataList.h:53
constexpr reference operator*() const noexcept
Definition ExtraDataList.h:98
value_type & reference
Definition ExtraDataList.h:58
constexpr iterator_base & operator++() noexcept
Definition ExtraDataList.h:105
constexpr iterator_base & operator=(iterator_base &&a_rhs) noexcept
Definition ExtraDataList.h:89
constexpr iterator_base & operator=(const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:81
value_type * pointer
Definition ExtraDataList.h:57
std::ptrdiff_t difference_type
Definition ExtraDataList.h:55
constexpr friend bool operator!=(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:102
constexpr iterator_base() noexcept
Definition ExtraDataList.h:61
constexpr iterator_base(iterator_base &&a_rhs) noexcept
Definition ExtraDataList.h:73
friend void swap(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:120
std::forward_iterator_tag iterator_category
Definition ExtraDataList.h:59
constexpr iterator_base operator++(int) noexcept
Definition ExtraDataList.h:113
constexpr friend bool operator==(const iterator_base &a_lhs, const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:101
T value_type
Definition ExtraDataList.h:56
constexpr iterator_base(const iterator_base &a_rhs) noexcept
Definition ExtraDataList.h:69
constexpr pointer operator->() const noexcept
Definition ExtraDataList.h:99
constexpr iterator_base(pointer a_node) noexcept
Definition ExtraDataList.h:65
Definition ExtraDataList.h:49
void SetEncounterZone(BGSEncounterZone *a_zone)
const_iterator cbegin() const
BSExtraData * Add(BSExtraData *a_toAdd)
void SetHeadingTargetRefHandle(ObjectRefHandle &a_handle)
const_iterator end() const
TESForm * GetOwner()
bool HasType() const
Definition ExtraDataList.h:159
BSExtraData * GetByType(ExtraDataType a_type)
iterator begin()
ObjectRefHandle GetAshPileRef()
void SetOwner(TESForm *a_owner)
void SetLinkedRef(TESObjectREFR *a_targetRef, BGSKeyword *a_keyword)
const_iterator cend() const
TESObjectREFR * GetLinkedRef(BGSKeyword *a_keyword)
bool RemoveByType(ExtraDataType a_type)
bool HasQuestObjectAlias()
const T * GetByType() const
Definition ExtraDataList.h:151
const_iterator begin() const
void SetLevCreaModifier(LEV_CREA_MODIFIER a_modifier)
SOUL_LEVEL GetSoulLevel() const
bool HasType(ExtraDataType a_type) const
T * GetByType()
Definition ExtraDataList.h:145
ObjectRefHandle GetTeleportLinkedDoor()
bool Remove(T *a_toRemove)
Definition ExtraDataList.h:167
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:16
Definition ExtraTextDisplayData.h:14
Definition InventoryChanges.h:15
Definition TESBoundObject.h:24
Definition TESForm.h:36
Definition TESObjectREFR.h:114
Definition AbsorbEffect.h:6
SOUL_LEVEL
Definition SoulLevels.h:6
LEV_CREA_MODIFIER
Definition ExtraLevCreaModifier.h:9
ExtraDataType
Definition ExtraDataTypes.h:173
Definition ExtraDataList.h:22
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:28