Add missing proper findOrGenerateImpl() implementation to MultipleAccessStorage class

This commit is contained in:
Denis Glazachev 2020-08-28 16:05:08 +04:00
parent f91d57adac
commit 7ffb618f6e
2 changed files with 18 additions and 0 deletions

View File

@ -104,6 +104,23 @@ std::optional<UUID> MultipleAccessStorage::findImpl(EntityType type, const Strin
} }
std::optional<UUID> MultipleAccessStorage::findOrGenerateImpl(EntityType type, const String & name) const
{
auto storages = getStoragesInternal();
for (const auto & storage : *storages)
{
auto id = storage->findOrGenerate(type, name);
if (id)
{
std::lock_guard lock{mutex};
ids_cache.set(*id, storage);
return id;
}
}
return {};
}
std::vector<UUID> MultipleAccessStorage::findAllImpl(EntityType type) const std::vector<UUID> MultipleAccessStorage::findAllImpl(EntityType type) const
{ {
std::vector<UUID> all_ids; std::vector<UUID> all_ids;

View File

@ -35,6 +35,7 @@ public:
protected: protected:
std::optional<UUID> findImpl(EntityType type, const String & name) const override; std::optional<UUID> findImpl(EntityType type, const String & name) const override;
std::optional<UUID> findOrGenerateImpl(EntityType type, const String & name) const override;
std::vector<UUID> findAllImpl(EntityType type) const override; std::vector<UUID> findAllImpl(EntityType type) const override;
bool existsImpl(const UUID & id) const override; bool existsImpl(const UUID & id) const override;
AccessEntityPtr readImpl(const UUID & id) const override; AccessEntityPtr readImpl(const UUID & id) const override;