Started work on database handling.

This commit is contained in:
2024-04-08 03:10:24 -07:00
parent 405acb026f
commit beba947c69
22 changed files with 918 additions and 44 deletions

98
src/db/DbObject.cpp Normal file
View File

@@ -0,0 +1,98 @@
#include "ehs/db/DbObject.h"
namespace ehs
{
DbObject::DbObject()
: id(0), loaded(false), parent(nullptr)
{
}
DbObject::DbObject(DbObject&& obj) noexcept
: id(obj.id), vars((Array<DbVar>&&)obj.vars), loaded(obj.loaded), parent(obj.parent)
{
obj.id = 0;
obj.loaded = false;
obj.parent = nullptr;
}
DbObject::DbObject(const DbObject& obj)
: id(obj.id), vars(obj.vars), loaded(obj.loaded), parent(obj.parent)
{
}
DbObject& DbObject::operator=(DbObject&& obj) noexcept
{
if (this == &obj)
return *this;
id = obj.id;
vars = (Array<DbVar>&&)obj.vars;
loaded = obj.loaded;
parent = obj.parent;
obj.id = 0;
obj.loaded = false;
obj.parent = nullptr;
return *this;
}
DbObject& DbObject::operator=(const DbObject& obj)
{
if (this == &obj)
return *this;
id = obj.id;
vars = obj.vars;
loaded = obj.loaded;
parent = obj.parent;
return *this;
}
UInt_64 DbObject::GetId()
{
return id;
}
bool DbObject::HasVariable(UInt_64 hashId)
{
for (UInt_64 i = 0; i < vars.Size(); ++i)
if (vars[i].GetHashId() == hashId)
return true;
return false;
}
DbVar* DbObject::GetVariable(UInt_64 hashId) const
{
for (UInt_64 i = 0; i < vars.Size(); ++i)
if (vars[i].GetHashId() == hashId)
return &vars[i];
return nullptr;
}
void DbObject::Save()
{
}
void DbObject::Load()
{
}
bool DbObject::IsLoaded() const
{
return loaded;
}
void DbObject::Free()
{
vars.Clear();
}
DbTable* DbObject::GetParent() const
{
return parent;
}
}