2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-10 00:27:43 +00:00

CFlyingPirate: First draft almost done

This commit is contained in:
2020-03-13 04:11:17 -04:00
parent 11ea9d3aa6
commit 13d8c3fdd1
9 changed files with 1049 additions and 135 deletions

View File

@@ -77,13 +77,13 @@ public:
explicit operator bool() const { return HasReference(); }
bool HasReference() const { return x0_objRef != nullptr; }
virtual void Unlock();
void Unlock();
void Lock();
bool IsLocked() const { return x4_lockHeld; }
bool IsLoaded() const;
IObj* GetObj();
const IObj* GetObj() const { return const_cast<CToken*>(this)->GetObj(); }
virtual CToken& operator=(const CToken& other);
CToken& operator=(const CToken& other);
CToken& operator=(CToken&& other);
CToken() = default;
CToken(const CToken& other);
@@ -101,6 +101,7 @@ public:
return TObjOwnerDerivedFromIObj<T>::GetNewDerivedObject(std::move(obj));
}
TToken() = default;
virtual ~TToken() = default;
TToken(const CToken& other) : CToken(other) {}
TToken(CToken&& other) : CToken(std::move(other)) {}
TToken(std::unique_ptr<T>&& obj) : CToken(GetIObjObjectFor(std::move(obj))) {}
@@ -108,6 +109,8 @@ public:
*this = CToken(GetIObjObjectFor(std::move(obj)));
return this;
}
virtual void Unlock() { CToken::Unlock(); }
virtual void Lock() { CToken::Lock(); }
virtual T* GetObj() {
TObjOwnerDerivedFromIObj<T>* owner = static_cast<TObjOwnerDerivedFromIObj<T>*>(CToken::GetObj());
if (owner)
@@ -115,6 +118,10 @@ public:
return nullptr;
}
virtual const T* GetObj() const { return const_cast<TToken<T>*>(this)->GetObj(); }
virtual TToken& operator=(const CToken& other) {
CToken::operator=(other);
return *this;
}
T* operator->() { return GetObj(); }
const T* operator->() const { return GetObj(); }
T& operator*() { return *GetObj(); }
@@ -142,12 +149,12 @@ public:
}
TCachedToken& operator=(const TCachedToken& other) {
CToken::operator=(other);
TToken<T>::operator=(other);
m_obj = nullptr;
return *this;
}
TCachedToken& operator=(const CToken& other) {
CToken::operator=(other);
TToken<T>::operator=(other);
m_obj = nullptr;
return *this;
}