Changeset View
Changeset View
Standalone View
Standalone View
source/blender/asset_system/intern/asset_library_service.cc
- This file was moved from source/blender/blenkernel/intern/asset_library_service.cc.
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| /** \file | /** \file | ||||
| * \ingroup bke | * \ingroup asset_system | ||||
| */ | */ | ||||
| #include "asset_library_service.hh" | #include "asset_library_service.hh" | ||||
| #include "AS_asset_library.hh" | |||||
| #include "BKE_asset_library.hh" | |||||
| #include "BKE_blender.h" | #include "BKE_blender.h" | ||||
| #include "BKE_preferences.h" | #include "BKE_preferences.h" | ||||
| #include "BLI_fileops.h" /* For PATH_MAX (at least on Windows). */ | #include "BLI_fileops.h" /* For PATH_MAX (at least on Windows). */ | ||||
| #include "BLI_path_util.h" | #include "BLI_path_util.h" | ||||
| #include "BLI_string_ref.hh" | #include "BLI_string_ref.hh" | ||||
| #include "DNA_asset_types.h" | #include "DNA_asset_types.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "CLG_log.h" | #include "CLG_log.h" | ||||
| static CLG_LogRef LOG = {"bke.asset_service"}; | static CLG_LogRef LOG = {"asset_system.asset_library_service"}; | ||||
| namespace blender::bke { | namespace blender::asset_system { | ||||
| std::unique_ptr<AssetLibraryService> AssetLibraryService::instance_; | std::unique_ptr<AssetLibraryService> AssetLibraryService::instance_; | ||||
| bool AssetLibraryService::atexit_handler_registered_ = false; | bool AssetLibraryService::atexit_handler_registered_ = false; | ||||
| AssetLibraryService *AssetLibraryService::get() | AssetLibraryService *AssetLibraryService::get() | ||||
| { | { | ||||
| if (!instance_) { | if (!instance_) { | ||||
| allocate_service_instance(); | allocate_service_instance(); | ||||
| Show All 10 Lines | void AssetLibraryService::destroy() | ||||
| instance_.reset(); | instance_.reset(); | ||||
| } | } | ||||
| AssetLibrary *AssetLibraryService::get_asset_library( | AssetLibrary *AssetLibraryService::get_asset_library( | ||||
| const Main *bmain, const AssetLibraryReference &library_reference) | const Main *bmain, const AssetLibraryReference &library_reference) | ||||
| { | { | ||||
| if (library_reference.type == ASSET_LIBRARY_LOCAL) { | if (library_reference.type == ASSET_LIBRARY_LOCAL) { | ||||
| /* For the "Current File" library we get the asset library root path based on main. */ | /* For the "Current File" library we get the asset library root path based on main. */ | ||||
| std::string root_path = bmain ? BKE_asset_library_find_suitable_root_path_from_main(bmain) : | std::string root_path = bmain ? AS_asset_library_find_suitable_root_path_from_main(bmain) : ""; | ||||
| ""; | |||||
| if (root_path.empty()) { | if (root_path.empty()) { | ||||
| /* File wasn't saved yet. */ | /* File wasn't saved yet. */ | ||||
| return get_asset_library_current_file(); | return get_asset_library_current_file(); | ||||
| } | } | ||||
| return get_asset_library_on_disk(root_path); | return get_asset_library_on_disk(root_path); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | if (current_file_library_) { | ||||
| fn(*current_file_library_); | fn(*current_file_library_); | ||||
| } | } | ||||
| for (const auto &asset_lib_uptr : on_disk_libraries_.values()) { | for (const auto &asset_lib_uptr : on_disk_libraries_.values()) { | ||||
| fn(*asset_lib_uptr); | fn(*asset_lib_uptr); | ||||
| } | } | ||||
| } | } | ||||
| } // namespace blender::bke | } // namespace blender::asset_system | ||||