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

#include <BKE_asset_catalog.hh>

Inheritance diagram for blender::bke::AssetCatalogDefinitionFile:
blender::bke::tests::TestableAssetCatalogDefinitionFile

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< AssetCatalogDefinitionFilecopy_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< AssetCatalogparse_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_
 

Detailed Description

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 #AssetCatalogs themselves.

Definition at line 361 of file BKE_asset_catalog.hh.

Member Typedef Documentation

◆ AssetCatalogParsedFn

Definition at line 399 of file BKE_asset_catalog.hh.

Constructor & Destructor Documentation

◆ AssetCatalogDefinitionFile()

blender::bke::AssetCatalogDefinitionFile::AssetCatalogDefinitionFile ( )
default

Member Function Documentation

◆ add_new()

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

◆ add_overwrite()

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

◆ contains()

bool blender::bke::AssetCatalogDefinitionFile::contains ( CatalogID  catalog_id) const

Definition at line 796 of file blenkernel/intern/asset_catalog.cc.

References catalogs_.

Referenced by blender::bke::tests::TEST_F().

◆ copy_and_remap()

std::unique_ptr< AssetCatalogDefinitionFile > blender::bke::AssetCatalogDefinitionFile::copy_and_remap ( const OwningAssetCatalogMap catalogs,
const OwningAssetCatalogMap deleted_catalogs 
) const

◆ ensure_directory_exists()

bool blender::bke::AssetCatalogDefinitionFile::ensure_directory_exists ( const CatalogFilePath  directory_path) const
protected

◆ forget()

void blender::bke::AssetCatalogDefinitionFile::forget ( CatalogID  catalog_id)

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_.

◆ parse_catalog_file()

void blender::bke::AssetCatalogDefinitionFile::parse_catalog_file ( const CatalogFilePath catalog_definition_file_path,
AssetCatalogParsedFn  callback 
)

◆ parse_catalog_line()

std::unique_ptr< AssetCatalog > blender::bke::AssetCatalogDefinitionFile::parse_catalog_line ( StringRef  line)
protected

◆ parse_version_line()

bool blender::bke::AssetCatalogDefinitionFile::parse_version_line ( StringRef  line)
protected

◆ write_to_disk() [1/2]

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

◆ write_to_disk() [2/2]

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

◆ write_to_disk_unsafe()

bool blender::bke::AssetCatalogDefinitionFile::write_to_disk_unsafe ( const CatalogFilePath dest_file_path) const
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().

Member Data Documentation

◆ catalogs_

Map<CatalogID, AssetCatalog *> blender::bke::AssetCatalogDefinitionFile::catalogs_
protected

◆ file_path

CatalogFilePath blender::bke::AssetCatalogDefinitionFile::file_path

◆ HEADER

const std::string blender::bke::AssetCatalogDefinitionFile::HEADER
static
Initial value:
=
"# This is an Asset Catalog Definition file for Blender.\n"
"#\n"
"# Empty lines and lines starting with `#` will be ignored.\n"
"# The first non-ignored line should be the version indicator.\n"
"# Other lines are of the format \"UUID:catalog/path/for/assets:simple catalog name\"\n"

Definition at line 370 of file BKE_asset_catalog.hh.

Referenced by write_to_disk_unsafe().

◆ SUPPORTED_VERSION

const int blender::bke::AssetCatalogDefinitionFile::SUPPORTED_VERSION = 1
static

Definition at line 365 of file BKE_asset_catalog.hh.

Referenced by parse_version_line(), and write_to_disk_unsafe().

◆ VERSION_MARKER

const std::string blender::bke::AssetCatalogDefinitionFile::VERSION_MARKER = "VERSION "
static

Definition at line 369 of file BKE_asset_catalog.hh.

Referenced by parse_version_line(), and write_to_disk_unsafe().


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