Blender V5.0
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
5#pragma once
6
7#include "BLI_memory_cache.hh"
8#include "BLI_string_ref.hh"
9
10namespace blender::memory_cache {
11
17template<typename T>
18std::shared_ptr<const T> get_loaded(const GenericKey &loader_key,
19 Span<StringRefNull> file_paths,
20 FunctionRef<std::unique_ptr<T>()> load_fn);
21
22std::shared_ptr<CachedValue> get_loaded_base(const GenericKey &loader_key,
23 Span<StringRefNull> file_paths,
24 FunctionRef<std::unique_ptr<CachedValue>()> load_fn);
25
26template<typename T>
27inline std::shared_ptr<const T> get_loaded(const GenericKey &loader_key,
28 Span<StringRefNull> file_paths,
29 FunctionRef<std::unique_ptr<T>()> load_fn)
30{
31 return std::dynamic_pointer_cast<const T>(get_loaded_base(loader_key, file_paths, load_fn));
32}
33
34} // 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)