Blender V4.3
idtype.cc File Reference
#include <array>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
#include "BLI_utildefines.h"
#include "CLG_log.h"
#include "BLT_translation.hh"
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "BKE_main.hh"
#include "BKE_node.hh"
#include "BKE_idtype.hh"

Go to the source code of this file.

Macros

#define INIT_TYPE(_id_code)
 
#define CASE_IDINDEX(_id)
 
#define CASE_IDINDEX(_id)
 

Functions

uint BKE_idtype_cache_key_hash (const void *key_v)
 
bool BKE_idtype_cache_key_cmp (const void *key_a_v, const void *key_b_v)
 
static void id_type_init ()
 
void BKE_idtype_init ()
 
const IDTypeInfoBKE_idtype_get_info_from_idtype_index (const int idtype_index)
 
const IDTypeInfoBKE_idtype_get_info_from_idcode (const short id_code)
 
const IDTypeInfoBKE_idtype_get_info_from_id (const ID *id)
 
static const IDTypeInfoidtype_get_info_from_name (const char *idtype_name)
 
const char * BKE_idtype_idcode_to_name (const short idcode)
 
const char * BKE_idtype_idcode_to_name_plural (const short idcode)
 
const char * BKE_idtype_idcode_to_translation_context (const short idcode)
 
short BKE_idtype_idcode_from_name (const char *idtype_name)
 
bool BKE_idtype_idcode_is_valid (const short idcode)
 
bool BKE_idtype_idcode_is_linkable (const short idcode)
 
bool BKE_idtype_idcode_is_only_appendable (const short idcode)
 
bool BKE_idtype_idcode_append_is_reusable (const short idcode)
 
int BKE_idtype_idcode_to_index (const short idcode)
 
int BKE_idtype_idfilter_to_index (const uint64_t id_filter)
 
short BKE_idtype_index_to_idcode (const int idtype_index)
 
uint64_t BKE_idtype_index_to_idfilter (const int idtype_index)
 
uint64_t BKE_idtype_idcode_to_idfilter (const short idcode)
 
short BKE_idtype_idfilter_to_idcode (const uint64_t idfilter)
 
short BKE_idtype_idcode_iter_step (int *idtype_index)
 
void BKE_idtype_id_foreach_cache (ID *id, IDTypeForeachCacheFunctionCallback function_callback, void *user_data)
 

Variables

static std::array< IDTypeInfo *, INDEX_ID_MAXid_types
 

Macro Definition Documentation

◆ CASE_IDINDEX [1/2]

#define CASE_IDINDEX ( _id)
Value:
case ID_##_id: \
return INDEX_ID_##_id

Referenced by BKE_idtype_idcode_to_index(), and BKE_idtype_idfilter_to_index().

◆ CASE_IDINDEX [2/2]

#define CASE_IDINDEX ( _id)
Value:
case FILTER_ID_##_id: \
return INDEX_ID_##_id

◆ INIT_TYPE

#define INIT_TYPE ( _id_code)
Value:
{ \
BLI_assert(IDType_##_id_code.main_listbase_index == INDEX_##_id_code); \
id_types[INDEX_##_id_code] = &IDType_##_id_code; \
init_types_num++; \
} \
(void)0
static std::array< IDTypeInfo *, INDEX_ID_MAX > id_types
Definition idtype.cc:49

Referenced by id_type_init().

Function Documentation

◆ BKE_idtype_cache_key_cmp()

bool BKE_idtype_cache_key_cmp ( const void * key_a_v,
const void * key_b_v )

Definition at line 41 of file idtype.cc.

References IDCacheKey::id_session_uid, and IDCacheKey::identifier.

Referenced by blo_cache_storage_init().

◆ BKE_idtype_cache_key_hash()

uint BKE_idtype_cache_key_hash ( const void * key_v)

◆ BKE_idtype_get_info_from_id()

◆ BKE_idtype_get_info_from_idcode()

◆ BKE_idtype_get_info_from_idtype_index()

const IDTypeInfo * BKE_idtype_get_info_from_idtype_index ( const int idtype_index)

◆ BKE_idtype_id_foreach_cache()

void BKE_idtype_id_foreach_cache ( ID * id,
IDTypeForeachCacheFunctionCallback function_callback,
void * user_data )

◆ BKE_idtype_idcode_append_is_reusable()

bool BKE_idtype_idcode_append_is_reusable ( short idcode)

Check if an ID type can try to reuse and existing matching local one when being appended again.

Parameters
idcodeThe IDType code to check.
Returns
Boolean, false when it cannot be re-used, true otherwise.

Definition at line 220 of file idtype.cc.

References BKE_idtype_get_info_from_idcode(), BLI_assert, IDTypeInfo::flags, IDTYPE_FLAGS_APPEND_IS_REUSABLE, and IDTYPE_FLAGS_NO_LIBLINKING.

Referenced by BKE_blendfile_append(), BKE_main_library_weak_reference_add_item(), BKE_main_library_weak_reference_create(), and blendfile_append_define_actions().

◆ BKE_idtype_idcode_from_name()

short BKE_idtype_idcode_from_name ( const char * idtype_name)

Convert an ID-type name into an idcode (ie. ID_SCE)

Parameters
idtype_nameThe ID-type's "user visible name" to convert.
Returns
The idcode for the name, or 0 if invalid.

Definition at line 189 of file idtype.cc.

References BLI_assert, IDTypeInfo::id_code, and idtype_get_info_from_name().

Referenced by groupname_to_code(), imb_thumb_load_from_blend_id(), wm_link_append_exec(), and wm_link_append_item_poll().

◆ BKE_idtype_idcode_is_linkable()

◆ BKE_idtype_idcode_is_only_appendable()

bool BKE_idtype_idcode_is_only_appendable ( short idcode)

Check if an ID type is only appendable.

Parameters
idcodeThe IDType code to check.
Returns
Boolean, false when also linkable, true when only appendable.

Definition at line 208 of file idtype.cc.

References BKE_idtype_get_info_from_idcode(), BLI_assert, IDTypeInfo::flags, IDTYPE_FLAGS_NO_LIBLINKING, and IDTYPE_FLAGS_ONLY_APPEND.

Referenced by wm_link_append_item_poll().

◆ BKE_idtype_idcode_is_valid()

bool BKE_idtype_idcode_is_valid ( short idcode)

Return if the ID code is a valid ID code.

Parameters
idcodeThe code to check.
Returns
Boolean, 0 when invalid.

Definition at line 196 of file idtype.cc.

References BKE_idtype_get_info_from_idcode(), and true.

Referenced by blo_bhead_is_id_valid_type(), BLO_blendhandle_get_linkable_groups(), and link_named_part().

◆ BKE_idtype_idcode_iter_step()

short BKE_idtype_idcode_iter_step ( int * idtype_index)

Return an ID code and steps the index forward 1.

Parameters
indexstart as 0.
Returns
the code, 0 when all codes have been returned.

Definition at line 379 of file idtype.cc.

References BKE_idtype_index_to_idcode(), and id_types.

Referenced by BKE_blendfile_link_append_context_item_idtypes_from_library_add(), BKE_main_idmap_create(), bpy_lib_enter(), bpy_lib_exit(), and main_namemap_validate_and_fix().

◆ BKE_idtype_idcode_to_idfilter()

◆ BKE_idtype_idcode_to_index()

◆ BKE_idtype_idcode_to_name()

◆ BKE_idtype_idcode_to_name_plural()

const char * BKE_idtype_idcode_to_name_plural ( short idcode)

◆ BKE_idtype_idcode_to_translation_context()

const char * BKE_idtype_idcode_to_translation_context ( short idcode)

Convert an idcode into its translations' context.

Parameters
idcodeThe code to convert.
Returns
A static string representing the i18n context of the code.

Definition at line 182 of file idtype.cc.

References BKE_idtype_get_info_from_idcode(), BLI_assert, BLT_I18NCONTEXT_DEFAULT, and IDTypeInfo::translation_context.

◆ BKE_idtype_idfilter_to_idcode()

short BKE_idtype_idfilter_to_idcode ( uint64_t idfilter)

Convert an idfilter into an idcode (e.g. FILTER_ID_OB -> ID_OB).

Definition at line 374 of file idtype.cc.

References BKE_idtype_idfilter_to_index(), and BKE_idtype_index_to_idcode().

◆ BKE_idtype_idfilter_to_index()

int BKE_idtype_idfilter_to_index ( uint64_t id_filter)

Convert an id_filter into an idtype_index (e.g. FILTER_ID_OB -> INDEX_ID_OB).

Definition at line 291 of file idtype.cc.

References BR, CASE_IDINDEX, CV, and LT.

Referenced by BKE_idtype_idfilter_to_idcode().

◆ BKE_idtype_index_to_idcode()

short BKE_idtype_index_to_idcode ( int idtype_index)

◆ BKE_idtype_index_to_idfilter()

uint64_t BKE_idtype_index_to_idfilter ( int idtype_index)

Convert an idtype_index into an idfilter (e.g. INDEX_ID_OB -> FILTER_ID_OB).

Definition at line 358 of file idtype.cc.

References BKE_idtype_get_info_from_idtype_index(), BLI_assert_unreachable, and IDTypeInfo::id_filter.

Referenced by BKE_idtype_idcode_to_idfilter().

◆ BKE_idtype_init()

void BKE_idtype_init ( )

Definition at line 127 of file idtype.cc.

References id_type_init().

Referenced by blender::bke::tests::Context< TestData >::Context(), blender::bke::greasepencil::tests::GreasePencilIDTestContext::GreasePencilIDTestContext(), blender::ed::greasepencil::tests::GreasePencilIDTestContext::GreasePencilIDTestContext(), blender::bke::tests::LibIDMainSortTestContext::LibIDMainSortTestContext(), main(), blender::bke::image::partial_update::ImagePartialUpdateTest::SetUp(), BlendfileLoadingBaseTest::SetUpTestCase(), blender::animrig::nla::tests::NLASlottedActionTest::SetUpTestSuite(), blender::animrig::tests::ActionFCurveMoveTest::SetUpTestSuite(), blender::animrig::tests::ActionFilterTest::SetUpTestSuite(), blender::animrig::tests::ActionIteratorsTest::SetUpTestSuite(), blender::animrig::tests::ActionLayersTest::SetUpTestSuite(), blender::animrig::tests::ActionLegacyTest::SetUpTestSuite(), blender::animrig::tests::ActionQueryTest::SetUpTestSuite(), blender::animrig::tests::AnimationEvaluationTest::SetUpTestSuite(), blender::animrig::tests::KeyframingTest::SetUpTestSuite(), blender::bke::tests::BMainTest::SetUpTestSuite(), blender::bke::tests::BPathTest::SetUpTestSuite(), blender::bke::tests::ImageTest::SetUpTestSuite(), blender::interface::tests::CopyDriversToSelected::SetUpTestSuite(), blender::animrig::tests::ArmatureBoneCollections::TearDown(), blender::animrig::tests::ArmatureBoneCollectionsTestList::TearDown(), blender::bke::id::tests::TEST(), blender::bke::id::tests::TEST(), blender::bke::id::tests::TEST(), blender::bke::id::tests::TEST(), blender::bke::id::tests::TEST(), and blender::bke::tests::TEST().

◆ id_type_init()

◆ idtype_get_info_from_name()

static const IDTypeInfo * idtype_get_info_from_name ( const char * idtype_name)
static

Definition at line 155 of file idtype.cc.

References id_types, and STREQ.

Referenced by BKE_idtype_idcode_from_name().

Variable Documentation

◆ id_types