Blender  V3.3
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
blender::bke::AssetLibraryService Class Reference

#include <asset_library_service.hh>

Public Types

using AssetLibraryPtr = std::unique_ptr< AssetLibrary >
 

Public Member Functions

 AssetLibraryService ()=default
 
 ~AssetLibraryService ()=default
 
AssetLibraryget_asset_library_on_disk (StringRefNull top_level_directory)
 
AssetLibraryget_asset_library_current_file ()
 
bool has_any_unsaved_catalogs () const
 

Static Public Member Functions

static AssetLibraryServiceget ()
 
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, AssetLibraryPtron_disk_libraries_
 
AssetLibraryPtr current_file_library_
 
bCallbackFuncStore on_load_callback_store_
 

Static Protected Attributes

static std::unique_ptr< AssetLibraryServiceinstance_
 
static bool atexit_handler_registered_ = false
 

Detailed Description

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.

Note
How Asset libraries are identified may change in the future. For now they are assumed to be:
  • on disk (identified by the absolute directory), or
  • the "current file" library (which is in memory but could have catalogs loaded from a file on disk).

Definition at line 34 of file asset_library_service.hh.

Member Typedef Documentation

◆ AssetLibraryPtr

Definition at line 36 of file asset_library_service.hh.

Constructor & Destructor Documentation

◆ AssetLibraryService()

blender::bke::AssetLibraryService::AssetLibraryService ( )
default

◆ ~AssetLibraryService()

blender::bke::AssetLibraryService::~AssetLibraryService ( )
default

Member Function Documentation

◆ allocate_service_instance()

void blender::bke::AssetLibraryService::allocate_service_instance ( )
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().

◆ app_handler_register()

void blender::bke::AssetLibraryService::app_handler_register ( )
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_.

◆ app_handler_unregister()

void blender::bke::AssetLibraryService::app_handler_unregister ( )
protected

◆ destroy()

void blender::bke::AssetLibraryService::destroy ( )
static

◆ get()

AssetLibraryService * blender::bke::AssetLibraryService::get ( )
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().

◆ get_asset_library_current_file()

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().

◆ get_asset_library_on_disk()

AssetLibrary * blender::bke::AssetLibraryService::get_asset_library_on_disk ( StringRefNull  top_level_directory)

◆ has_any_unsaved_catalogs()

bool blender::bke::AssetLibraryService::has_any_unsaved_catalogs ( ) const

Member Data Documentation

◆ atexit_handler_registered_

bool blender::bke::AssetLibraryService::atexit_handler_registered_ = false
staticprotected

Definition at line 67 of file asset_library_service.hh.

Referenced by allocate_service_instance().

◆ current_file_library_

AssetLibraryPtr blender::bke::AssetLibraryService::current_file_library_
protected

◆ instance_

std::unique_ptr< AssetLibraryService > blender::bke::AssetLibraryService::instance_
staticprotected

Definition at line 59 of file asset_library_service.hh.

Referenced by allocate_service_instance(), destroy(), and get().

◆ on_disk_libraries_

Map<std::string, AssetLibraryPtr> blender::bke::AssetLibraryService::on_disk_libraries_
protected

Definition at line 62 of file asset_library_service.hh.

Referenced by get_asset_library_on_disk(), and has_any_unsaved_catalogs().

◆ on_load_callback_store_

bCallbackFuncStore blender::bke::AssetLibraryService::on_load_callback_store_
protected

Definition at line 66 of file asset_library_service.hh.

Referenced by app_handler_register(), and app_handler_unregister().


The documentation for this class was generated from the following files: