diff --git a/include/matador/object/object_cache.hpp b/include/matador/object/object_cache.hpp index 42acaf8..fe06880 100644 --- a/include/matador/object/object_cache.hpp +++ b/include/matador/object/object_cache.hpp @@ -25,10 +25,10 @@ struct cache_entry_base { [[nodiscard]] virtual bool is_dead() const noexcept = 0; }; -template +template struct cache_entry : cache_entry_base { - std::weak_ptr > proxy; - std::weak_ptr entity; + std::weak_ptr > proxy; + std::weak_ptr entity; [[nodiscard]] bool is_dead() const noexcept override { return proxy.expired() && entity.expired(); @@ -63,8 +63,8 @@ public: * Andernfalls wird ein neuer Proxy erzeugt, im Cache abgelegt und zurückgegeben. * Falls für (T, id) bereits eine Entity vorhanden ist, wird sie an den Proxy gebunden. * - * @tparam T Entity-Typ. - * @tparam ResolverPtr Zeiger-Typ auf einen Resolver, typischerweise + * @tparam Type Entity-Typ. + * @tparam ResolverPointerType Zeiger-Typ auf einen Resolver, typischerweise * @c std::shared_ptr> oder @c std::weak_ptr>. * @param id Identifier/Primärschlüssel der Entity. * @param resolver_ptr Resolver (shared/weak), der zur Lazy-Auflösung durch den Proxy genutzt wird. @@ -72,23 +72,23 @@ public: * * @note Diese Methode ist threadsafe. */ - template - std::shared_ptr> acquire_proxy(utils::identifier id, ResolverPtr &&resolver_ptr) { - const auto k = make_key(id); + template + std::shared_ptr> acquire_proxy(utils::identifier id, ResolverPointerType &&resolver_ptr) { + const auto k = make_key(id); std::unique_lock lock(mutex_); auto it = map_.find(k); if (it != map_.end()) { // found entry, return std::shared_ptr of proxy - auto *entry = entry_cast_(it->second.get()); + auto *entry = entry_cast_(it->second.get()); if (auto proxy_ptr = entry->proxy.lock()) { return proxy_ptr; } // if the proxy is dead, but the entity is alive, create a new proxy and attach entity - auto weak_resolver = to_weak(std::forward(resolver_ptr)); - auto proxy_ptr = std::make_shared>(weak_resolver, id); + auto weak_resolver = to_weak(std::forward(resolver_ptr)); + auto proxy_ptr = std::make_shared>(weak_resolver, id); if (auto obj = entry->entity.lock()) { proxy_ptr->attach(std::move(obj)); @@ -101,12 +101,12 @@ public: } // entry couldn't be found, create a new entry - auto entry_ptr = std::make_unique>(); + auto entry_ptr = std::make_unique>(); auto *entry = entry_ptr.get(); // create a weak resolver and shared proxy - auto weak_resolver = to_weak(std::forward(resolver_ptr)); - auto proxy_ptr = std::make_shared>(weak_resolver, id); + auto weak_resolver = to_weak(std::forward(resolver_ptr)); + auto proxy_ptr = std::make_shared>(weak_resolver, id); // lock entity and attach to proxy if (auto obj = entry->entity.lock()) { @@ -286,12 +286,10 @@ private: } template - using enable_if_resolver_shared_ptr_t = - std::enable_if_t, U>, int>; + using enable_if_resolver_shared_ptr_t = std::enable_if_t, U>, int>; template - using enable_if_resolver_weak_ptr_t = - std::enable_if_t, U>, int>; + using enable_if_resolver_weak_ptr_t = std::enable_if_t, U>, int>; // shared_ptr -> weak_ptr template = 0> @@ -306,8 +304,8 @@ private: } // (2) Opportunistischer Cleanup: entferne Entry, wenn beide weak_ptr abgelaufen sind. - template - bool prune_if_dead(It &it) { + template + bool prune_if_dead(IteratorType &it) { if (it == map_.end()) { return false; } @@ -319,9 +317,9 @@ private: return false; } - template + template void prune_if_dead_typed(typename std::unordered_map, key_hash>::iterator &it) { - (void)T{}; // T bleibt im Interface, damit bestehende Call-Sites unverändert bleiben können. + (void)Type{}; // T bleibt im Interface, damit bestehende Call-Sites unverändert bleiben können. prune_if_dead(it); }