Template Struct Store

Inheritance Relationships

Base Type

Struct Documentation

template<typename AssetType, typename Key = std::filesystem::path, typename Allocator = std::allocator<std::pair<const Key, std::shared_ptr<AssetType>>>>
struct Store : public CE::Assets::Cache::Context

Caches constructed assets by key.

reserve() provides storage whose slots callers construct selectively with emplace(); the older allocate() interface returns unconstructed handles for manual construction. Publish complete assets under a unique lock; readers copy retained handles under a shared lock. Construction and final release happen outside the lock.

Public Types

using Handle = std::shared_ptr<AssetType>
using key_type = Key

Public Functions

Store() = default
inline virtual ~Store()
inline virtual Handle get_asset(const Key &key) const

Declaration: [[nodiscard]]

inline bool contains(const Key &key) const

Declaration: [[nodiscard]]

inline std::size_t size() const

Declaration: [[nodiscard]]

inline Stats diagnostics() const

Declaration: [[nodiscard]]

inline virtual void clear_assets() noexcept

Protected Functions

inline explicit Store(const Allocator &allocator)
inline Handle publish_asset(const Key &key, Handle asset)
template<typename Published>
inline Handle publish_asset(const Key &key, Handle asset, Published &&published)
inline Handle replace_asset(const Key &key, Handle asset)
template<typename Derived>
inline auto reserve(const std::size_t N)

Reserve raw slots for selective construction with emplace().

template<typename Derived>
inline std::vector<std::shared_ptr<Derived>> allocate(const std::size_t N)

Provide raw object handles for callers that construct slots manually.

Protected Attributes

mutable std::shared_mutex assets_mutex_
std::unordered_map<Key, Handle, std::hash<Key>, std::equal_to<Key>, Allocator> loaded_assets = {}
const CE::Diagnostics::DomainId domain_ = CE::Diagnostics::next_domain_id()
std::uint64_t publications_ = 0
std::uint64_t replacements_ = 0