31AssetWeakReference::AssetWeakReference() =
default;
34 : asset_library_type(other.asset_library_type),
35 asset_library_identifier(
BLI_strdup_null(other.asset_library_identifier)),
36 relative_asset_identifier(
BLI_strdup_null(other.relative_asset_identifier))
40AssetWeakReference::AssetWeakReference(AssetWeakReference &&other)
41 : asset_library_type(other.asset_library_type),
42 asset_library_identifier(other.asset_library_identifier),
43 relative_asset_identifier(other.relative_asset_identifier)
46 other.asset_library_identifier =
nullptr;
47 other.relative_asset_identifier =
nullptr;
50AssetWeakReference::~AssetWeakReference()
52 MEM_delete(asset_library_identifier);
53 MEM_delete(relative_asset_identifier);
56AssetWeakReference &AssetWeakReference::operator=(
const AssetWeakReference &other)
61 std::destroy_at(
this);
62 new (
this) AssetWeakReference(other);
66AssetWeakReference &AssetWeakReference::operator=(AssetWeakReference &&other)
71 std::destroy_at(
this);
72 new (
this) AssetWeakReference(std::move(other));
84 const char *b_lib_idenfifier =
b.asset_library_identifier ?
b.asset_library_identifier :
"";
90 const char *b_asset_idenfifier =
b.relative_asset_identifier ?
b.relative_asset_identifier :
"";
97AssetWeakReference AssetWeakReference::make_reference(
const asset_system::AssetLibrary &library,
98 const StringRef library_relative_identifier)
100 AssetWeakReference weak_ref{};
103 !(library.library_type() == ASSET_LIBRARY_CUSTOM && library.name().is_empty()),
104 "Custom asset libraries should have a name set, otherwise weak references will not work");
106 weak_ref.asset_library_type = library.library_type();
107 StringRefNull name = library.name();
108 if (!name.is_empty()) {
109 weak_ref.asset_library_identifier =
BLI_strdupn(name.c_str(), name.size());
112 weak_ref.relative_asset_identifier =
BLI_strdupn(library_relative_identifier.data(),
113 library_relative_identifier.size());
147 MEM_delete(catalog_path.path);
154 const ListBaseT<AssetCatalogPathLink> &catalog_path_list)
156 ListBaseT<AssetCatalogPathLink> duplicated_list = {
nullptr};
165 return duplicated_list;
169 BlendWriter *writer,
const ListBaseT<AssetCatalogPathLink> &catalog_path_list)
178 BlendDataReader *reader, ListBaseT<AssetCatalogPathLink> &catalog_path_list)
187 const char *catalog_path)
194 const char *catalog_path)
202 const char *catalog_path)
204 bool changed =
false;
207 if (!
STREQ(path_link.path, catalog_path)) {
210 MEM_delete(path_link.path);
#define FOREACH_MAIN_ID_END
#define FOREACH_MAIN_ID_BEGIN(_bmain, _id)
#define BLO_read_struct_list(reader, struct_name, list)
Read Blender memory allocation and freeing.
#define BLI_assert_msg(a, msg)
bool operator==(const Error &left, const Error &right)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_asset_catalog_path_list_free(ListBaseT< AssetCatalogPathLink > &catalog_path_list)
bool BKE_asset_catalog_path_list_has_path(const ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
void BKE_asset_weak_reference_foreach_main(Main &bmain, FunctionRef< void(AssetWeakReference &weak_ref)> fn)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
const IDTypeInfo * BKE_idtype_get_info_from_id(const ID *id)
void * BLI_findstring_ptr(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_asset_catalog_path_list_blend_read_data(BlendDataReader *reader, ListBaseT< AssetCatalogPathLink > &catalog_path_list)
int BLI_path_cmp_normalized(const char *p1, const char *p2) ATTR_NONNULL(1
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BKE_asset_weak_reference_write(BlendWriter *writer, const AssetWeakReference *weak_ref)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
bool BKE_asset_catalog_path_list_remove_path(ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
void BKE_asset_weak_reference_read(BlendDataReader *reader, AssetWeakReference *weak_ref)
void BKE_asset_catalog_path_list_blend_write(BlendWriter *writer, const ListBaseT< AssetCatalogPathLink > &catalog_path_list)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
void BKE_asset_catalog_path_list_add_path(ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
ListBaseT< AssetCatalogPathLink > BKE_asset_catalog_path_list_duplicate(const ListBaseT< AssetCatalogPathLink > &catalog_path_list)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
const char * asset_library_identifier
const char * relative_asset_identifier
eAssetLibraryType asset_library_type
void write_string(const char *data)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
IDTypeForeachAssetWeakReferenceFunction foreach_asset_weak_reference