Changeset View
Changeset View
Standalone View
Standalone View
source/blender/asset_system/AS_asset_library.hh
- This file was moved from source/blender/blenkernel/BKE_asset_library.hh.
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| /** \file | /** \file | ||||
| * \ingroup bke | * \ingroup asset_system | ||||
| */ | */ | ||||
| #pragma once | #pragma once | ||||
| #ifndef __cplusplus | |||||
| # error This is a C++-only header file. Use BKE_asset_library.h instead. | |||||
| #endif | |||||
| #include "DNA_asset_types.h" | #include "DNA_asset_types.h" | ||||
| #include "BLI_string_ref.hh" | #include "BLI_string_ref.hh" | ||||
| #include "BLI_vector.hh" | #include "BLI_vector.hh" | ||||
| #include "BKE_asset_library.h" | #include "AS_asset_catalog.hh" | ||||
| #include "BKE_asset_catalog.hh" | |||||
| #include "BKE_callbacks.h" | #include "BKE_callbacks.h" | ||||
| #include <memory> | #include <memory> | ||||
| struct AssetLibrary; | |||||
| struct AssetLibraryReference; | struct AssetLibraryReference; | ||||
| struct AssetMetaData; | |||||
| struct Main; | struct Main; | ||||
| namespace blender::bke { | namespace blender::asset_system { | ||||
| class AssetRepresentation; | class AssetRepresentation; | ||||
| /** | /** | ||||
| * AssetLibrary provides access to an asset library's data. | * AssetLibrary provides access to an asset library's data. | ||||
| * | * | ||||
| * The asset library contains catalogs and storage for asset representations. It could be extended | * The asset library contains catalogs and storage for asset representations. It could be extended | ||||
| * to also include asset indexes and more. | * to also include asset indexes and more. | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | private: | ||||
| */ | */ | ||||
| Vector<std::unique_ptr<AssetRepresentation>> asset_storage_; | Vector<std::unique_ptr<AssetRepresentation>> asset_storage_; | ||||
| std::optional<int> find_asset_index(const AssetRepresentation &asset); | std::optional<int> find_asset_index(const AssetRepresentation &asset); | ||||
| }; | }; | ||||
| Vector<AssetLibraryReference> all_valid_asset_library_refs(); | Vector<AssetLibraryReference> all_valid_asset_library_refs(); | ||||
| } // namespace blender::bke | } // namespace blender::asset_system | ||||
| blender::bke::AssetLibrary *BKE_asset_library_load(const Main *bmain, | blender::asset_system::AssetLibrary *AS_asset_library_load( | ||||
| const AssetLibraryReference &library_reference); | const Main *bmain, const AssetLibraryReference &library_reference); | ||||
| /** | /** | ||||
| * Try to find an appropriate location for an asset library root from a file or directory path. | * Try to find an appropriate location for an asset library root from a file or directory path. | ||||
| * Does not check if \a input_path exists. | * Does not check if \a input_path exists. | ||||
| * | * | ||||
| * The design is made to find an appropriate asset library path from a .blend file path, but | * The design is made to find an appropriate asset library path from a .blend file path, but | ||||
| * technically works with any file or directory as \a input_path. | * technically works with any file or directory as \a input_path. | ||||
| * Design is: | * Design is: | ||||
| * * If \a input_path lies within a known asset library path (i.e. an asset library registered in | * * If \a input_path lies within a known asset library path (i.e. an asset library registered in | ||||
| * the Preferences), return the asset library path. | * the Preferences), return the asset library path. | ||||
| * * Otherwise, if \a input_path has a parent path, return the parent path (e.g. to use the | * * Otherwise, if \a input_path has a parent path, return the parent path (e.g. to use the | ||||
| * directory a .blend file is in as asset library root). | * directory a .blend file is in as asset library root). | ||||
| * * If \a input_path is empty or doesn't have a parent path (e.g. because a .blend wasn't saved | * * If \a input_path is empty or doesn't have a parent path (e.g. because a .blend wasn't saved | ||||
| * yet), there is no suitable path. The caller has to decide how to handle this case. | * yet), there is no suitable path. The caller has to decide how to handle this case. | ||||
| * | * | ||||
| * \param r_library_path: The returned asset library path with a trailing slash, or an empty string | * \param r_library_path: The returned asset library path with a trailing slash, or an empty string | ||||
| * if no suitable path is found. Assumed to be a buffer of at least | * if no suitable path is found. Assumed to be a buffer of at least | ||||
| * #FILE_MAXDIR bytes. | * #FILE_MAXDIR bytes. | ||||
| * | * | ||||
| * \return True if the function could find a valid, that is, a non-empty path to return in \a | * \return True if the function could find a valid, that is, a non-empty path to return in \a | ||||
| * r_library_path. | * r_library_path. | ||||
| */ | */ | ||||
| std::string BKE_asset_library_find_suitable_root_path_from_path(blender::StringRefNull input_path); | std::string AS_asset_library_find_suitable_root_path_from_path(blender::StringRefNull input_path); | ||||
| /** | /** | ||||
| * Uses the current location on disk of the file represented by \a bmain as input to | * Uses the current location on disk of the file represented by \a bmain as input to | ||||
| * #BKE_asset_library_find_suitable_root_path_from_path(). Refer to it for a design | * #AS_asset_library_find_suitable_root_path_from_path(). Refer to it for a design | ||||
| * description. | * description. | ||||
| * | * | ||||
| * \return True if the function could find a valid, that is, a non-empty path to return in \a | * \return True if the function could find a valid, that is, a non-empty path to return in \a | ||||
| * r_library_path. If \a bmain wasn't saved into a file yet, the return value will be | * r_library_path. If \a bmain wasn't saved into a file yet, the return value will be | ||||
| * false. | * false. | ||||
| */ | */ | ||||
| std::string BKE_asset_library_find_suitable_root_path_from_main(const struct Main *bmain); | std::string AS_asset_library_find_suitable_root_path_from_main(const struct Main *bmain); | ||||
| blender::bke::AssetCatalogService *BKE_asset_library_get_catalog_service( | blender::asset_system::AssetCatalogService *AS_asset_library_get_catalog_service( | ||||
| const ::AssetLibrary *library); | |||||
| blender::asset_system::AssetCatalogTree *AS_asset_library_get_catalog_tree( | |||||
| const ::AssetLibrary *library); | const ::AssetLibrary *library); | ||||
| blender::bke::AssetCatalogTree *BKE_asset_library_get_catalog_tree(const ::AssetLibrary *library); | |||||