EHS/include/ehs/db/DbTable.h

59 lines
1.0 KiB
C
Raw Normal View History

2024-04-08 03:10:24 -07:00
#pragma once
#include "ehs/Version.h"
#include "ehs/Array.h"
#include "DbVarTmpl.h"
#include "DbObject.h"
#include "ehs/Serializer.h"
2024-04-08 03:10:24 -07:00
namespace ehs
{
class DbTable
{
private:
friend class Database;
friend class DbVar;
2024-04-08 03:10:24 -07:00
UInt_64 hashId;
Str_8 id;
Array<DbVarTmpl> varTmpls;
Array<DbObject> objects;
public:
DbTable();
DbTable(Str_8 id);
DbTable(DbTable&& table) noexcept;
DbTable(const DbTable& table);
DbTable& operator=(DbTable&& table) noexcept;
DbTable& operator=(const DbTable& table);
2024-04-08 03:10:24 -07:00
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
2024-04-08 03:10:24 -07:00
Str_8 GetId() const;
bool HasVariable(UInt_64 hashId) const;
bool HasVariable(const Str_8& id) const;
bool CreateVariable(Str_8 id, DbType type, const Byte* defaultValue);
2024-04-08 03:10:24 -07:00
bool CreateVariable(Str_8 id, DbType type, UInt_64 size, const Byte* defaultValue);
DbObject *CreateObject();
private:
DbVarTmpl* GetVariableTemplate(UInt_64 hashId) const;
2024-04-08 03:10:24 -07:00
void Serialize(Serializer<UInt_64>& data) const;
2024-04-08 03:10:24 -07:00
void Deserialize(Serializer<UInt_64>& data);
2024-04-08 03:10:24 -07:00
};
}