Blender V5.3
BKE_lib_id.hh File Reference
#include <optional>
#include "BLI_compiler_attrs.hh"
#include "BLI_enum_flags.hh"
#include "BLI_set.hh"
#include "BLI_string_ref.hh"
#include "BLI_vector.hh"
#include "DNA_ID.h"
#include "DNA_listBase.h"
#include "DNA_userdef_enums.h"

Go to the source code of this file.

Classes

struct  blender::bke::id::ID_Runtime_Remap
struct  blender::bke::id::ID_Runtime
struct  blender::IDNewNameResult
struct  blender::BKEIDDeleteOptions

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::bke
namespace  blender::bke::id

Macros

#define MAIN_ID_SESSION_UID_UNSET   0
#define MAX_ID_FULL_NAME   (256 + 256 + 3 + 1)
#define MAX_ID_FULL_NAME_UI   (MAX_ID_FULL_NAME + 3)
#define IS_TAGGED(_id)

Enumerations

enum  {
  blender::LIB_ID_CREATE_NO_MAIN = 1 << 0 , blender::LIB_ID_CREATE_NO_USER_REFCOUNT = 1 << 1 , blender::LIB_ID_CREATE_NO_ALLOCATE = 1 << 2 , blender::LIB_ID_CREATE_NO_DEG_TAG = 1 << 8 ,
  blender::LIB_ID_CREATE_LOCAL = 1 << 9 , blender::LIB_ID_COPY_SET_COPIED_ON_WRITE = 1 << 10 , blender::LIB_ID_COPY_ID_NEW_SET = 1 << 11 , blender::LIB_ID_COPY_NO_PREVIEW = 1 << 17 ,
  blender::LIB_ID_COPY_CACHES = 1 << 18 , blender::LIB_ID_COPY_NO_ANIMDATA = 1 << 19 , blender::LIB_ID_COPY_NO_LIB_OVERRIDE = 1 << 21 , blender::LIB_ID_COPY_NO_LIB_OVERRIDE_LOCAL_DATA_FLAG = 1 << 22 ,
  blender::LIB_ID_COPY_ACTIONS = 1 << 24 , blender::LIB_ID_COPY_SHAPEKEY = 1 << 26 , blender::LIB_ID_COPY_SCREEN = 1 << 27 , blender::LIB_ID_COPY_NODETREE_LOCALIZE = 1 << 28 ,
  blender::LIB_ID_COPY_RIGID_BODY_NO_COLLECTION_HANDLING = 1 << 29 , blender::LIB_ID_COPY_ASSET_METADATA = 1 << 30 , blender::LIB_ID_COPY_DEFAULT = LIB_ID_COPY_SHAPEKEY | LIB_ID_COPY_SCREEN , blender::LIB_ID_CREATE_LOCALIZE ,
  blender::LIB_ID_COPY_LOCALIZE
}
enum class  blender::IDNewNameMode { blender::RenameExistingNever = 0 , blender::RenameExistingAlways = 1 , blender::RenameExistingSameRoot = 2 }
enum  blender::eLibIDDuplicateFlags { blender::LIB_ID_DUPLICATE_IS_SUBPROCESS = 1 << 0 , blender::LIB_ID_DUPLICATE_IS_ROOT_ID = 1 << 1 }
enum  {
  blender::LIB_ID_FREE_NO_MAIN = 1 << 0 , blender::LIB_ID_FREE_NO_USER_REFCOUNT = 1 << 1 , blender::LIB_ID_FREE_NOT_ALLOCATED = 1 << 2 , blender::LIB_ID_FREE_NO_DEG_TAG = 1 << 8 ,
  blender::LIB_ID_FREE_NO_UI_USER = 1 << 9 , blender::LIB_ID_FREE_NO_NAMEMAP_REMOVE = 1 << 10
}
enum  {
  blender::LIB_ID_MAKELOCAL_FULL_LIBRARY = 1 << 0 , blender::LIB_ID_MAKELOCAL_INDIRECT = 1 << 1 , blender::LIB_ID_MAKELOCAL_FORCE_LOCAL = 1 << 8 , blender::LIB_ID_MAKELOCAL_FORCE_COPY = 1 << 9 ,
  blender::LIB_ID_MAKELOCAL_ASSET_DATA_CLEAR = 1 << 16 , blender::LIB_ID_MAKELOCAL_LIBOVERRIDE_CLEAR = 1 << 17
}

Functions

size_t blender::BKE_libblock_get_alloc_info (short type, const char **r_name)
ID * blender::BKE_libblock_alloc_notest (short type) ATTR_WARN_UNUSED_RESULT
void * blender::BKE_libblock_alloc (Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
void * blender::BKE_libblock_alloc_in_lib (Main *bmain, std::optional< Library * > owner_library, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
void blender::BKE_libblock_init_empty (ID *id) ATTR_NONNULL(1)
void blender::BKE_libblock_runtime_ensure (ID &id)
void blender::BKE_libblock_runtime_reset_remapping_status (ID *id) ATTR_NONNULL(1)
void blender::BKE_lib_libblock_session_uid_ensure (ID *id)
void blender::BKE_lib_libblock_session_uid_renew (ID *id)
void * blender::BKE_id_new (Main *bmain, short type, const char *name)
template<typename T>
T * blender::BKE_id_new (Main *bmain, const char *name)
void * blender::BKE_id_new_in_lib (Main *bmain, std::optional< Library * > owner_library, short type, const char *name)
template<typename T>
T * blender::BKE_id_new_in_lib (Main *bmain, std::optional< Library * > owner_library, const char *name)
void * blender::BKE_id_new_nomain (short type, const char *name)
template<typename T>
T * blender::BKE_id_new_nomain (const char *name)
void blender::BKE_libblock_copy_ex (Main *bmain, const ID *id, ID **new_id_p, int orig_flag)
void blender::BKE_libblock_copy_in_lib (Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int orig_flag)
void * blender::BKE_libblock_copy (Main *bmain, const ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void blender::BKE_id_move_to_same_lib (Main &bmain, ID &id, const ID &owner_id)
IDNewNameResult blender::BKE_libblock_rename (Main &bmain, ID &id, StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
IDNewNameResult blender::BKE_id_rename (Main &bmain, ID &id, StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
ID * blender::BKE_libblock_find_name (Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ID * blender::BKE_libblock_find_session_uid (Main *bmain, short type, uint32_t session_uid)
ID * blender::BKE_libblock_find_session_uid (Main *bmain, uint32_t session_uid)
ID * blender::BKE_libblock_find_name_and_library (Main *bmain, short type, const char *name, const char *lib_name)
ID * blender::BKE_libblock_find_name_and_library_filepath (Main *bmain, short type, const char *name, const char *lib_filepath_abs)
void blender::BKE_libblock_free_runtime_data (ID *id)
void blender::BKE_libblock_free_data (ID *id, bool do_id_user) ATTR_NONNULL()
void blender::BKE_libblock_free_datablock (ID *id, int flag) ATTR_NONNULL()
void blender::BKE_id_free_ex (Main *bmain, void *idv, int flag_orig, bool use_flag_from_idtag)
void blender::BKE_id_free (Main *bmain, void *idv)
void blender::BKE_id_free_us (Main *bmain, void *idv) ATTR_NONNULL()
void blender::BKE_id_delete (Main *bmain, void *idv, const BKEIDDeleteOptions &options={}) ATTR_NONNULL()
size_t blender::BKE_id_multi_tagged_delete (Main *bmain, const BKEIDDeleteOptions &options={}) ATTR_NONNULL()
size_t blender::BKE_id_multi_delete (Main *bmain, Set< ID * > &ids_to_delete, const BKEIDDeleteOptions &options={})
void blender::BKE_libblock_management_main_add (Main *bmain, void *idv)
void blender::BKE_libblock_management_main_remove (Main *bmain, void *idv)
void blender::BKE_libblock_management_usercounts_set (Main *bmain, void *idv)
void blender::BKE_libblock_management_usercounts_clear (Main *bmain, void *idv)
void blender::id_lib_extern (ID *id, bool enforce_fix=false)
void blender::id_lib_indirect (ID *id, bool enforce_fix=false)
void blender::id_lib_indirect_weak_link (ID *id)
void blender::id_us_ensure_real (ID *id)
void blender::id_us_clear_real (ID *id)
void blender::id_us_plus_no_lib (ID *id)
void blender::id_us_plus (ID *id)
void blender::id_us_min (ID *id)
void blender::id_fake_user_set (ID *id)
void blender::id_fake_user_clear (ID *id)
void blender::BKE_id_newptr_and_tag_clear (ID *id)
void blender::BKE_lib_id_make_local_generic_action_define (Main *bmain, ID *id, int flags, bool *r_force_local, bool *r_force_copy)
void blender::BKE_lib_id_make_local_generic (Main *bmain, ID *id, int flags)
bool blender::BKE_lib_id_make_local (Main *bmain, ID *id, int flags)
bool blender::id_single_user (bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop)
bool blender::BKE_id_copy_is_allowed (const ID *id)
ID * blender::BKE_id_copy_ex (Main *bmain, const ID *id, ID **new_id_p, int flag)
struct ID * blender::BKE_id_copy_in_lib (Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
ID * blender::BKE_id_copy (Main *bmain, const ID *id)
ID * blender::BKE_id_copy_for_duplicate (Main *bmain, ID *id, eDupli_ID_Flags duplicate_flags, int copy_flags)
ID * blender::BKE_id_copy_for_use_in_bmain (Main *bmain, const ID *id)
void blender::BKE_lib_id_swap (Main *bmain, ID *id_a, ID *id_b, const bool do_self_remap, const int self_remap_flags)
void blender::BKE_lib_id_swap_full (Main *bmain, ID *id_a, ID *id_b, const bool do_self_remap, const int self_remap_flags)
void blender::id_sort_by_name (ListBaseT< ID > *lb, ID *id, ID *id_sorting_hint)
void blender::BKE_lib_id_expand_local (Main *bmain, ID *id, int flags)
IDNewNameResult blender::BKE_id_new_name_validate (Main &bmain, ListBaseT< ID > &lb, ID &id, const char *newname, IDNewNameMode mode, bool do_linked_data)
void blender::BKE_lib_id_clear_library_data (Main *bmain, ID *id, int flags)
void blender::BKE_main_id_tag_idcode (Main *mainvar, short type, int tag, bool value)
void blender::BKE_main_id_tag_listbase (ListBaseT< ID > *lb, int tag, bool value)
void blender::BKE_main_id_tag_all (Main *mainvar, int tag, bool value)
void blender::BKE_main_id_flag_listbase (ListBaseT< ID > *lb, int flag, bool value)
void blender::BKE_main_id_flag_all (Main *bmain, int flag, bool value)
void blender::BKE_main_id_newptr_and_tag_clear (Main *bmain)
void blender::BKE_main_id_refcount_recompute (Main *bmain, bool do_linked_only)
void blender::BKE_main_id_indirect_linked_update (Main &bmain, std::optional< Span< ID * > > local_ids=std::nullopt)
void blender::BKE_main_lib_objects_recalc_all (Main *bmain)
void blender::BKE_main_id_repair_duplicate_names_listbase (Main *bmain, ListBaseT< ID > *lb)
void blender::BKE_id_full_name_get (char name[MAX_ID_FULL_NAME], const ID *id, char separator_char)
void blender::BKE_id_full_name_ui_prefix_get (char name[MAX_ID_FULL_NAME_UI], const ID *id, bool add_lib_hint, char separator_char, int *r_prefix_len)
const char * blender::BKE_id_name (const ID &id)
char * blender::BKE_id_name (ID &id)
char * blender::BKE_id_to_unique_string_key (const ID *id)
void blender::BKE_library_make_local (Main *bmain, const Library *lib, GHash *old_to_new_ids, bool untagged_only, bool set_fake, bool clear_asset_data)
void blender::BKE_id_tag_set_atomic (ID *id, int tag)
void blender::BKE_id_tag_clear_atomic (ID *id, int tag)
bool blender::BKE_id_is_in_main (Main *bmain, ID *id)
bool blender::BKE_id_is_in_global_main (ID *id)
bool blender::BKE_id_can_be_asset (const ID *id)
ID * blender::BKE_id_owner_get (ID *id, const bool debug_relationship_assert=true)
bool blender::BKE_id_is_editable (const Main *bmain, const ID *id)
bool blender::BKE_id_can_use_id (const ID &id_from, const ID &id_to)
Vector< ID * > blender::BKE_id_ordered_list (const ListBaseT< ID > *lb)
void blender::BKE_id_reorder (const ListBaseT< ID > *lb, ID *id, ID *relative, bool after)
void blender::BKE_id_blend_write (BlendWriter *writer, ID *id)
void blender::BKE_id_eval_properties_copy (ID *id_cow, ID *id)
Python Data Handling
void blender::BKE_libblock_free_data_py (ID *id)

Detailed Description

API to manage data-blocks inside of Blender's Main data-base, or as independent runtime-only data.

Note
BKE_lib_ files are for operations over data-blocks themselves, although they might alter Main as well (when creating/renaming/deleting an ID e.g.).

Names

Warning
Descriptions below is ideal goal, current status of naming does not yet fully follow it (this is WIP).
  • BKE_lib_id_ should be used for rather high-level operations, that involve Main database and relations with other IDs, and can be considered as 'safe' (as in, in themselves, they leave affected IDs/Main in a consistent status).
  • BKE_lib_libblock_ should be used for lower level operations, that perform some parts of BKE_lib_id_ ones, but will generally not ensure caller that affected data is in a consistent state by their own execution alone.
  • BKE_lib_main_ should be used for operations performed over all IDs of a given Main data-base.
Note
External code should typically not use BKE_lib_libblock_ functions, except in some specific cases requiring advanced (and potentially dangerous) handling.

Definition in file BKE_lib_id.hh.

Macro Definition Documentation

◆ IS_TAGGED

#define IS_TAGGED ( _id)
Value:
((_id) && (((ID *)_id)->tag & ID_TAG_DOIT))

Definition at line 1086 of file BKE_lib_id.hh.

Referenced by blender::ed::object::object_convert_exec().

◆ MAIN_ID_SESSION_UID_UNSET

◆ MAX_ID_FULL_NAME

#define MAX_ID_FULL_NAME   (256 + 256 + 3 + 1)

◆ MAX_ID_FULL_NAME_UI

#define MAX_ID_FULL_NAME_UI   (MAX_ID_FULL_NAME + 3)

Adds 'key-code' two letters at beginning.

Definition at line 967 of file BKE_lib_id.hh.

Referenced by blender::BKE_id_full_name_ui_prefix_get(), blender::ui::id_search_add(), and blender::ui::rna_collection_search_update_fn().