Blender
V3.3
|
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_mempool.h"
#include "BLI_utildefines.h"
#include "DNA_ID.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_main_idmap.h"
Go to the source code of this file.
Classes | |
struct | IDNameLib_Key |
struct | IDNameLib_TypeMap |
struct | IDNameLib_Map |
Functions | |
BKE_main_idmap API | |
static struct IDNameLib_TypeMap * | main_idmap_from_idcode (struct IDNameLib_Map *id_map, short id_type) |
struct IDNameLib_Map * | BKE_main_idmap_create (struct Main *bmain, const bool create_valid_ids_set, struct Main *old_bmain, const int idmap_types) |
void | BKE_main_idmap_insert_id (struct IDNameLib_Map *id_map, ID *id) |
void | BKE_main_idmap_remove_id (struct IDNameLib_Map *id_map, ID *id) |
struct Main * | BKE_main_idmap_main_get (struct IDNameLib_Map *id_map) |
static unsigned int | idkey_hash (const void *ptr) |
static bool | idkey_cmp (const void *a, const void *b) |
ID * | BKE_main_idmap_lookup_name (struct IDNameLib_Map *id_map, short id_type, const char *name, const Library *lib) |
ID * | BKE_main_idmap_lookup_id (struct IDNameLib_Map *id_map, const ID *id) |
ID * | BKE_main_idmap_lookup_uuid (struct IDNameLib_Map *id_map, const uint session_uuid) |
void | BKE_main_idmap_destroy (struct IDNameLib_Map *id_map) |
Utility functions for faster ID lookups.
Definition in file main_idmap.c.
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.
create_valid_ids_set | If true, generate a reference to prevent freed memory accesses. |
old_bmain | If 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().
void BKE_main_idmap_destroy | ( | struct IDNameLib_Map * | id_map | ) |
Definition at line 258 of file main_idmap.c.
References BLI_assert, BLI_ghash_free(), BLI_gset_free(), BLI_mempool_destroy(), INDEX_ID_MAX, MAIN_IDMAP_TYPE_NAME, MAIN_IDMAP_TYPE_UUID, IDNameLib_TypeMap::map, MEM_freeN, and NULL.
Referenced by BKE_main_free(), blo_filedata_free(), blo_join_main(), blo_lib_link_restore(), blo_make_old_idmap_from_main(), and blo_split_main().
void BKE_main_idmap_insert_id | ( | struct IDNameLib_Map * | id_map, |
ID * | id | ||
) |
Definition at line 128 of file main_idmap.c.
References BLI_assert, BLI_ghash_ensure_p(), BLI_ghash_insert(), BLI_mempool_alloc(), GS, id, IDNameLib_TypeMap::id_type, IDNameLib_Key::lib, LIKELY, MAIN_ID_SESSION_UUID_UNSET, main_idmap_from_idcode(), MAIN_IDMAP_TYPE_NAME, MAIN_IDMAP_TYPE_UUID, IDNameLib_TypeMap::map, IDNameLib_Key::name, ID::name, NULL, POINTER_FROM_UINT, ID::session_uuid, and UNUSED_VARS_NDEBUG.
Referenced by create_placeholder(), and read_libblock().
ID* BKE_main_idmap_lookup_id | ( | struct IDNameLib_Map * | id_map, |
const ID * | id | ||
) |
Definition at line 236 of file main_idmap.c.
References BKE_main_idmap_lookup_name(), BLI_gset_haskey(), GS, id, ID::lib, ID::name, and NULL.
ID* BKE_main_idmap_lookup_name | ( | struct IDNameLib_Map * | id_map, |
short | id_type, | ||
const char * | name, | ||
const Library * | lib | ||
) |
Definition at line 204 of file main_idmap.c.
References BLI_ghash_insert(), BLI_ghash_lookup(), BLI_ghash_new(), BLI_mempool_alloc(), BLI_mempool_create(), BLI_MEMPOOL_NOP, ListBase::first, id, IDNameLib_TypeMap::id_type, idkey_cmp(), idkey_hash(), IDNameLib_Key::lib, lib, main_idmap_from_idcode(), IDNameLib_TypeMap::map, map, IDNameLib_Key::name, ID::next, NULL, UNLIKELY, and which_libbase().
Referenced by BKE_main_idmap_lookup_id().
ID* BKE_main_idmap_lookup_uuid | ( | struct IDNameLib_Map * | id_map, |
const 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().
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().
void BKE_main_idmap_remove_id | ( | struct IDNameLib_Map * | id_map, |
ID * | id | ||
) |
Definition at line 158 of file main_idmap.c.
References BLI_assert, BLI_ghash_remove(), GS, id, IDNameLib_TypeMap::id_type, LIKELY, MAIN_ID_SESSION_UUID_UNSET, main_idmap_from_idcode(), MAIN_IDMAP_TYPE_NAME, MAIN_IDMAP_TYPE_UUID, IDNameLib_TypeMap::map, ID::name, NULL, POINTER_FROM_UINT, and ID::session_uuid.
Referenced by read_library_linked_ids().
Definition at line 197 of file main_idmap.c.
References Freestyle::a, usdtokens::b(), IDNameLib_Key::lib, IDNameLib_Key::name, and STREQ.
Referenced by BKE_main_idmap_lookup_name().
|
static |
Definition at line 187 of file main_idmap.c.
References BLI_ghashutil_ptrhash(), BLI_ghashutil_strhash, IDNameLib_Key::lib, IDNameLib_Key::name, and ptr.
Referenced by BKE_main_idmap_lookup_name().
|
static |
Definition at line 64 of file main_idmap.c.
References IDNameLib_TypeMap::id_type, INDEX_ID_MAX, MAIN_IDMAP_TYPE_NAME, and NULL.
Referenced by BKE_main_idmap_insert_id(), BKE_main_idmap_lookup_name(), and BKE_main_idmap_remove_id().