Refactor MxPtrList to use p_ownership (#344)

* Refactor MxPtrList to use p_ownership

* Remove class names
This commit is contained in:
Christian Semmler
2023-12-20 20:09:05 -05:00
committed by GitHub
parent db60467ba3
commit afadca953b
24 changed files with 148 additions and 217 deletions

View File

@@ -10,12 +10,6 @@ class MxList;
template <class T>
class MxListCursor;
template <class T>
class MxPtrList : public MxList<T*> {
public:
MxPtrList(void (*p_destroy)(T*) = Destroy) { m_customDestructor = p_destroy; }
};
template <class T>
class MxListEntry {
public:
@@ -62,9 +56,9 @@ public:
void Append(T p_obj) { InsertEntry(p_obj, this->m_last, NULL); };
void DeleteAll(MxBool p_destroy = TRUE);
MxU32 GetCount() { return this->m_count; }
void SetDestroy(void (*p_customDestructor)(T)) { this->m_customDestructor = p_customDestructor; }
friend class MxListCursor<T>;
using MxCollection<T>::SetDestroy;
protected:
MxListEntry<T>* m_first; // 0x10
@@ -74,6 +68,16 @@ protected:
MxListEntry<T>* InsertEntry(T, MxListEntry<T>*, MxListEntry<T>*);
};
template <class T>
class MxPtrList : public MxList<T*> {
public:
MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); }
static void Destroy(T* p_obj) { delete p_obj; };
void SetOwnership(MxBool p_ownership) { SetDestroy(p_ownership ? Destroy : MxCollection<T*>::Destroy); }
};
template <class T>
class MxListCursor : public MxCore {
public: