|
Blender V4.3
|
#include <AS_asset_library.hh>
Inherited by blender::asset_system::AllAssetLibrary, blender::asset_system::OnDiskAssetLibrary, and blender::asset_system::RuntimeAssetLibrary.
Static Public Member Functions | |
| static void | foreach_loaded (FunctionRef< void(AssetLibrary &)> fn, bool include_all_library) |
Static Public Attributes | |
| static bool | save_catalogs_when_file_is_saved = true |
Protected Member Functions | |
| virtual void | refresh_catalogs () |
Protected Attributes | |
| std::unique_ptr< AssetCatalogService > | catalog_service_ |
| std::mutex | catalog_service_mutex_ |
| std::optional< eAssetImportMethod > | import_method_ |
| bool | may_override_import_method_ = false |
| bool | use_relative_path_ = true |
| bCallbackFuncStore | on_save_callback_store_ {} |
Friends | |
| class | AssetLibraryService |
| class | AssetRepresentation |
AssetLibrary provides access to an asset library's data.
The asset library contains catalogs and storage for asset representations. It could be extended to also include asset indexes and more.
Definition at line 40 of file AS_asset_library.hh.
| blender::asset_system::AssetLibrary::AssetLibrary | ( | eAssetLibraryType | library_type, |
| StringRef | name = "", | ||
| StringRef | root_path = "" ) |
| name | The name this asset library will be displayed in the UI as. Will also be used as a weak way to identify an asset library (e.g. by AssetWeakReference). Make sure this is set for any custom (not builtin) asset library. That is, ASSET_LIBRARY_CUSTOM ones. |
| root_path | If this is an asset library on disk, the top-level directory path. |
Definition at line 165 of file asset_library.cc.
|
virtual |
Definition at line 173 of file asset_library.cc.
References bCallbackFuncStore::func, on_blend_save_handler_unregister(), and on_save_callback_store_.
| std::weak_ptr< AssetRepresentation > blender::asset_system::AssetLibrary::add_external_asset | ( | StringRef | relative_asset_path, |
| StringRef | name, | ||
| int | id_type, | ||
| std::unique_ptr< AssetMetaData > | metadata ) |
Create a representation of an asset to be considered part of this library. Once the representation is not needed anymore, it must be freed using remove_asset(), or there will be leaking that's only cleared when the library storage is destructed (typically on exit or loading a different file).
| relative_asset_path | The path of the asset relative to the asset library root. With this the asset must be uniquely identifiable within the asset library. |
Definition at line 202 of file asset_library.cc.
Referenced by blender::asset_system::tests::AssetRepresentationTest::add_dummy_asset(), and filelist_readjob_list_lib_add_datablock().
| std::weak_ptr< AssetRepresentation > blender::asset_system::AssetLibrary::add_local_id_asset | ( | StringRef | relative_asset_path, |
| ID & | id ) |
See AssetLibrary::add_external_asset().
Definition at line 212 of file asset_library.cc.
Referenced by filelist_readjob_main_assets_add_items().
| AssetCatalogService & blender::asset_system::AssetLibrary::catalog_service | ( | ) | const |
Definition at line 195 of file asset_library.cc.
References catalog_service_.
Referenced by blender::ed::sculpt_paint::asset_library_ensure_catalog(), blender::ed::sculpt_paint::asset_library_ensure_catalogs_in_path(), blender::ed::asset_browser::AssetCatalogTreeView::AssetCatalogTreeView(), blender::ed::sculpt_paint::brush_asset_edit_metadata_exec(), blender::ed::sculpt_paint::brush_asset_edit_metadata_invoke(), blender::ed::sculpt_paint::brush_asset_save_as_exec(), blender::ed::sculpt_paint::brush_asset_save_as_invoke(), blender::ed::asset::build_filtered_all_catalog_tree(), blender::ed::asset::build_filtered_catalog_tree(), blender::ed::asset::catalog_add(), blender::ed::asset::shelf::catalog_filter_from_shelf_settings(), blender::ed::asset::catalog_move(), blender::ed::asset::catalog_remove(), blender::ed::asset::catalog_rename(), blender::ed::asset::catalogs_read_only(), blender::ed::asset::catalogs_save_from_main_path(), compare_asset_catalog(), blender::ed::asset_browser::file_ensure_updated_catalog_filter_data(), blender::ed::asset::get_catalog_service(), blender::ed::asset_browser::AssetCatalogDropTarget::get_drag_catalog(), blender::asset_system::AssetLibraryService::has_any_unsaved_catalogs(), load_catalogs(), on_blend_save_post(), blender::asset_system::AllAssetLibrary::rebuild_catalogs_from_nested(), refresh_catalog_simplename(), blender::asset_system::OnDiskAssetLibrary::refresh_catalogs(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and blender::ed::sculpt_paint::visit_library_catalogs_catalog_for_search().
|
static |
Execute fn for every asset library that is loaded. The asset library is passed to the fn call.
| skip_all_library | When true, the fn will also be executed for the "All" asset library. This is just a combination of the other ones, so usually iterating over it is redundant. |
Definition at line 180 of file asset_library.cc.
References blender::asset_system::AssetLibraryService::foreach_loaded_asset_library(), and blender::asset_system::AssetLibraryService::get().
Referenced by filelist_readjob_all_asset_library(), and blender::asset_system::AllAssetLibrary::rebuild_catalogs_from_nested().
| eAssetLibraryType blender::asset_system::AssetLibrary::library_type | ( | ) | const |
Definition at line 310 of file asset_library.cc.
| void blender::asset_system::AssetLibrary::load_catalogs | ( | ) |
Definition at line 187 of file asset_library.cc.
References catalog_service(), catalog_service_, catalog_service_mutex_, blender::asset_system::AssetCatalogService::load_from_disk(), lock, and root_path().
| StringRefNull blender::asset_system::AssetLibrary::name | ( | ) | const |
Definition at line 315 of file asset_library.cc.
Referenced by compare_asset_catalog().
| void blender::asset_system::AssetLibrary::on_blend_save_handler_register | ( | ) |
Definition at line 261 of file asset_library.cc.
References bCallbackFuncStore::alloc, bCallbackFuncStore::arg, BKE_callback_add(), BKE_CB_EVT_SAVE_POST, bCallbackFuncStore::func, and on_save_callback_store_.
Referenced by blender::asset_system::OnDiskAssetLibrary::OnDiskAssetLibrary(), and blender::asset_system::RuntimeAssetLibrary::RuntimeAssetLibrary().
| void blender::asset_system::AssetLibrary::on_blend_save_handler_unregister | ( | ) |
Definition at line 272 of file asset_library.cc.
References bCallbackFuncStore::arg, BKE_callback_remove(), BKE_CB_EVT_SAVE_POST, bCallbackFuncStore::func, and on_save_callback_store_.
Referenced by ~AssetLibrary().
| void blender::asset_system::AssetLibrary::on_blend_save_post | ( | Main * | bmain, |
| PointerRNA ** | pointers, | ||
| int | num_pointers ) |
Definition at line 279 of file asset_library.cc.
References catalog_service(), Main::filepath, save_catalogs_when_file_is_saved, and blender::asset_system::AssetCatalogService::write_to_disk().
| void blender::asset_system::AssetLibrary::refresh_catalog_simplename | ( | AssetMetaData * | asset_data | ) |
Update catalog_simple_name by looking up the asset's catalog by its ID.
No-op if the catalog cannot be found. This could be the kind of "the catalog definition file is corrupt/lost" scenario that the simple name is meant to help recover from.
Definition at line 295 of file asset_library.cc.
References BLI_uuid_is_nil(), AssetMetaData::catalog_id, catalog_service(), AssetMetaData::catalog_simple_name, blender::asset_system::AssetCatalogService::find_catalog(), blender::asset_system::AssetCatalog::simple_name, and STRNCPY.
|
protectedvirtual |
Load catalogs that have changed on disk.
Reimplemented in blender::asset_system::AllAssetLibrary, and blender::asset_system::OnDiskAssetLibrary.
Definition at line 200 of file asset_library.cc.
| void blender::asset_system::AssetLibrary::remap_ids_and_remove_invalid | ( | const blender::bke::id::IDRemapper & | mappings | ) |
Remap ID pointers for local ID assets, see #BKE_lib_remap.hh. When an ID pointer would be mapped to null (typically when an ID gets removed), the asset is removed, because we don't support such empty/null assets.
Definition at line 227 of file asset_library.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::bke::id::IDRemapper::apply(), BLI_assert, ID_REMAP_APPLY_DEFAULT, ID_REMAP_RESULT_SOURCE_UNASSIGNED, blender::asset_system::AssetRepresentation::is_local_id(), and remove_asset().
Referenced by AS_asset_library_remap_ids().
| bool blender::asset_system::AssetLibrary::remove_asset | ( | AssetRepresentation & | asset | ) |
Remove an asset from the library that was added using add_external_asset() or add_local_id_asset(). Can usually be expected to be constant time complexity (worst case may differ).
Definition at line 219 of file asset_library.cc.
Referenced by filelist_intern_entry_free(), and remap_ids_and_remove_invalid().
| std::string blender::asset_system::AssetLibrary::resolve_asset_weak_reference_to_full_path | ( | const AssetWeakReference & | asset_reference | ) |
Definition at line 288 of file asset_library.cc.
References blender::asset_system::AssetLibraryService::get(), and blender::asset_system::AssetLibraryService::resolve_asset_weak_reference_to_full_path().
Referenced by blender::ed::asset::find_asset_from_weak_ref().
| StringRefNull blender::asset_system::AssetLibrary::root_path | ( | ) | const |
Definition at line 320 of file asset_library.cc.
Referenced by filelist_readjob_all_asset_library(), blender::asset_system::AssetRepresentation::full_path(), blender::ed::sculpt_paint::library_to_library_ref(), load_catalogs(), and blender::asset_system::tests::TEST_F().
|
friend |
Definition at line 100 of file AS_asset_library.hh.
|
friend |
Definition at line 101 of file AS_asset_library.hh.
|
protected |
Definition at line 83 of file AS_asset_library.hh.
Referenced by catalog_service(), and load_catalogs().
|
protected |
Definition at line 84 of file AS_asset_library.hh.
Referenced by load_catalogs().
|
protected |
|
protected |
Assets owned by this library may be imported with a different method than set in import_method_ above, it's just a default.
Definition at line 89 of file AS_asset_library.hh.
Referenced by blender::asset_system::AssetLibraryService::get_asset_library(), and blender::asset_system::AssetRepresentation::may_override_import_method().
|
protected |
Definition at line 93 of file AS_asset_library.hh.
Referenced by on_blend_save_handler_register(), on_blend_save_handler_unregister(), and ~AssetLibrary().
|
static |
Definition at line 98 of file AS_asset_library.hh.
Referenced by blender::ed::asset::catalogs_get_save_catalogs_when_file_is_saved(), blender::ed::asset::catalogs_set_save_catalogs_when_file_is_saved(), and on_blend_save_post().
|
protected |
Definition at line 91 of file AS_asset_library.hh.
Referenced by blender::asset_system::AssetLibraryService::get_asset_library(), and blender::asset_system::AssetRepresentation::get_use_relative_path().