Blender
V3.3
|
#include <asset_library_service.hh>
Public Types | |
using | AssetLibraryPtr = std::unique_ptr< AssetLibrary > |
Public Member Functions | |
AssetLibraryService ()=default | |
~AssetLibraryService ()=default | |
AssetLibrary * | get_asset_library_on_disk (StringRefNull top_level_directory) |
AssetLibrary * | get_asset_library_current_file () |
bool | has_any_unsaved_catalogs () const |
Static Public Member Functions | |
static AssetLibraryService * | get () |
static void | destroy () |
Protected Member Functions | |
void | app_handler_register () |
void | app_handler_unregister () |
Static Protected Member Functions | |
static void | allocate_service_instance () |
Protected Attributes | |
Map< std::string, AssetLibraryPtr > | on_disk_libraries_ |
AssetLibraryPtr | current_file_library_ |
bCallbackFuncStore | on_load_callback_store_ |
Static Protected Attributes | |
static std::unique_ptr< AssetLibraryService > | instance_ |
static bool | atexit_handler_registered_ = false |
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 34 of file asset_library_service.hh.
using blender::bke::AssetLibraryService::AssetLibraryPtr = std::unique_ptr<AssetLibrary> |
Definition at line 36 of file asset_library_service.hh.
|
default |
|
default |
|
staticprotected |
Allocate a new instance of the service and assign it to instance_
.
Definition at line 93 of file asset_library_service.cc.
References atexit_handler_registered_, BKE_blender_atexit_register(), destroy(), and instance_.
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 114 of file asset_library_service.cc.
References bCallbackFuncStore::alloc, bCallbackFuncStore::arg, BKE_callback_add(), BKE_CB_EVT_LOAD_PRE, bCallbackFuncStore::func, blender::bke::on_blendfile_load(), and on_load_callback_store_.
|
protected |
Definition at line 125 of file asset_library_service.cc.
References bCallbackFuncStore::arg, BKE_callback_remove(), BKE_CB_EVT_LOAD_PRE, bCallbackFuncStore::func, and on_load_callback_store_.
|
static |
Destroy the AssetLibraryService singleton. It will be reallocated by get() if necessary.
Definition at line 32 of file asset_library_service.cc.
References instance_.
Referenced by allocate_service_instance(), blender::bke::on_blendfile_load(), blender::bke::tests::AssetLibraryServiceTest::TearDown(), blender::bke::tests::AssetLibraryTest::TearDown(), and blender::bke::tests::TEST_F().
|
static |
Return the AssetLibraryService singleton, allocating it if necessary.
Definition at line 24 of file asset_library_service.cc.
References allocate_service_instance(), and instance_.
Referenced by BKE_asset_library_has_any_unsaved_catalogs(), BKE_asset_library_load(), and blender::bke::tests::TEST_F().
AssetLibrary * blender::bke::AssetLibraryService::get_asset_library_current_file | ( | ) |
Get the "Current File" asset library.
Definition at line 78 of file asset_library_service.cc.
References CLOG_INFO, current_file_library_, lib, and LOG.
Referenced by BKE_asset_library_load(), and blender::bke::tests::TEST_F().
AssetLibrary * blender::bke::AssetLibraryService::get_asset_library_on_disk | ( | StringRefNull | top_level_directory | ) |
Get the given asset library. Opens it (i.e. creates a new AssetLibrary instance) if necessary.
Definition at line 52 of file asset_library_service.cc.
References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), BLI_assert_msg, CLOG_INFO, blender::StringRefBase::is_empty(), lib, LOG, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_ptr(), and on_disk_libraries_.
Referenced by BKE_asset_library_load(), and blender::bke::tests::TEST_F().
bool blender::bke::AssetLibraryService::has_any_unsaved_catalogs | ( | ) | const |
Returns whether there are any known asset libraries with unsaved catalog edits.
Definition at line 132 of file asset_library_service.cc.
References current_file_library_, on_disk_libraries_, and blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::values().
Referenced by BKE_asset_library_has_any_unsaved_catalogs(), and blender::bke::tests::TEST_F().
|
staticprotected |
Definition at line 67 of file asset_library_service.hh.
Referenced by allocate_service_instance().
|
protected |
Definition at line 63 of file asset_library_service.hh.
Referenced by get_asset_library_current_file(), and has_any_unsaved_catalogs().
|
staticprotected |
Definition at line 59 of file asset_library_service.hh.
Referenced by allocate_service_instance(), destroy(), and get().
|
protected |
Definition at line 62 of file asset_library_service.hh.
Referenced by get_asset_library_on_disk(), and has_any_unsaved_catalogs().
|
protected |
Definition at line 66 of file asset_library_service.hh.
Referenced by app_handler_register(), and app_handler_unregister().