Blender V5.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
8
9#pragma once
10
11#include <memory>
12#include <mutex>
13#include <optional>
14#include <utility>
15
16#include "AS_asset_library.hh"
17
18#include "BLI_function_ref.hh"
19#include "BLI_map.hh"
20
21#include "essentials_library.hh"
22
23namespace blender {
24
27
28namespace asset_system {
29
30class AllAssetLibrary;
34
49 static std::unique_ptr<AssetLibraryService> instance_;
50
56 using OnDiskLibraryIdentifier = std::pair<eAssetLibraryType, std::string>;
62 mutable std::recursive_mutex on_disk_libraries_mutex_;
63 using URLLibraryIdentifier = std::string;
66 mutable std::recursive_mutex remote_libraries_mutex_;
72 std::unique_ptr<RuntimeAssetLibrary> current_file_library_;
74 std::unique_ptr<AllAssetLibrary> all_library_;
75 std::unique_ptr<OnlineEssentialsLibrary> online_essentials_library_;
76
78 bCallbackFuncStore on_load_callback_store_;
79 static bool atexit_handler_registered_;
80
81 public:
84
86 static AssetLibraryService *get();
87
89 static void destroy();
90
91 static std::string root_path_from_library_ref(const AssetLibraryReference &library_reference);
93 const AssetLibraryReference &library_reference);
95 const AssetWeakReference &asset_reference);
107
108 AssetLibrary *get_asset_library(const Main *bmain,
109 const AssetLibraryReference &library_reference);
110
138
150 const AssetWeakReference &asset_reference);
156 const AssetWeakReference &asset_reference);
164 std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference);
188
193 std::optional<ExplodedPath> resolve_asset_weak_reference_to_exploded_path(
194 const AssetWeakReference &asset_reference);
195
197 bool has_any_unsaved_catalogs() const;
198
201 bool include_all_library) const;
202
203 protected:
205 static void allocate_service_instance();
206
208
210
221 StringRef name,
222 StringRefNull root_path,
223 bool load_catalogs = true,
224 bUserAssetLibrary *preferences_library = nullptr);
231};
232
233} // namespace asset_system
234
235} // namespace blender
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_on_disk_custom_preferences(bUserAssetLibrary *custom_library)
AssetLibrary * get_asset_library(const Main *bmain, const AssetLibraryReference &library_reference)
AssetLibrary * find_loaded_on_disk_asset_library_from_name(StringRef name) const
static bUserAssetLibrary * find_custom_asset_library_from_library_ref(const AssetLibraryReference &library_reference)
OnDiskAssetLibrary * lookup_on_disk_library(eAssetLibraryType type, StringRefNull root_path)
std::optional< ExplodedPath > resolve_asset_weak_reference_to_exploded_path(const AssetWeakReference &asset_reference)
static AssetLibrary * move_runtime_current_file_into_on_disk_library(const Main &bmain)
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_on_disk(eAssetLibraryType library_type, StringRef name, StringRefNull root_path, bool load_catalogs=true, bUserAssetLibrary *preferences_library=nullptr)
AssetLibrary * get_preferences_remote_asset_library(const bUserAssetLibrary &custom_library)
AssetLibrary * get_asset_library_all(const Main *bmain)
BMesh Iterators.
__int64 int64_t
Definition BKE_text.h:90