|
Blender V5.3
|
#include <asset_library_service.hh>
Classes | |
| struct | ExplodedPath |
Static Public Member Functions | |
| static AssetLibraryService * | get () |
| static void | destroy () |
| static std::string | root_path_from_library_ref (const AssetLibraryReference &library_reference) |
| static bUserAssetLibrary * | find_custom_asset_library_from_library_ref (const AssetLibraryReference &library_reference) |
| static bUserAssetLibrary * | find_custom_preferences_asset_library_from_asset_weak_ref (const AssetWeakReference &asset_reference) |
| static AssetLibrary * | move_runtime_current_file_into_on_disk_library (const Main &bmain) |
Protected Member Functions | |
| OnDiskAssetLibrary * | lookup_on_disk_library (eAssetLibraryType type, StringRefNull root_path) |
| AssetLibrary * | find_loaded_on_disk_asset_library_from_name (StringRef name) const |
| AssetLibrary * | get_online_essentials_asset_library () |
| AssetLibrary * | get_preferences_remote_asset_library (const bUserAssetLibrary &custom_library) |
| AssetLibrary * | get_asset_library_on_disk (eAssetLibraryType library_type, StringRef name, StringRefNull root_path, bool load_catalogs=true, bUserAssetLibrary *preferences_library=nullptr) |
| void | app_handler_register () |
| void | app_handler_unregister () |
Static Protected Member Functions | |
| static void | allocate_service_instance () |
Global singleton-ish that provides access to individual AssetLibrary instances.
Whenever a blend file is loaded, the existing instance of AssetLibraryService is destructed, and a new one is created – hence the "singleton-ish". This ensures only information about relevant asset libraries is loaded.
Definition at line 48 of file asset_library_service.hh.
|
default |
Referenced by get(), move_runtime_current_file_into_on_disk_library(), and ~AssetLibraryService().
|
default |
References AssetLibraryService(), destroy(), find_custom_asset_library_from_library_ref(), find_custom_preferences_asset_library_from_asset_weak_ref(), get(), get_asset_library(), get_asset_library_all(), get_asset_library_current_file(), get_asset_library_on_disk_builtin(), get_asset_library_on_disk_custom(), get_asset_library_on_disk_custom_preferences(), move_runtime_current_file_into_on_disk_library(), normalize_asset_weak_reference_relative_asset_identifier(), reload_all_library_catalogs_if_dirty(), resolve_asset_weak_reference_to_full_path(), resolve_asset_weak_reference_to_library_path(), rfind_blendfile_extension(), root_path_from_library_ref(), and tag_all_library_catalogs_dirty().
|
staticprotected |
Allocate a new instance of the service and assign it to instance_.
Definition at line 635 of file asset_library_service.cc.
References blender::BKE_blender_atexit_register(), and destroy().
Referenced by get().
|
protected |
Ensure the AssetLibraryService instance is destroyed before a new blend file is loaded. This makes memory management simple, and ensures a fresh start for every blend file.
Definition at line 658 of file asset_library_service.cc.
References blender::BKE_callback_add(), blender::BKE_CB_EVT_LOAD_PRE, and blender::asset_system::on_blendfile_load().
|
protected |
Definition at line 669 of file asset_library_service.cc.
References blender::BKE_callback_remove(), and blender::BKE_CB_EVT_LOAD_PRE.
Referenced by destroy().
|
static |
Destroy the AssetLibraryService singleton. It will be reallocated by get() if necessary.
Definition at line 65 of file asset_library_service.cc.
References app_handler_unregister().
Referenced by allocate_service_instance(), blender::AS_asset_libraries_exit(), blender::asset_system::on_blendfile_load(), blender::asset_system::tests::AssetLibraryServiceTest::TearDown(), blender::asset_system::tests::AssetLibraryTest::TearDown(), blender::asset_system::tests::AssetLibraryTestBase::TearDown(), blender::asset_system::tests::TEST_F(), and ~AssetLibraryService().
|
static |
Definition at line 604 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_CUSTOM, blender::BKE_preferences_asset_library_find_index(), blender::BLI_assert(), blender::AssetLibraryReference::custom_library_index, blender::AssetLibraryReference::type, and blender::U.
Referenced by get_asset_library(), blender::asset_system::is_or_contains_remote_libraries(), root_path_from_library_ref(), and ~AssetLibraryService().
|
static |
Definition at line 403 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_CUSTOM, blender::AssetWeakReference::asset_library_identifier, blender::AssetWeakReference::asset_library_type, blender::BKE_preferences_asset_library_find_by_name(), ELEM, and blender::U.
Referenced by resolve_asset_weak_reference_to_library_path(), and ~AssetLibraryService().
|
protected |
Definition at line 413 of file asset_library_service.cc.
References lock.
Referenced by resolve_asset_weak_reference_to_library_path().
| void blender::asset_system::AssetLibraryService::foreach_loaded_asset_library | ( | FunctionRef< void(AssetLibrary &)> | fn, |
| bool | include_all_library ) const |
See AssetLibrary::foreach_loaded().
Definition at line 690 of file asset_library_service.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::ASSET_LIBRARY_ESSENTIALS, lock, blender::U, blender::USER_ASSETS_USE_ONLINE_ESSENTIALS, and USER_EXPERIMENTAL_TEST.
Referenced by blender::AS_asset_library_remap_ids(), blender::asset_system::AssetLibrary::foreach_loaded(), and has_any_unsaved_catalogs().
|
static |
Return the AssetLibraryService singleton, allocating it if necessary.
Definition at line 57 of file asset_library_service.cc.
References allocate_service_instance(), AssetLibraryService(), and get().
Referenced by blender::asset_system::all_library_reload_catalogs_if_dirty(), blender::asset_system::all_library_tag_catalogs_dirty(), blender::AS_asset_full_path_explode_from_weak_ref(), blender::AS_asset_library_has_any_unsaved_catalogs(), blender::AS_asset_library_load(), blender::AS_asset_library_load_from_directory(), blender::AS_asset_library_remap_ids(), blender::asset_system::AssetCatalogService::create_catalog(), blender::asset_system::AssetLibrary::foreach_loaded(), get(), blender::asset_system::tests::AssetRepresentationTest::get_builtin_library_from_type(), move_runtime_current_file_into_on_disk_library(), blender::asset_system::AssetCatalogService::prune_catalogs_by_path(), blender::asset_system::AssetCatalogService::redo(), blender::asset_system::AssetLibrary::resolve_asset_weak_reference_to_full_path(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::AssetCatalogService::undo(), blender::asset_system::AssetCatalogService::update_catalog_path(), and ~AssetLibraryService().
| AssetLibrary * blender::asset_system::AssetLibraryService::get_asset_library | ( | const Main * | bmain, |
| const AssetLibraryReference & | library_reference ) |
Definition at line 74 of file asset_library_service.cc.
References blender::AS_asset_library_find_suitable_root_path_from_main(), blender::ASSET_LIBRARY_ALL, blender::ASSET_LIBRARY_CUSTOM, blender::ASSET_LIBRARY_ESSENTIALS, blender::ASSET_LIBRARY_LOCAL, blender::ASSET_LIBRARY_ONLINE_ESSENTIALS, blender::ASSET_LIBRARY_USE_REMOTE_URL, blender::asset_system::essentials_directory_path(), find_custom_asset_library_from_library_ref(), blender::bUserAssetLibrary::flag, get_asset_library_all(), get_asset_library_current_file(), get_asset_library_on_disk_builtin(), get_asset_library_on_disk_custom_preferences(), get_online_essentials_asset_library(), get_preferences_remote_asset_library(), blender::blender::StringRefBase::is_empty(), blender::asset_system::is_online_essentials_url(), blender::bUserAssetLibrary::remote_url, blender::bUserAssetLibrary::resolved_dirpath, and blender::AssetLibraryReference::type.
Referenced by blender::AS_asset_library_load(), get_asset_library_all(), blender::asset_system::tests::AssetRepresentationTest::get_builtin_library_from_type(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and ~AssetLibraryService().
| AssetLibrary * blender::asset_system::AssetLibraryService::get_asset_library_all | ( | const Main * | bmain | ) |
Get the "All" asset library, which loads all others and merges them into one.
Definition at line 362 of file asset_library_service.cc.
References blender::asset_system::all_valid_asset_library_refs(), blender::ASSET_LIBRARY_ALL, CLOG_DEBUG, get_asset_library(), and blender::LOG.
Referenced by get_asset_library(), and ~AssetLibraryService().
| AssetLibrary * blender::asset_system::AssetLibraryService::get_asset_library_current_file | ( | ) |
Get the "Current File" asset library.
Definition at line 265 of file asset_library_service.cc.
References CLOG_DEBUG, and blender::LOG.
Referenced by blender::AS_asset_library_load_from_directory(), get_asset_library(), 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 ~AssetLibraryService().
|
protected |
Get the given asset library. Opens it (i.e. creates a new AssetLibrary instance) if necessary.
| root_path | The top level directory. |
| preferences_library | The definition of the library from the Preferences. Set this to null if the library is not registered in the Preferences (but non-null if it is!). |
Definition at line 180 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_CUSTOM, blender::ASSET_LIBRARY_ESSENTIALS, blender::ASSET_LIBRARY_LOCAL, CLOG_DEBUG, blender::asset_system::AssetLibrary::load_or_reload_catalogs(), lock, blender::LOG, lookup_on_disk_library(), and blender::asset_system::utils::resolve_directory_path().
Referenced by get_asset_library_on_disk_builtin(), get_asset_library_on_disk_custom(), get_asset_library_on_disk_custom_preferences(), and move_runtime_current_file_into_on_disk_library().
| AssetLibrary * blender::asset_system::AssetLibraryService::get_asset_library_on_disk_builtin | ( | eAssetLibraryType | type, |
| StringRefNull | root_path ) |
Get a builtin (not user defined) asset library. I.e. a library that is not of type ASSET_LIBRARY_CUSTOM.
Definition at line 253 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_CUSTOM, BLI_assert_msg, and get_asset_library_on_disk().
Referenced by get_asset_library(), and ~AssetLibraryService().
| AssetLibrary * blender::asset_system::AssetLibraryService::get_asset_library_on_disk_custom | ( | StringRef | name, |
| StringRefNull | root_path ) |
Get an asset library of type ASSET_LIBRARY_CUSTOM from a directory path. Use get_asset_library_on_disk_custom_preferences() for asset libraries registered in the Preferences.
Definition at line 237 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_CUSTOM, and get_asset_library_on_disk().
Referenced by blender::AS_asset_library_load_from_directory(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), 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 ~AssetLibraryService().
| AssetLibrary * blender::asset_system::AssetLibraryService::get_asset_library_on_disk_custom_preferences | ( | bUserAssetLibrary * | custom_library | ) |
Get an asset library of type ASSET_LIBRARY_CUSTOM from an asset library definition in the Preferences.
Definition at line 243 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_CUSTOM, get_asset_library_on_disk(), blender::bUserAssetLibrary::name, and blender::bUserAssetLibrary::resolved_dirpath.
Referenced by get_asset_library(), and ~AssetLibraryService().
|
protected |
Definition at line 133 of file asset_library_service.cc.
References CLOG_DEBUG, and blender::LOG.
Referenced by get_asset_library().
|
protected |
Definition at line 148 of file asset_library_service.cc.
References blender::StringRefNull::c_str(), CLOG_DEBUG, blender::asset_system::AssetLibrary::load_or_reload_catalogs(), lock, blender::LOG, and blender::bUserAssetLibrary::remote_url.
Referenced by get_asset_library().
| bool blender::asset_system::AssetLibraryService::has_any_unsaved_catalogs | ( | ) | const |
Returns whether there are any known asset libraries with unsaved catalog edits.
Definition at line 676 of file asset_library_service.cc.
References foreach_loaded_asset_library().
Referenced by blender::AS_asset_library_has_any_unsaved_catalogs(), blender::asset_system::tests::TEST_F(), and blender::asset_system::tests::TEST_F().
|
protected |
Definition at line 389 of file asset_library_service.cc.
References BLI_assert_msg, blender::blender::StringRefBase::is_empty(), lock, and blender::asset_system::utils::resolve_directory_path().
Referenced by get_asset_library_on_disk(), and move_runtime_current_file_into_on_disk_library().
|
static |
Turn the runtime current file library into an on-disk current file library, preserving catalog data like undo/redo history, deleted catalog info, catalog saving state, etc. Note that this creates a new on-disk asset library and destroys the runtime one.
Call when the .blend file is saved to disk.
Definition at line 298 of file asset_library_service.cc.
References blender::AS_asset_library_find_suitable_root_path_from_main(), blender::ASSET_LIBRARY_LOCAL, AssetLibraryService(), blender::BLI_assert(), BLI_assert_msg, BLI_path_join, blender::StringRefNull::c_str(), blender::asset_system::AssetLibrary::catalog_service(), blender::asset_system::AssetLibrary::catalog_service_, blender::asset_system::AssetLibrary::catalog_service_mutex_, blender::asset_system::AssetCatalogService::construct_cdf_in_memory(), blender::asset_system::AssetCatalogService::DEFAULT_CATALOG_FILENAME, get(), get_asset_library_on_disk(), blender::asset_system::AssetCatalogService::get_catalog_definition_file(), lock, lookup_on_disk_library(), PATH_MAX, and blender::asset_system::AssetLibrary::root_path().
Referenced by blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and ~AssetLibraryService().
| std::string blender::asset_system::AssetLibraryService::normalize_asset_weak_reference_relative_asset_identifier | ( | const AssetWeakReference & | asset_reference | ) |
Return a normalized version of #AssetWeakReference.relative_asset_identifier. Special care is required here because slashes or backslashes should not be converted in the ID name itself.
Definition at line 491 of file asset_library_service.cc.
References ALTSEP_STR, blender::BLI_assert(), blender::blender::StringRefBase::find_first_of(), blender::blender::StringRefBase::not_found, blender::AssetWeakReference::relative_asset_identifier, blender::asset_system::utils::resolve_path(), rfind_blendfile_extension(), and SEP_STR.
Referenced by resolve_asset_weak_reference_to_exploded_path(), resolve_asset_weak_reference_to_full_path(), and ~AssetLibraryService().
| void blender::asset_system::AssetLibraryService::reload_all_library_catalogs_if_dirty | ( | ) |
Definition at line 287 of file asset_library_service.cc.
Referenced by blender::asset_system::all_library_reload_catalogs_if_dirty(), and ~AssetLibraryService().
| std::optional< AssetLibraryService::ExplodedPath > blender::asset_system::AssetLibraryService::resolve_asset_weak_reference_to_exploded_path | ( | const AssetWeakReference & | asset_reference | ) |
Similar to BKE_blendfile_library_path_explode, returns the full path as resolve_asset_weak_reference_to_library_path, with StringRefs to the dir (i.e. blendfile path), group (i.e. ID type) and name (i.e. ID name) parts.
Definition at line 546 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_ALL, blender::ASSET_LIBRARY_CUSTOM, blender::ASSET_LIBRARY_ESSENTIALS, blender::ASSET_LIBRARY_LOCAL, blender::ASSET_LIBRARY_ONLINE_ESSENTIALS, blender::AssetWeakReference::asset_library_type, blender::BLI_assert(), blender::asset_system::AssetLibraryService::ExplodedPath::dir_component, blender::asset_system::AssetLibraryService::ExplodedPath::full_path, blender::asset_system::AssetLibraryService::ExplodedPath::group_component, blender::asset_system::AssetLibraryService::ExplodedPath::name_component, normalize_asset_weak_reference_relative_asset_identifier(), blender::blender::StringRefBase::not_found, blender::AssetWeakReference::relative_asset_identifier, resolve_asset_weak_reference_to_full_path(), rfind_blendfile_extension(), blender::SEP, blender::StringRef::StringRef(), and blender::blender::StringRefBase::substr().
Referenced by blender::AS_asset_full_path_explode_from_weak_ref(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and blender::asset_system::tests::TEST_F().
| std::string blender::asset_system::AssetLibraryService::resolve_asset_weak_reference_to_full_path | ( | const AssetWeakReference & | asset_reference | ) |
Attempt to build a full path to an asset based on the currently available (not necessary loaded) asset libraries. The path is not guaranteed to exist. The returned path will be normalized and using native slashes.
Definition at line 522 of file asset_library_service.cc.
References normalize_asset_weak_reference_relative_asset_identifier(), blender::AssetWeakReference::relative_asset_identifier, resolve_asset_weak_reference_to_library_path(), blender::asset_system::utils::resolve_path(), and SEP_STR.
Referenced by resolve_asset_weak_reference_to_exploded_path(), blender::asset_system::AssetLibrary::resolve_asset_weak_reference_to_full_path(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and ~AssetLibraryService().
| std::string blender::asset_system::AssetLibraryService::resolve_asset_weak_reference_to_library_path | ( | const AssetWeakReference & | asset_reference | ) |
Get a valid library path from the weak reference. Empty if e.g. the reference is to a local asset.
Definition at line 425 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_ALL, blender::ASSET_LIBRARY_CUSTOM, blender::ASSET_LIBRARY_ESSENTIALS, blender::AssetWeakReference::asset_library_identifier, blender::ASSET_LIBRARY_LOCAL, blender::ASSET_LIBRARY_ONLINE_ESSENTIALS, blender::AssetWeakReference::asset_library_type, blender::asset_system::essentials_directory_path(), find_custom_preferences_asset_library_from_asset_weak_ref(), find_loaded_on_disk_asset_library_from_name(), blender::asset_system::online_essentials_cache_directory_path(), blender::asset_system::utils::resolve_path(), and blender::bUserAssetLibrary::resolved_dirpath.
Referenced by resolve_asset_weak_reference_to_full_path(), and ~AssetLibraryService().
Return the start position of the last blend-file extension in given path, or #std::string::npos if not found. Works with both kind of path separators.
Definition at line 465 of file asset_library_service.cc.
References ALTSEP_STR, blender::blender::StringRefBase::not_found, blender::blender::StringRefBase::rfind(), and SEP_STR.
Referenced by normalize_asset_weak_reference_relative_asset_identifier(), resolve_asset_weak_reference_to_exploded_path(), and ~AssetLibraryService().
|
static |
Definition at line 613 of file asset_library_service.cc.
References blender::ASSET_LIBRARY_ALL, blender::ASSET_LIBRARY_ESSENTIALS, blender::ASSET_LIBRARY_LOCAL, blender::ASSET_LIBRARY_ONLINE_ESSENTIALS, ELEM, blender::asset_system::essentials_directory_path(), find_custom_asset_library_from_library_ref(), blender::asset_system::online_essentials_cache_directory_path(), blender::bUserAssetLibrary::resolved_dirpath, and blender::AssetLibraryReference::type.
Referenced by blender::AS_asset_library_root_path_from_library_ref(), and ~AssetLibraryService().
| void blender::asset_system::AssetLibraryService::tag_all_library_catalogs_dirty | ( | ) |
Tag the "All" asset library as needing to reload catalogs. This should be called when catalog data of other asset libraries changes. Note that changes to the catalog definition file on disk don't ever affect this "dirty" flag. It only reflects changes from this Blender session.
Definition at line 280 of file asset_library_service.cc.
Referenced by blender::asset_system::all_library_tag_catalogs_dirty(), blender::asset_system::AssetCatalogService::create_catalog(), blender::asset_system::AssetCatalogService::prune_catalogs_by_path(), blender::asset_system::AssetCatalogService::redo(), blender::asset_system::AssetCatalogService::undo(), blender::asset_system::AssetCatalogService::update_catalog_path(), and ~AssetLibraryService().