Blender
V3.3
|
#include <BKE_asset_catalog.hh>
Public Types | |
using | AssetCatalogParsedFn = FunctionRef< bool(std::unique_ptr< AssetCatalog >)> |
Public Member Functions | |
AssetCatalogDefinitionFile ()=default | |
bool | write_to_disk () const |
bool | write_to_disk (const CatalogFilePath &dest_file_path) const |
bool | contains (CatalogID catalog_id) const |
void | add_overwrite (AssetCatalog *catalog) |
void | add_new (AssetCatalog *catalog) |
void | forget (CatalogID catalog_id) |
void | parse_catalog_file (const CatalogFilePath &catalog_definition_file_path, AssetCatalogParsedFn callback) |
std::unique_ptr< AssetCatalogDefinitionFile > | copy_and_remap (const OwningAssetCatalogMap &catalogs, const OwningAssetCatalogMap &deleted_catalogs) const |
Public Attributes | |
CatalogFilePath | file_path |
Static Public Attributes | |
static const int | SUPPORTED_VERSION = 1 |
static const std::string | VERSION_MARKER = "VERSION " |
static const std::string | HEADER |
Protected Member Functions | |
bool | parse_version_line (StringRef line) |
std::unique_ptr< AssetCatalog > | parse_catalog_line (StringRef line) |
bool | write_to_disk_unsafe (const CatalogFilePath &dest_file_path) const |
bool | ensure_directory_exists (const CatalogFilePath directory_path) const |
Protected Attributes | |
Map< CatalogID, AssetCatalog * > | catalogs_ |
Keeps track of which catalogs are defined in a certain file on disk. Only contains non-owning pointers to the #AssetCatalog instances, so ensure the lifetime of this class is shorter than that of the #AssetCatalog
s themselves.
Definition at line 361 of file BKE_asset_catalog.hh.
using blender::bke::AssetCatalogDefinitionFile::AssetCatalogParsedFn = FunctionRef<bool(std::unique_ptr<AssetCatalog>)> |
Definition at line 399 of file BKE_asset_catalog.hh.
|
default |
void blender::bke::AssetCatalogDefinitionFile::add_new | ( | AssetCatalog * | catalog | ) |
Add a new catalog. Undefined behavior if a catalog with the same ID was already added.
Definition at line 801 of file blenkernel/intern/asset_catalog.cc.
References blender::bke::AssetCatalog::catalog_id, and catalogs_.
Referenced by blender::bke::tests::TEST_F().
void blender::bke::AssetCatalogDefinitionFile::add_overwrite | ( | AssetCatalog * | catalog | ) |
Add a catalog, overwriting the one with the same catalog ID.
Definition at line 806 of file blenkernel/intern/asset_catalog.cc.
References blender::bke::AssetCatalog::catalog_id, and catalogs_.
Referenced by parse_catalog_file().
Definition at line 796 of file blenkernel/intern/asset_catalog.cc.
References catalogs_.
Referenced by blender::bke::tests::TEST_F().
std::unique_ptr< AssetCatalogDefinitionFile > blender::bke::AssetCatalogDefinitionFile::copy_and_remap | ( | const OwningAssetCatalogMap & | catalogs, |
const OwningAssetCatalogMap & | deleted_catalogs | ||
) | const |
Definition at line 1020 of file blenkernel/intern/asset_catalog.cc.
References BLI_assert, catalogs_, copy(), and blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_ptr().
|
protected |
Definition at line 984 of file blenkernel/intern/asset_catalog.cc.
References BLI_dir_create_recursive(), BLI_exists(), and BLI_is_dir().
Referenced by write_to_disk_unsafe().
Remove the catalog from the collection of catalogs stored in this file.
Definition at line 811 of file blenkernel/intern/asset_catalog.cc.
References catalogs_.
void blender::bke::AssetCatalogDefinitionFile::parse_catalog_file | ( | const CatalogFilePath & | catalog_definition_file_path, |
AssetCatalogParsedFn | callback | ||
) |
Definition at line 816 of file blenkernel/intern/asset_catalog.cc.
References add_overwrite(), CLOG_ERROR, blender::StringRefBase::is_empty(), LOG, parse_catalog_line(), parse_version_line(), and blender::StringRefBase::trim().
Referenced by blender::bke::AssetCatalogService::reload_catalogs().
|
protected |
Definition at line 875 of file blenkernel/intern/asset_catalog.cc.
References BLI_uuid_parse_string(), blender::bke::AssetCatalogPath::cleanup(), file_path, blender::StringRefBase::find_first_of(), blender::StringRefBase::not_found, blender::StringRefBase::substr(), and blender::StringRefBase::trim().
Referenced by parse_catalog_file().
Definition at line 862 of file blenkernel/intern/asset_catalog.cc.
References blender::StringRefBase::startswith(), blender::StringRefBase::substr(), SUPPORTED_VERSION, and VERSION_MARKER.
Referenced by parse_catalog_file().
bool blender::bke::AssetCatalogDefinitionFile::write_to_disk | ( | ) | const |
Write the catalog definitions to the same file they were read from. Return true when the file was written correctly, false when there was a problem.
Definition at line 918 of file blenkernel/intern/asset_catalog.cc.
References BLI_assert_msg, and file_path.
Referenced by blender::bke::tests::TEST_F().
bool blender::bke::AssetCatalogDefinitionFile::write_to_disk | ( | const CatalogFilePath & | dest_file_path | ) | const |
Write the catalog definitions to an arbitrary file path.
Any existing file is backed up to "filename~". Any previously existing backup is overwritten.
Return true when the file was written correctly, false when there was a problem.
Definition at line 924 of file blenkernel/intern/asset_catalog.cc.
References BLI_exists(), BLI_rename(), and write_to_disk_unsafe().
|
protected |
Write the catalog definitions to the given file path. Return true when the file was written correctly, false when there was a problem.
Definition at line 947 of file blenkernel/intern/asset_catalog.cc.
References BLI_split_dir_part(), catalogs_, ensure_directory_exists(), HEADER, usdtokens::out(), output, PATH_MAX, SUPPORTED_VERSION, and VERSION_MARKER.
Referenced by write_to_disk().
|
protected |
Definition at line 409 of file BKE_asset_catalog.hh.
Referenced by add_new(), add_overwrite(), contains(), copy_and_remap(), forget(), blender::bke::tests::TestableAssetCatalogDefinitionFile::get_catalogs(), and write_to_disk_unsafe().
CatalogFilePath blender::bke::AssetCatalogDefinitionFile::file_path |
Definition at line 372 of file BKE_asset_catalog.hh.
Referenced by parse_catalog_line(), blender::bke::AssetCatalogService::reload_catalogs(), blender::bke::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), blender::bke::tests::TEST_F(), and write_to_disk().
|
static |
Definition at line 370 of file BKE_asset_catalog.hh.
Referenced by write_to_disk_unsafe().
|
static |
Definition at line 365 of file BKE_asset_catalog.hh.
Referenced by parse_version_line(), and write_to_disk_unsafe().
|
static |
Definition at line 369 of file BKE_asset_catalog.hh.
Referenced by parse_version_line(), and write_to_disk_unsafe().