1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:27:34 +00:00

LibSQL: Remove Core::EventReceiver parent from SQL::Heap

This relationship was only used to provide a name and factory methods
for the heap.
This commit is contained in:
Timothy Flynn 2023-08-07 10:57:34 -04:00 committed by Tim Flynn
parent 2c17742811
commit 4a04438e43
7 changed files with 29 additions and 21 deletions

View file

@ -16,7 +16,7 @@
namespace SQL {
Database::Database(DeprecatedString name)
: m_heap(Heap::construct(move(name)))
: m_heap(Heap::create(move(name)).release_value_but_fixme_should_propagate_errors())
, m_serializer(m_heap)
{
}

View file

@ -14,9 +14,14 @@
namespace SQL {
Heap::Heap(DeprecatedString file_name)
ErrorOr<NonnullRefPtr<Heap>> Heap::create(DeprecatedString file_name)
{
return adopt_nonnull_ref_or_enomem(new (nothrow) Heap(move(file_name)));
}
Heap::Heap(DeprecatedString file_name)
: m_name(move(file_name))
{
set_name(move(file_name));
}
Heap::~Heap()

View file

@ -11,8 +11,8 @@
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/RefCounted.h>
#include <AK/Vector.h>
#include <LibCore/EventReceiver.h>
#include <LibCore/File.h>
namespace SQL {
@ -64,13 +64,14 @@ private:
* A Heap can be thought of the backing storage of a single database. It's
* assumed that a single SQL database is backed by a single Heap.
*/
class Heap : public Core::EventReceiver {
C_OBJECT(Heap);
class Heap : public RefCounted<Heap> {
public:
static constexpr u32 VERSION = 4;
virtual ~Heap() override;
static ErrorOr<NonnullRefPtr<Heap>> create(DeprecatedString);
virtual ~Heap();
DeprecatedString const& name() const { return m_name; }
ErrorOr<void> open();
ErrorOr<size_t> file_size_in_bytes() const;
@ -135,6 +136,8 @@ private:
ErrorOr<void> initialize_zero_block();
ErrorOr<void> update_zero_block();
DeprecatedString m_name;
OwnPtr<Core::InputBufferedFile> m_file;
Block::Index m_highest_block_written { 0 };
Block::Index m_next_block { 1 };