Blender V5.3
BKE_blendfile_link_append.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
9
10#include <list>
11#include <string>
12
13#include "BLI_bit_vector.hh"
14#include "BLI_function_ref.hh"
15#include "BLI_map.hh"
16
17#include "BLO_readfile.hh"
18
19struct BlendHandle;
20
21namespace blender {
22
23struct Collection;
24struct ID;
25struct Library;
27struct Main;
29struct ReportList;
30struct Scene;
31struct ViewLayer;
32
33/* TODO: Rename file to `BKE_blendfile_import.hh`. */
34/* TODO: Replace `BlendfileLinkAppend` prefix by `bke::blendfile::import` namespace. */
35/* TODO: Move these enums to scoped enum classes. */
36
38enum {
44};
45
47enum {
65};
66
67/* NOTE: These three structs are currently exposed in header to allow for their usage in RNA.
68 * Regular C++ code should not access their content directly.
69 *
70 * TODO: Refactor these three structs into classes, and integrated the whole API into them. */
71struct BlendfileLinkAppendContext;
72
117
129
141 std::list<BlendfileLinkAppendContextItem> items;
142 using items_iterator_t = std::list<BlendfileLinkAppendContextItem>::iterator;
145
151
156 enum class ProcessStage {
161 Init = 0,
163 Linking,
168 Appending,
173 Instantiating,
178 Done,
179
180 /* NOTE: For the time being, liboverride step is not considered here (#BKE_blendfile_override).
181 * Mainly because it is only available through the BPY API currently. */
182 };
184
187
190
192 const void *blendfile_mem = nullptr;
194};
195
213 int flag,
214 bool do_set);
215
223 BlendfileLinkAppendContext *lapp_context, const void *blendfile_mem, int blendfile_memsize);
226 BlendfileLinkAppendContext *lapp_context);
227
241 const char *libname,
242 BlendHandle *blo_handle);
254 BlendfileLinkAppendContext *lapp_context, const char *idname, short idcode, void *userdata);
255
256#define BLENDFILE_LINK_APPEND_INVALID -1
272 BlendfileLinkAppendContext *lapp_context,
273 ReportList *reports,
274 uint64_t id_types_filter,
275 int library_index);
276
282 BlendfileLinkAppendContext *lapp_context,
283 BlendfileLinkAppendContextItem *item,
284 int library_index);
288bool BKE_blendfile_link_append_context_is_empty(BlendfileLinkAppendContext *lapp_context);
289
290void *BKE_blendfile_link_append_context_item_userdata_get(BlendfileLinkAppendContext *lapp_context,
291 BlendfileLinkAppendContextItem *item);
292ID *BKE_blendfile_link_append_context_item_newid_get(BlendfileLinkAppendContext *lapp_context,
293 BlendfileLinkAppendContextItem *item);
298void BKE_blendfile_link_append_context_item_newid_set(BlendfileLinkAppendContext *lapp_context,
299 BlendfileLinkAppendContextItem *item,
300 ID *new_id);
302 BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item);
303short BKE_blendfile_link_append_context_item_idcode_get(BlendfileLinkAppendContext *lapp_context,
304 BlendfileLinkAppendContextItem *item);
305
318
327 BlendfileLinkAppendContext *lapp_context,
333 FunctionRef<bool(BlendfileLinkAppendContext *lapp_context,
334 BlendfileLinkAppendContextItem *item)> callback_function,
336
342void BKE_blendfile_link_append_context_init_done(BlendfileLinkAppendContext *lapp_context);
343
347void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports);
348
355void BKE_blendfile_link_pack(BlendfileLinkAppendContext *lapp_context, ReportList *reports);
356
364void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *reports);
365
369void BKE_blendfile_link_append_instantiate_loose(BlendfileLinkAppendContext *lapp_context,
370 ReportList *reports);
371
385 Scene *scene,
386 ViewLayer *view_layer,
387 Collection *target_collection,
388 ReportList *reports);
389
395void BKE_blendfile_link_append_context_finalize(BlendfileLinkAppendContext *lapp_context);
396
419
432void BKE_blendfile_override(BlendfileLinkAppendContext *lapp_context,
433 const eBKELibLinkOverride flags,
434 ReportList *reports);
435
458void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context,
459 ReportList *reports,
460 Library *library,
461 bool do_reload);
462
469void BKE_blendfile_id_relocate(BlendfileLinkAppendContext &lapp_context, ReportList *reports);
470
471} // namespace blender
external readfile function prototypes.
unsigned long long int uint64_t
Definition scene.h:133
BMesh Iterators.
void BKE_blendfile_link_append_instantiate_loose(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
BlendfileLinkAppendContext * BKE_blendfile_link_append_context_new(LibraryLink_Params *params)
void BKE_blendfile_link_append_context_free(BlendfileLinkAppendContext *lapp_context)
BlendfileLinkAppendContextItem * BKE_blendfile_link_append_context_item_add(BlendfileLinkAppendContext *lapp_context, const char *idname, short idcode, void *userdata)
void BKE_blendfile_link_append_context_item_library_index_enable(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item, int library_index)
void BKE_blendfile_id_relocate(BlendfileLinkAppendContext &lapp_context, ReportList *reports)
void BKE_blendfile_link_append_context_embedded_blendfile_clear(BlendfileLinkAppendContext *lapp_context)
ID * BKE_blendfile_link_append_context_item_newid_get(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)
ID * BKE_blendfile_link_append_context_item_liboverrideid_get(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)
short BKE_blendfile_link_append_context_item_idcode_get(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)
void * BKE_blendfile_link_append_context_item_userdata_get(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)
void BKE_blendfile_link_append_context_item_newid_set(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item, ID *new_id)
void BKE_blendfile_link_append_instantiate_loose_from_bmain(Main *bmain, Scene *scene, ViewLayer *view_layer, Collection *target_collection, ReportList *reports)
void BKE_blendfile_link_append_context_embedded_blendfile_set(BlendfileLinkAppendContext *lapp_context, const void *blendfile_mem, int blendfile_memsize)
bool BKE_blendfile_link_append_context_is_empty(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_link_append_context_finalize(BlendfileLinkAppendContext *lapp_context)
@ BKE_LIBLINK_OVERRIDE_USE_EXISTING_LIBOVERRIDES
void BKE_blendfile_link_append_context_flag_set(BlendfileLinkAppendContext *lapp_context, int flag, bool do_set)
void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
void BKE_blendfile_link_pack(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, ReportList *reports, Library *library, bool do_reload)
void BKE_blendfile_link_append_context_library_add(BlendfileLinkAppendContext *lapp_context, const char *libname, BlendHandle *blo_handle)
@ LINK_APPEND_TAG_LIBOVERRIDE_DEPENDENCY_ONLY
@ BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_INDIRECT
@ BKE_BLENDFILE_LINK_APPEND_FOREACH_ITEM_FLAG_DO_DIRECT
void BKE_blendfile_link(BlendfileLinkAppendContext *lapp_context, ReportList *reports)
void BKE_blendfile_link_append_context_item_foreach(BlendfileLinkAppendContext *lapp_context, FunctionRef< bool(BlendfileLinkAppendContext *lapp_context, BlendfileLinkAppendContextItem *item)> callback_function, eBlendfileLinkAppendForeachItemFlag flag)
int BKE_blendfile_link_append_context_item_idtypes_from_library_add(BlendfileLinkAppendContext *lapp_context, ReportList *reports, uint64_t id_types_filter, int library_index)
void BKE_blendfile_link_append_context_init_done(BlendfileLinkAppendContext *lapp_context)
void BKE_blendfile_override(BlendfileLinkAppendContext *lapp_context, const eBKELibLinkOverride flags, ReportList *reports)
Vector< BlendfileLinkAppendContextLibrary > libraries
Map< ID *, BlendfileLinkAppendContextItem * > new_id_to_item
std::list< BlendfileLinkAppendContextItem > items
std::list< BlendfileLinkAppendContextItem >::iterator items_iterator_t
MainLibraryWeakReferenceMap * library_weak_reference_mapping