diff --git a/include/ehs/db/DbTable.h b/include/ehs/db/DbTable.h index 4c92fce..11e76ab 100644 --- a/include/ehs/db/DbTable.h +++ b/include/ehs/db/DbTable.h @@ -46,6 +46,10 @@ namespace ehs DbObject *CreateObject(); + DbObject *GetObject(UInt_64 variableHashId, const Str_8 &value) const; + + DbObject *GetObject(const Str_8 &variable, const Str_8 &value) const; + DbObject *GetObject(UInt_64 id) const; private: diff --git a/src/db/DbTable.cpp b/src/db/DbTable.cpp index 0db8f80..caf4ed6 100644 --- a/src/db/DbTable.cpp +++ b/src/db/DbTable.cpp @@ -119,6 +119,27 @@ namespace ehs return obj; } + DbObject* DbTable::GetObject(UInt_64 variableHashId, const Str_8& value) const + { + for (UInt_64 i = 0; i < objects.Size(); ++i) + { + objects[i].Load(); + + const DbVar * const var = objects[i].GetVariable(variableHashId); + if (var->GetValueStr() == value) + return &objects[i]; + + objects[i].Free(); + } + + return nullptr; + } + + DbObject* DbTable::GetObject(const Str_8& variable, const Str_8& value) const + { + return GetObject(variable.Hash_64(), value); + } + DbObject* DbTable::GetObject(const UInt_64 id) const { for (UInt_64 i = 0; i < objects.Size(); ++i)