Blender V4.3
BKE_main_idmap.hh File Reference

Go to the source code of this file.

Enumerations

enum  { MAIN_IDMAP_TYPE_NAME = 1 << 0 , MAIN_IDMAP_TYPE_UID = 1 << 1 }
 

Functions

IDNameLib_MapBKE_main_idmap_create (Main *bmain, bool create_valid_ids_set, Main *old_bmain, int idmap_types) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
 
void BKE_main_idmap_clear (IDNameLib_Map &id_map)
 
void BKE_main_idmap_destroy (IDNameLib_Map *id_map) ATTR_NONNULL()
 
void BKE_main_idmap_insert_id (IDNameLib_Map *id_map, ID *id) ATTR_NONNULL()
 
void BKE_main_idmap_remove_id (IDNameLib_Map *id_map, const ID *id) ATTR_NONNULL()
 
MainBKE_main_idmap_main_get (IDNameLib_Map *id_map) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
IDBKE_main_idmap_lookup_name (IDNameLib_Map *id_map, short id_type, const char *name, const Library *lib) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
 
ID IDBKE_main_idmap_lookup_id (IDNameLib_Map *id_map, const ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
 
ID ID IDBKE_main_idmap_lookup_uid (IDNameLib_Map *id_map, uint session_uid) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
 

Detailed Description

API to generate and use a mapping from [ID type & name] to [id pointer], within a given Main data-base.

Note
BKE_main files are for operations over the Main database itself, or generating extra temp data to help working with it. Those should typically not affect the data-blocks themselves.

Names

  • BKE_main_idmap_ Should be used for functions in that file.

Definition in file BKE_main_idmap.hh.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAIN_IDMAP_TYPE_NAME 
MAIN_IDMAP_TYPE_UID 

Definition at line 26 of file BKE_main_idmap.hh.

Function Documentation

◆ BKE_main_idmap_clear()

void BKE_main_idmap_clear ( IDNameLib_Map & id_map)

◆ BKE_main_idmap_create()

IDNameLib_Map * BKE_main_idmap_create ( Main * bmain,
bool create_valid_ids_set,
Main * old_bmain,
int idmap_types )

Generate mapping from ID type/name to ID pointer for given bmain.

Note
When used during undo/redo, there is no guaranty that ID pointers from UI area are not pointing to freed memory (when some IDs have been deleted). To avoid crashes in those cases, one can provide the 'old' (aka current) Main database as reference. BKE_main_idmap_lookup_id will then check that given ID does exist in old_bmain before trying to use it.
Parameters
create_valid_ids_setIf true, generate a reference to prevent freed memory accesses.
old_bmainIf not NULL, its IDs will be added the valid references set.

Definition at line 77 of file main_idmap.cc.

References BKE_idtype_idcode_iter_step(), BKE_main_gset_create(), BLI_assert, BLI_ghash_ensure_p(), BLI_ghash_int_new(), FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, IDNameLib_TypeMap::id_type, INDEX_ID_MAX, MAIN_ID_SESSION_UID_UNSET, MAIN_IDMAP_TYPE_UID, IDNameLib_TypeMap::map, MEM_mallocN, POINTER_FROM_UINT, and UNUSED_VARS_NDEBUG.

Referenced by blo_make_old_idmap_from_main(), blo_read_file_internal(), library_id_is_yet_read(), library_link_end(), blender::bke::blendfile::PartialWriteContext::PartialWriteContext(), blender::ed::space_node::NodeClipboard::paste_validate_id_references(), read_libraries(), and setup_app_data().

◆ BKE_main_idmap_destroy()

◆ BKE_main_idmap_insert_id()

◆ BKE_main_idmap_lookup_id()

ID ID * BKE_main_idmap_lookup_id ( IDNameLib_Map * id_map,
const ID * id )

◆ BKE_main_idmap_lookup_name()

ID * BKE_main_idmap_lookup_name ( IDNameLib_Map * id_map,
short id_type,
const char * name,
const Library * lib )

◆ BKE_main_idmap_lookup_uid()

◆ BKE_main_idmap_main_get()

Main * BKE_main_idmap_main_get ( IDNameLib_Map * id_map)

Definition at line 184 of file main_idmap.cc.

Referenced by library_id_is_yet_read().

◆ BKE_main_idmap_remove_id()