Blender V4.3
blender::asset_system::AssetCatalogDefinitionFile Class Reference

#include <asset_catalog_definition_file.hh>

Inherited by blender::asset_system::tests::TestableAssetCatalogDefinitionFile.

Public Types

using AssetCatalogParsedFn = FunctionRef<bool(std::unique_ptr<AssetCatalog>)>
 

Public Member Functions

 AssetCatalogDefinitionFile (const CatalogFilePath &file_path)
 
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 catalog_loaded_callback)
 
std::unique_ptr< AssetCatalogDefinitionFilecopy_and_remap (const OwningAssetCatalogMap &catalogs, const OwningAssetCatalogMap &deleted_catalogs) const
 

Public Attributes

const 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 24 of file asset_catalog_definition_file.hh.

Member Typedef Documentation

◆ AssetCatalogParsedFn

Constructor & Destructor Documentation

◆ AssetCatalogDefinitionFile()

blender::asset_system::AssetCatalogDefinitionFile::AssetCatalogDefinitionFile ( const CatalogFilePath & file_path)

Definition at line 154 of file asset_catalog_definition_file.cc.

Member Function Documentation

◆ add_new()

void blender::asset_system::AssetCatalogDefinitionFile::add_new ( AssetCatalog * catalog)

Add a new catalog. Undefined behavior if a catalog with the same ID was already added.

Definition at line 37 of file asset_catalog_definition_file.cc.

References blender::asset_system::AssetCatalog::catalog_id, and catalogs_.

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

◆ add_overwrite()

void blender::asset_system::AssetCatalogDefinitionFile::add_overwrite ( AssetCatalog * catalog)

Add a catalog, overwriting the one with the same catalog ID.

Definition at line 42 of file asset_catalog_definition_file.cc.

References blender::asset_system::AssetCatalog::catalog_id, and catalogs_.

Referenced by parse_catalog_file().

◆ contains()

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

◆ copy_and_remap()

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

◆ ensure_directory_exists()

bool blender::asset_system::AssetCatalogDefinitionFile::ensure_directory_exists ( const CatalogFilePath & directory_path) const
protected

◆ forget()

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

Remove the catalog from the collection of catalogs stored in this file.

Definition at line 47 of file asset_catalog_definition_file.cc.

References catalogs_.

◆ parse_catalog_file()

void blender::asset_system::AssetCatalogDefinitionFile::parse_catalog_file ( const CatalogFilePath & catalog_definition_file_path,
AssetCatalogParsedFn catalog_loaded_callback )

◆ parse_catalog_line()

◆ parse_version_line()

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

Definition at line 98 of file asset_catalog_definition_file.cc.

References SUPPORTED_VERSION, and VERSION_MARKER.

Referenced by parse_catalog_file().

◆ write_to_disk() [1/2]

bool blender::asset_system::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 159 of file asset_catalog_definition_file.cc.

References BLI_assert_msg, file_path, and write_to_disk().

Referenced by blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), and write_to_disk().

◆ write_to_disk() [2/2]

bool blender::asset_system::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 165 of file asset_catalog_definition_file.cc.

References BLI_exists(), BLI_rename_overwrite(), and write_to_disk_unsafe().

◆ write_to_disk_unsafe()

bool blender::asset_system::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 188 of file asset_catalog_definition_file.cc.

References BLI_path_split_dir_part(), catalogs_, ensure_directory_exists(), HEADER, output, PATH_MAX, SUPPORTED_VERSION, and VERSION_MARKER.

Referenced by write_to_disk().

Member Data Documentation

◆ catalogs_

◆ file_path

◆ HEADER

const std::string blender::asset_system::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 38 of file asset_catalog_definition_file.hh.

Referenced by write_to_disk_unsafe().

◆ SUPPORTED_VERSION

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

Definition at line 33 of file asset_catalog_definition_file.hh.

Referenced by parse_version_line(), and write_to_disk_unsafe().

◆ VERSION_MARKER

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

Definition at line 37 of file asset_catalog_definition_file.hh.

Referenced by parse_version_line(), and write_to_disk_unsafe().


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