Blender  V3.3
Enumerations | Functions
BKE_main_idmap.h File Reference
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Enumerations

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

Functions

struct IDNameLib_MapBKE_main_idmap_create (struct Main *bmain, bool create_valid_ids_set, struct Main *old_bmain, int idmap_types) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
 
void BKE_main_idmap_destroy (struct IDNameLib_Map *id_map) ATTR_NONNULL()
 
void BKE_main_idmap_insert_id (struct IDNameLib_Map *id_map, struct ID *id) ATTR_NONNULL()
 
void BKE_main_idmap_remove_id (struct IDNameLib_Map *id_map, struct ID *id) ATTR_NONNULL()
 
struct MainBKE_main_idmap_main_get (struct IDNameLib_Map *id_map) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
 
struct IDBKE_main_idmap_lookup_name (struct IDNameLib_Map *id_map, short id_type, const char *name, const struct Library *lib) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
 
struct ID struct IDBKE_main_idmap_lookup_id (struct IDNameLib_Map *id_map, const struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
 
struct ID struct ID struct IDBKE_main_idmap_lookup_uuid (struct IDNameLib_Map *id_map, uint session_uuid) 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

Definition in file BKE_main_idmap.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAIN_IDMAP_TYPE_NAME 
MAIN_IDMAP_TYPE_UUID 

Definition at line 28 of file BKE_main_idmap.h.

Function Documentation

◆ BKE_main_idmap_create()

struct IDNameLib_Map* BKE_main_idmap_create ( struct Main bmain,
bool  create_valid_ids_set,
struct 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.c.

References BKE_idtype_idcode_iter_step(), BKE_main_gset_create(), BLI_assert, BLI_ghash_ensure_p(), BLI_ghash_int_new(), IDNameLib_Map::bmain, FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, id, IDNameLib_TypeMap::id_type, IDNameLib_Map::idmap_types, INDEX_ID_MAX, MAIN_ID_SESSION_UUID_UNSET, MAIN_IDMAP_TYPE_UUID, IDNameLib_TypeMap::map, MEM_mallocN, NULL, POINTER_FROM_UINT, ID::session_uuid, and UNUSED_VARS_NDEBUG.

Referenced by blo_lib_link_restore(), blo_make_old_idmap_from_main(), is_yet_read(), library_link_end(), and read_libraries().

◆ BKE_main_idmap_destroy()

void BKE_main_idmap_destroy ( struct IDNameLib_Map id_map)

◆ BKE_main_idmap_insert_id()

void BKE_main_idmap_insert_id ( struct IDNameLib_Map id_map,
struct ID id 
)

◆ BKE_main_idmap_lookup_id()

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

Referenced by restore_pointer_by_name().

◆ BKE_main_idmap_lookup_name()

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

Referenced by is_yet_read().

◆ BKE_main_idmap_lookup_uuid()

struct ID struct ID struct ID* BKE_main_idmap_lookup_uuid ( struct IDNameLib_Map id_map,
uint  session_uuid 
)

Definition at line 250 of file main_idmap.c.

References BLI_ghash_lookup(), MAIN_IDMAP_TYPE_UUID, NULL, and POINTER_FROM_UINT.

Referenced by read_libblock_undo_restore().

◆ BKE_main_idmap_main_get()

struct Main* BKE_main_idmap_main_get ( struct IDNameLib_Map id_map)

Definition at line 182 of file main_idmap.c.

Referenced by is_yet_read(), and restore_pointer_by_name().

◆ BKE_main_idmap_remove_id()

void BKE_main_idmap_remove_id ( struct IDNameLib_Map id_map,
struct ID id 
)