|
Blender V5.3
|
#include <AS_asset_library.hh>
Inherited by blender::asset_system::AllAssetLibrary, blender::asset_system::OnDiskAssetLibrary, blender::asset_system::RemoteAssetLibrary, 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::shared_ptr< AssetCatalogService > | catalog_service_ |
| std::recursive_mutex | catalog_service_mutex_ |
| bool | may_override_import_method_ = false |
| 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 46 of file AS_asset_library.hh.
| blender::asset_system::AssetLibrary::AssetLibrary | ( | eAssetLibraryType | library_type, |
| bool | is_read_only, | ||
| StringRef | name = "", | ||
| StringRef | root_path = "" ) |
| is_read_only | If true, the user should not be able to edit assets or asset catalogs from this library. See is_read_only(). |
| 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 223 of file asset_library.cc.
References catalog_service_, is_read_only(), library_type(), name(), and root_path().
Referenced by blender::asset_system::AllAssetLibrary::AllAssetLibrary(), AssetRepresentation, blender::asset_system::AllAssetLibrary::force_remote_listing_download(), foreach_loaded(), blender::asset_system::OnDiskAssetLibrary::OnDiskAssetLibrary(), blender::asset_system::AllAssetLibrary::rebuild_catalogs_from_nested(), blender::asset_system::RemoteAssetLibrary::RemoteAssetLibrary(), and blender::asset_system::RuntimeAssetLibrary::RuntimeAssetLibrary().
|
virtual |
Definition at line 237 of file asset_library.cc.
References blender::bCallbackFuncStore::func, on_blend_save_handler_unregister(), and on_save_callback_store_.
| std::weak_ptr< AssetRepresentation > blender::asset_system::AssetLibrary::add_external_on_disk_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 318 of file asset_library.cc.
Referenced by blender::filelist_readjob_list_lib_add_datablock(), and import_method().
| std::weak_ptr< AssetRepresentation > blender::asset_system::AssetLibrary::add_external_online_asset | ( | StringRef | relative_asset_path, |
| StringRef | name, | ||
| int | id_type, | ||
| std::unique_ptr< AssetMetaData > | metadata, | ||
| OnlineAssetInfo | online_info ) |
See #AssetLibrary::add_external_on_disk_asset(). Use this for assets that are not available on disk, and part of an online asset library.
Definition at line 329 of file asset_library.cc.
Referenced by blender::filelist_readjob_list_lib_add_datablock(), and import_method().
| std::weak_ptr< AssetRepresentation > blender::asset_system::AssetLibrary::add_local_id_asset | ( | ID & | id | ) |
See #AssetLibrary::add_external_on_disk_asset().
Definition at line 341 of file asset_library.cc.
References lock.
Referenced by blender::filelist_readjob_main_assets_add_items(), and import_method().
|
virtual |
Reimplemented in blender::asset_system::PreferencesRemoteAssetLibrary.
Definition at line 272 of file asset_library.cc.
Referenced by blender::asset_system::AllAssetLibrary::force_remote_listing_download(), blender::asset_system::RemoteAssetLibrary::force_remote_listing_download(), and import_method().
| AssetCatalogService & blender::asset_system::AssetLibrary::catalog_service | ( | ) | const |
Definition at line 277 of file asset_library.cc.
References catalog_service_, catalog_service_mutex_, and lock.
Referenced by blender::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(), import_method(), load_or_reload_catalogs(), blender::asset_system::AssetLibraryService::move_runtime_current_file_into_on_disk_library(), on_blend_save_post(), blender::asset_system::AllAssetLibrary::rebuild_catalogs_from_nested(), refresh_catalog_simplename(), blender::asset_system::OnDiskAssetLibrary::refresh_catalogs(), blender::asset_system::RemoteAssetLibrary::refresh_catalogs(), blender::ed::geometry::register_node_group_operators(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and blender::asset_system::tests::TEST_F().
| std::shared_ptr< AssetCatalogService > blender::asset_system::AssetLibrary::catalog_service_ptr | ( | ) | const |
Get shared ownership of the catalog service. Unlike catalog_service(), this keeps the service alive for as long as the returned pointer is held, even if another thread replaces the library's catalog service in the meantime (e.g. a background catalog reload job). Use this instead of catalog_service() when accessing the service from a thread that may run concurrently with such a replacement (e.g. the drawing/main thread while an asset read job is running).
Definition at line 283 of file asset_library.cc.
References catalog_service_, catalog_service_mutex_, and lock.
Referenced by import_method().
|
virtual |
(Re-)download the remote listing for this library.
This only has an effect for asset libraries that are themselves a remote library, or contain one (such as the "Essentials" library if it includes online essentials, or the "All" if there are any remote libraries included).
The "Allow Online Access" option will be enforced internally, but probably some check to give a user message should be done at a higher level.
Reimplemented in blender::asset_system::AllAssetLibrary, blender::asset_system::EssentialsAssetLibrary, and blender::asset_system::RemoteAssetLibrary.
Definition at line 251 of file asset_library.cc.
Referenced by AssetRepresentation.
|
static |
Execute fn for every asset library that is loaded and enabled. The asset library is passed to the fn call.
| include_all_library | When true, 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 244 of file asset_library.cc.
References AssetLibrary(), AssetLibraryService, blender::asset_system::AssetLibraryService::foreach_loaded_asset_library(), and blender::asset_system::AssetLibraryService::get().
Referenced by AssetRepresentation, blender::asset_system::contains_assets_from_remote_url(), blender::filelist_readjob_all_asset_library(), blender::asset_system::AllAssetLibrary::force_remote_listing_download(), and blender::asset_system::AllAssetLibrary::rebuild_catalogs_from_nested().
|
pure virtual |
Get the import method that should be used for assets in this library.
Implemented in blender::asset_system::AllAssetLibrary, blender::asset_system::EssentialsAssetLibrary, blender::asset_system::OnDiskAssetLibrary, blender::asset_system::PreferencesOnDiskAssetLibrary, blender::asset_system::PreferencesRemoteAssetLibrary, blender::asset_system::RemoteAssetLibrary, and blender::asset_system::RuntimeAssetLibrary.
References add_external_on_disk_asset(), add_external_online_asset(), add_local_id_asset(), AssetRepresentation, auth_token(), catalog_service(), catalog_service_ptr(), is_read_only(), library_type(), load_or_reload_catalogs(), name(), on_blend_save_handler_register(), on_blend_save_handler_unregister(), on_blend_save_post(), refresh_catalog_simplename(), refresh_catalogs(), remap_ids_and_remove_invalid(), remote_url(), remove_asset(), resolve_asset_weak_reference_to_full_path(), root_path(), and use_relative_paths().
| bool blender::asset_system::AssetLibrary::is_read_only | ( | ) | const |
Check if this is a read-only library, meaning the user shouldn't be able to do edits to assets and asset catalogs from this library.
Of course it's possible to modify the .blend files containing the assets manually; and similarly, to open a .blend file in the library directory to edit asset catalogs. This function only speaks for editing directly via this library.
Definition at line 488 of file asset_library.cc.
Referenced by AssetLibrary(), AssetRepresentation, blender::ed::asset::get_user_library_ref_for_save(), import_method(), on_blend_save_post(), blender::asset_system::OnDiskAssetLibrary::OnDiskAssetLibrary(), and blender::asset_system::RemoteAssetLibrary::RemoteAssetLibrary().
|
pure virtual |
Get the AssetLibraryReference referencing this library. This can fail for custom libraries, which have too look up their bUserAssetLibrary. It will not return a value for values that were loaded directly through a path.
Implemented in blender::asset_system::AllAssetLibrary, blender::asset_system::EssentialsAssetLibrary, blender::asset_system::OnDiskAssetLibrary, blender::asset_system::OnlineEssentialsLibrary, blender::asset_system::PreferencesOnDiskAssetLibrary, blender::asset_system::PreferencesRemoteAssetLibrary, and blender::asset_system::RuntimeAssetLibrary.
References user_asset_library().
Referenced by blender::ed::asset::asset_library_from_context(), and blender::ed::asset::get_user_library_ref_for_save().
| eAssetLibraryType blender::asset_system::AssetLibrary::library_type | ( | ) | const |
Definition at line 473 of file asset_library.cc.
Referenced by AssetLibrary(), AssetRepresentation, blender::filelist_readjob_list_lib_add_datablock(), import_method(), blender::asset_system::OnDiskAssetLibrary::library_reference(), load_or_reload_catalogs(), blender::asset_system::OnDiskAssetLibrary::OnDiskAssetLibrary(), blender::remote_asset_library_load(), and blender::asset_system::RemoteAssetLibrary::RemoteAssetLibrary().
| void blender::asset_system::AssetLibrary::load_or_reload_catalogs | ( | ) |
Definition at line 294 of file asset_library.cc.
References blender::ASSET_LIBRARY_ESSENTIALS, catalog_service(), catalog_service_, catalog_service_mutex_, library_type(), blender::asset_system::AssetCatalogService::load_from_disk(), lock, and refresh_catalogs().
Referenced by blender::asset_system::AssetLibraryService::get_asset_library_on_disk(), blender::asset_system::AssetLibraryService::get_preferences_remote_asset_library(), import_method(), and blender::remote_asset_library_load().
| StringRefNull blender::asset_system::AssetLibrary::name | ( | ) | const |
Definition at line 478 of file asset_library.cc.
Referenced by add_external_on_disk_asset(), add_external_online_asset(), AssetLibrary(), AssetRepresentation, blender::compare_asset_catalog(), blender::filelist_readjob_remote_asset_library_index_read(), import_method(), blender::asset_system::OnDiskAssetLibrary::OnDiskAssetLibrary(), blender::asset_system::PreferencesOnDiskAssetLibrary::PreferencesOnDiskAssetLibrary(), blender::asset_system::PreferencesRemoteAssetLibrary::PreferencesRemoteAssetLibrary(), and blender::asset_system::RemoteAssetLibrary::RemoteAssetLibrary().
| void blender::asset_system::AssetLibrary::on_blend_save_handler_register | ( | ) |
Definition at line 424 of file asset_library.cc.
References blender::bCallbackFuncStore::alloc, blender::bCallbackFuncStore::arg, blender::BKE_callback_add(), blender::BKE_CB_EVT_SAVE_POST, blender::bCallbackFuncStore::func, and on_save_callback_store_.
Referenced by import_method(), blender::asset_system::OnDiskAssetLibrary::OnDiskAssetLibrary(), and blender::asset_system::RuntimeAssetLibrary::RuntimeAssetLibrary().
| void blender::asset_system::AssetLibrary::on_blend_save_handler_unregister | ( | ) |
Definition at line 435 of file asset_library.cc.
References blender::bCallbackFuncStore::arg, blender::BKE_callback_remove(), blender::BKE_CB_EVT_SAVE_POST, blender::bCallbackFuncStore::func, and on_save_callback_store_.
Referenced by import_method(), and ~AssetLibrary().
| void blender::asset_system::AssetLibrary::on_blend_save_post | ( | Main * | bmain, |
| PointerRNA ** | pointers, | ||
| int | num_pointers ) |
Definition at line 442 of file asset_library.cc.
References catalog_service(), blender::Main::filepath, is_read_only(), save_catalogs_when_file_is_saved, and blender::asset_system::AssetCatalogService::write_to_disk().
Referenced by import_method().
| 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 458 of file asset_library.cc.
References blender::BLI_uuid_is_nil(), blender::AssetMetaData::catalog_id, catalog_service(), blender::AssetMetaData::catalog_simple_name, blender::asset_system::AssetCatalogService::find_catalog(), blender::asset_system::AssetCatalog::simple_name, and blender::STRNCPY().
Referenced by import_method().
|
protectedvirtual |
Load catalogs that have changed on disk.
Reimplemented in blender::asset_system::AllAssetLibrary, blender::asset_system::EssentialsAssetLibrary, blender::asset_system::OnDiskAssetLibrary, and blender::asset_system::RemoteAssetLibrary.
Definition at line 289 of file asset_library.cc.
Referenced by import_method(), and load_or_reload_catalogs().
| void blender::asset_system::AssetLibrary::remap_ids_and_remove_invalid | ( | const 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 368 of file asset_library.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::bke::id::IDRemapper::apply(), AssetRepresentation, blender::BLI_assert(), blender::ID_REMAP_APPLY_DEFAULT, blender::ID_REMAP_RESULT_SOURCE_UNASSIGNED, blender::asset_system::AssetRepresentation::is_local_id(), lock, remove_asset(), and blender::result.
Referenced by import_method().
|
virtual |
Return the URL of the remote asset library, or #std::nullopt if this is not a remote library.
Note: don't use this as a way to distinguish remote vs. local libraries. Either query the asset itself, or use is_or_contains_remote_libraries(). The Essentials and All libraries may contain a mixture of remote and local assets.
Reimplemented in blender::asset_system::RemoteAssetLibrary.
Definition at line 266 of file asset_library.cc.
Referenced by blender::asset_system::contains_assets_from_remote_url(), blender::ED_fileselect_asset_import_method_get(), blender::filelist_readjob_all_asset_library(), blender::asset_system::AllAssetLibrary::force_remote_listing_download(), import_method(), and blender::asset_system::AllAssetLibrary::rebuild_catalogs_from_nested().
| bool blender::asset_system::AssetLibrary::remove_asset | ( | AssetRepresentation & | asset | ) |
Remove an asset from the library that was added using add_external_on_disk_asset() or add_local_id_asset(). Can usually be expected to be constant time complexity (worst case may differ).
Definition at line 348 of file asset_library.cc.
References AssetRepresentation, blender::BLI_assert(), lock, and remove_asset().
Referenced by blender::filelist_intern_entry_free(), import_method(), remap_ids_and_remove_invalid(), and remove_asset().
| std::string blender::asset_system::AssetLibrary::resolve_asset_weak_reference_to_full_path | ( | const AssetWeakReference & | asset_reference | ) |
Definition at line 451 of file asset_library.cc.
References AssetLibraryService, 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(), and import_method().
| StringRefNull blender::asset_system::AssetLibrary::root_path | ( | ) | const |
Definition at line 483 of file asset_library.cc.
Referenced by AssetLibrary(), AssetRepresentation, blender::filelist_readjob_all_asset_library(), blender::asset_system::AllAssetLibrary::force_remote_listing_download(), blender::asset_system::RemoteAssetLibrary::force_remote_listing_download(), import_method(), blender::asset_system::AssetLibraryService::move_runtime_current_file_into_on_disk_library(), blender::asset_system::OnDiskAssetLibrary::OnDiskAssetLibrary(), blender::asset_system::remote_library_asset_preview_path(), blender::asset_system::RemoteAssetLibrary::RemoteAssetLibrary(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and blender::asset_system::tests::TEST_F().
|
virtual |
Reimplemented in blender::asset_system::PreferencesOnDiskAssetLibrary.
Definition at line 261 of file asset_library.cc.
Referenced by import_method().
|
virtual |
Get the bUserAssetLibrary that's backing this asset library, if there is any.
Reimplemented in blender::asset_system::PreferencesOnDiskAssetLibrary, and blender::asset_system::PreferencesRemoteAssetLibrary.
Definition at line 256 of file asset_library.cc.
Referenced by library_reference().
|
friend |
Definition at line 115 of file AS_asset_library.hh.
References AssetLibraryService.
Referenced by AssetLibraryService, foreach_loaded(), and resolve_asset_weak_reference_to_full_path().
|
friend |
Definition at line 116 of file AS_asset_library.hh.
References AssetLibrary(), AssetRepresentation, force_remote_listing_download(), foreach_loaded(), is_read_only(), library_type(), name(), and root_path().
Referenced by AssetRepresentation, import_method(), remap_ids_and_remove_invalid(), and remove_asset().
|
protected |
Definition at line 99 of file AS_asset_library.hh.
Referenced by AssetLibrary(), catalog_service(), catalog_service_ptr(), load_or_reload_catalogs(), and blender::asset_system::AssetLibraryService::move_runtime_current_file_into_on_disk_library().
|
mutableprotected |
Definition at line 100 of file AS_asset_library.hh.
Referenced by catalog_service(), catalog_service_ptr(), load_or_reload_catalogs(), and blender::asset_system::AssetLibraryService::move_runtime_current_file_into_on_disk_library().
|
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 106 of file AS_asset_library.hh.
Referenced by blender::asset_system::PreferencesRemoteAssetLibrary::PreferencesRemoteAssetLibrary(), and blender::asset_system::RemoteAssetLibrary::RemoteAssetLibrary().
|
protected |
Definition at line 108 of file AS_asset_library.hh.
Referenced by on_blend_save_handler_register(), on_blend_save_handler_unregister(), and ~AssetLibrary().
|
static |
Definition at line 113 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().