Blender V4.3
asset_library_service.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include <optional>
12#include <utility>
13
14#include "AS_asset_library.hh"
15
16#include "BLI_function_ref.hh"
17#include "BLI_map.hh"
18
19#include <memory>
20
23
24namespace blender::asset_system {
25
26class AllAssetLibrary;
27class OnDiskAssetLibrary;
28class RuntimeAssetLibrary;
29
44 static std::unique_ptr<AssetLibraryService> instance_;
45
51 using OnDiskLibraryIdentifier = std::pair<eAssetLibraryType, std::string>;
59 std::unique_ptr<RuntimeAssetLibrary> current_file_library_;
61 std::unique_ptr<AllAssetLibrary> all_library_;
62
64 bCallbackFuncStore on_load_callback_store_;
65 static bool atexit_handler_registered_;
66
67 public:
70
72 static AssetLibraryService *get();
73
75 static void destroy();
76
77 static std::string root_path_from_library_ref(const AssetLibraryReference &library_reference);
79 const AssetLibraryReference &library_reference);
81 const AssetWeakReference &asset_reference);
82
84 const AssetLibraryReference &library_reference);
85
102
114 const AssetWeakReference &asset_reference);
118 const AssetWeakReference &asset_reference);
126 std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference);
145 std::optional<ExplodedPath> resolve_asset_weak_reference_to_exploded_path(
146 const AssetWeakReference &asset_reference);
147
149 bool has_any_unsaved_catalogs() const;
150
153 bool include_all_library) const;
154
155 protected:
157 static void allocate_service_instance();
158
160
167 StringRef name,
168 StringRefNull root_path);
174};
175
176} // namespace blender::asset_system
eAssetLibraryType
void foreach_loaded_asset_library(FunctionRef< void(AssetLibrary &)> fn, bool include_all_library) const
AssetLibrary * get_asset_library_on_disk_builtin(eAssetLibraryType type, StringRefNull root_path)
AssetLibrary * get_asset_library(const Main *bmain, const AssetLibraryReference &library_reference)
AssetLibrary * find_loaded_on_disk_asset_library_from_name(StringRef name) const
AssetLibrary * get_asset_library_on_disk(eAssetLibraryType library_type, StringRef name, StringRefNull root_path)
static bUserAssetLibrary * find_custom_asset_library_from_library_ref(const AssetLibraryReference &library_reference)
std::optional< ExplodedPath > resolve_asset_weak_reference_to_exploded_path(const AssetWeakReference &asset_reference)
std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference)
AssetLibrary * get_asset_library_on_disk_custom(StringRef name, StringRefNull root_path)
static std::string root_path_from_library_ref(const AssetLibraryReference &library_reference)
std::string normalize_asset_weak_reference_relative_asset_identifier(const AssetWeakReference &asset_reference)
static bUserAssetLibrary * find_custom_preferences_asset_library_from_asset_weak_ref(const AssetWeakReference &asset_reference)
std::string resolve_asset_weak_reference_to_library_path(const AssetWeakReference &asset_reference)
AssetLibrary * get_asset_library_all(const Main *bmain)
__int64 int64_t
Definition stdint.h:89