Blender  V2.93
BKE_lib_query.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2014 by Blender Foundation.
17  * All rights reserved.
18  */
19 #pragma once
20 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 struct ID;
42 struct IDProperty;
43 struct Main;
44 
45 /* Tips for the callback for cases it's gonna to modify the pointer. */
46 enum {
50 
56 
62  IDWALK_CB_EMBEDDED = (1 << 3),
63 
68  IDWALK_CB_LOOPBACK = (1 << 4),
69 
72 
75 
81  IDWALK_CB_INTERNAL = (1 << 7),
82 
87  IDWALK_CB_USER = (1 << 8),
93  IDWALK_CB_USER_ONE = (1 << 9),
94 };
95 
96 enum {
102 };
103 
105  void *user_data;
107  struct Main *bmain;
112  struct ID *id_owner;
117  struct ID *id_self;
118  struct ID **id_pointer;
119  int cb_flag;
121 
128 
129 /* Flags for the foreach function itself. */
130 enum {
132  IDWALK_READONLY = (1 << 0),
133  IDWALK_RECURSE = (1 << 1), /* Also implies IDWALK_READONLY. */
134  IDWALK_INCLUDE_UI = (1 << 2), /* Include UI pointers (from WM and screens editors). */
137 
138  IDWALK_NO_INDIRECT_PROXY_DATA_USAGE = (1 << 8), /* Ugly special case :(((( */
142 };
143 
145 
147  struct ID **id_pp,
148  int cb_flag);
151  const int cb_flag,
152  const bool do_replace);
153 
154 #define BKE_LIB_FOREACHID_PROCESS_ID(_data, _id, _cb_flag) \
155  { \
156  CHECK_TYPE_ANY((_id), ID *, void *); \
157  if (!BKE_lib_query_foreachid_process((_data), (ID **)&(_id), (_cb_flag))) { \
158  return; \
159  } \
160  } \
161  ((void)0)
162 
163 #define BKE_LIB_FOREACHID_PROCESS(_data, _id_super, _cb_flag) \
164  { \
165  CHECK_TYPE(&((_id_super)->id), ID *); \
166  if (!BKE_lib_query_foreachid_process((_data), (ID **)&(_id_super), (_cb_flag))) { \
167  return; \
168  } \
169  } \
170  ((void)0)
171 
172 bool BKE_library_foreach_ID_embedded(struct LibraryForeachIDData *data, struct ID **id_pp);
174 
175 /* Loop over all of the ID's this datablock links to. */
177  struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, void *user_data, int flag);
178 void BKE_library_update_ID_link_user(struct ID *id_dst, struct ID *id_src, const int cb_flag);
179 
180 int BKE_library_ID_use_ID(struct ID *id_user, struct ID *id_used);
181 
182 bool BKE_library_id_can_use_idtype(struct ID *id_owner, const short id_type_used);
183 
184 bool BKE_library_ID_is_locally_used(struct Main *bmain, void *idv);
185 bool BKE_library_ID_is_indirectly_used(struct Main *bmain, void *idv);
187  void *idv,
188  bool *is_used_local,
189  bool *is_used_linked);
190 
192  const int tag,
193  const bool do_local_ids,
194  const bool do_linked_ids,
195  const bool do_tag_recursive,
196  int *r_num_tagged);
197 
198 void BKE_library_unused_linked_data_set_tag(struct Main *bmain, const bool do_init_tag);
200 
201 #ifdef __cplusplus
202 }
203 #endif
int(* LibraryIDLinkCallback)(LibraryIDLinkCallbackData *cb_data)
@ IDWALK_RECURSE
@ IDWALK_INCLUDE_UI
@ IDWALK_NOP
@ IDWALK_READONLY
@ IDWALK_NO_INDIRECT_PROXY_DATA_USAGE
@ IDWALK_DO_INTERNAL_RUNTIME_POINTERS
@ IDWALK_IGNORE_EMBEDDED_ID
int BKE_lib_query_foreachid_process_callback_flag_override(struct LibraryForeachIDData *data, const int cb_flag, const bool do_replace)
Definition: lib_query.c:128
void BKE_library_foreach_ID_link(struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
Definition: lib_query.c:322
@ IDWALK_RET_STOP_RECURSION
@ IDWALK_RET_STOP_ITER
Definition: BKE_lib_query.h:99
@ IDWALK_RET_NOP
Definition: BKE_lib_query.h:97
bool BKE_library_ID_is_locally_used(struct Main *bmain, void *idv)
Definition: lib_query.c:580
bool BKE_library_ID_is_indirectly_used(struct Main *bmain, void *idv)
Definition: lib_query.c:588
void BKE_lib_query_idpropertiesForeachIDLink_callback(struct IDProperty *id_prop, void *user_data)
Definition: lib_query.c:150
void BKE_library_ID_test_usages(struct Main *bmain, void *idv, bool *is_used_local, bool *is_used_linked)
Definition: lib_query.c:597
int BKE_lib_query_foreachid_process_flags_get(struct LibraryForeachIDData *data)
Definition: lib_query.c:123
void BKE_lib_query_unused_ids_tag(struct Main *bmain, const int tag, const bool do_local_ids, const bool do_linked_ids, const bool do_tag_recursive, int *r_num_tagged)
Definition: lib_query.c:726
int BKE_library_ID_use_ID(struct ID *id_user, struct ID *id_used)
Definition: lib_query.c:529
@ IDWALK_CB_LOOPBACK
Definition: BKE_lib_query.h:68
@ IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE
Definition: BKE_lib_query.h:74
@ IDWALK_CB_NEVER_SELF
Definition: BKE_lib_query.h:49
@ IDWALK_CB_USER_ONE
Definition: BKE_lib_query.h:93
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:87
@ IDWALK_CB_INTERNAL
Definition: BKE_lib_query.h:81
@ IDWALK_CB_EMBEDDED
Definition: BKE_lib_query.h:62
@ IDWALK_CB_NEVER_NULL
Definition: BKE_lib_query.h:48
@ IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE
Definition: BKE_lib_query.h:71
@ IDWALK_CB_NOP
Definition: BKE_lib_query.h:47
@ IDWALK_CB_INDIRECT_USAGE
Definition: BKE_lib_query.h:55
bool BKE_library_foreach_ID_embedded(struct LibraryForeachIDData *data, struct ID **id_pp)
Definition: lib_query.c:161
struct LibraryIDLinkCallbackData LibraryIDLinkCallbackData
void BKE_library_unused_linked_data_set_tag(struct Main *bmain, const bool do_init_tag)
Definition: lib_query.c:799
void BKE_library_indirectly_used_data_tag_clear(struct Main *bmain)
Definition: lib_query.c:836
bool BKE_library_id_can_use_idtype(struct ID *id_owner, const short id_type_used)
Definition: lib_query.c:348
void BKE_library_update_ID_link_user(struct ID *id_dst, struct ID *id_src, const int cb_flag)
Definition: lib_query.c:331
bool BKE_lib_query_foreachid_process(struct LibraryForeachIDData *data, struct ID **id_pp, int cb_flag)
Definition: lib_query.c:79
void * user_data
DEGForeachIDComponentCallback callback
Definition: DNA_ID.h:273
Definition: BKE_main.h:116