CreatureLib/src/Battling/History/HistoryElements/HistoryElement.hpp

32 lines
875 B
C++

#ifndef CREATURELIB_HISTORYELEMENT_HPP
#define CREATURELIB_HISTORYELEMENT_HPP
#include "../HistoryElementKind.hpp"
namespace CreatureLib::Battling {
class HistoryElement {
friend class HistoryHolder;
u8* _previousOffset = nullptr;
protected:
virtual void Clear() {
if (_previousOffset != nullptr) {
GetPrevious()->Clear();
}
}
public:
virtual HistoryElementKind GetKind() const noexcept = 0;
ArbUt::BorrowedPtr<const HistoryElement> GetPrevious() const noexcept {
return reinterpret_cast<HistoryElement*>((u8*)this - _previousOffset);
}
ArbUt::BorrowedPtr<HistoryElement> GetPrevious() noexcept {
return reinterpret_cast<HistoryElement*>((u8*)this - _previousOffset);
}
};
}
#endif // CREATURELIB_HISTORYELEMENT_HPP