Blender V5.3
BLI_memory_cache_file_load.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_memory_cache.hh"
12#include "BLI_string_ref.hh"
13
14namespace blender::memory_cache {
15
21template<typename T>
22std::shared_ptr<const T> get_loaded(const GenericKey &loader_key,
23 Span<StringRefNull> file_paths,
24 FunctionRef<std::unique_ptr<T>()> load_fn);
25
26std::shared_ptr<CachedValue> get_loaded_base(const GenericKey &loader_key,
27 Span<StringRefNull> file_paths,
28 FunctionRef<std::unique_ptr<CachedValue>()> load_fn);
29
30template<typename T>
31inline std::shared_ptr<const T> get_loaded(const GenericKey &loader_key,
32 Span<StringRefNull> file_paths,
33 FunctionRef<std::unique_ptr<T>()> load_fn)
34{
35 return std::dynamic_pointer_cast<const T>(get_loaded_base(loader_key, file_paths, load_fn));
36}
37
38} // namespace blender::memory_cache
std::shared_ptr< CachedValue > get_loaded_base(const GenericKey &loader_key, Span< StringRefNull > file_paths, FunctionRef< std::unique_ptr< CachedValue >()> load_fn)
std::shared_ptr< const T > get_loaded(const GenericKey &loader_key, Span< StringRefNull > file_paths, FunctionRef< std::unique_ptr< T >()> load_fn)