2024-04-08 03:10:24 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ehs/Version.h"
|
|
|
|
#include "ehs/Array.h"
|
|
|
|
#include "DbVarTmpl.h"
|
|
|
|
#include "DbObject.h"
|
2024-04-09 01:44:15 -07:00
|
|
|
#include "ehs/Serializer.h"
|
2024-04-08 03:10:24 -07:00
|
|
|
|
|
|
|
namespace ehs
|
|
|
|
{
|
2024-04-23 22:29:49 -07:00
|
|
|
class Database;
|
|
|
|
|
2024-04-08 03:10:24 -07:00
|
|
|
class DbTable
|
|
|
|
{
|
|
|
|
private:
|
2024-04-09 01:44:15 -07:00
|
|
|
friend class Database;
|
|
|
|
friend class DbVar;
|
2024-04-23 22:29:49 -07:00
|
|
|
friend class DbObject;
|
2024-04-09 01:44:15 -07:00
|
|
|
|
2024-04-23 22:29:49 -07:00
|
|
|
Database *parent;
|
2024-04-08 03:10:24 -07:00
|
|
|
UInt_64 hashId;
|
|
|
|
Str_8 id;
|
|
|
|
Array<DbVarTmpl> varTmpls;
|
|
|
|
Array<DbObject> objects;
|
|
|
|
|
|
|
|
public:
|
|
|
|
DbTable();
|
|
|
|
|
2024-04-09 01:44:15 -07:00
|
|
|
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;
|
|
|
|
|
2024-04-09 01:44:15 -07:00
|
|
|
void SetId(Str_8 newId);
|
|
|
|
|
2024-04-08 03:10:24 -07:00
|
|
|
Str_8 GetId() const;
|
|
|
|
|
2024-04-09 01:44:15 -07:00
|
|
|
bool HasVariable(UInt_64 hashId) const;
|
|
|
|
|
|
|
|
bool HasVariable(const Str_8& id) const;
|
|
|
|
|
2024-04-10 18:26:20 -07:00
|
|
|
bool CreateVariable(DbVarTmpl var);
|
2024-04-09 02:31:10 -07:00
|
|
|
|
2024-04-09 01:44:15 -07:00
|
|
|
DbObject *CreateObject();
|
|
|
|
|
2024-04-10 22:28:45 -07:00
|
|
|
DbObject *GetObject(UInt_64 variableHashId, const Str_8 &value) const;
|
|
|
|
|
|
|
|
DbObject *GetObject(const Str_8 &variable, const Str_8 &value) const;
|
|
|
|
|
2024-04-09 02:31:10 -07:00
|
|
|
DbObject *GetObject(UInt_64 id) const;
|
|
|
|
|
2024-04-09 01:44:15 -07:00
|
|
|
private:
|
2024-04-09 02:31:10 -07:00
|
|
|
DbVarTmpl *GetVariableTemplate(UInt_64 hashId) const;
|
2024-04-08 03:10:24 -07:00
|
|
|
|
2024-04-23 22:29:49 -07:00
|
|
|
void Serialize(const Str_8 &dir, Serializer<UInt_64>& data) const;
|
2024-04-08 03:10:24 -07:00
|
|
|
|
2024-04-23 22:29:49 -07:00
|
|
|
void Deserialize(const Str_8 &dir, Serializer<UInt_64>& data);
|
2024-04-08 03:10:24 -07:00
|
|
|
};
|
|
|
|
}
|