diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-03-24 14:28:41 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-03-24 18:10:39 +0300 |
commit | c08924bf94f2dffaae7b3ef2fad3c49cb8043c89 (patch) | |
tree | ee01dfd8f137667c39be7e3ed894236a64464751 /source/blender/blenkernel/BKE_library_query.h | |
parent | 60cf62ff4b08e310208dca9e35bd75131833e1aa (diff) |
Rework library_query foreach looper - add optional recursivity.
This commit:
* Fixes bad handling of 'stop iteration' (by adding a status flag, so that we can actually
stop in helper functions too, and jumping to a finalize label instead of raw return, to
allow propper clean up).
* Adds optional recursion into 'ID tree' - callback can also decide to exclude current id_pp
from recursion. Note that this implies 'readonly', modifying IDs while recursing is not
something we want to support!
* Changes callback signature/expected behavior: return behavior is now handled through flags,
and 'parent' ID of id_pp is also passed (since it may not always be root id anymore).
Reviewers: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D1869
Diffstat (limited to 'source/blender/blenkernel/BKE_library_query.h')
-rw-r--r-- | source/blender/blenkernel/BKE_library_query.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_library_query.h b/source/blender/blenkernel/BKE_library_query.h index f07644dc833..86628ea8b6f 100644 --- a/source/blender/blenkernel/BKE_library_query.h +++ b/source/blender/blenkernel/BKE_library_query.h @@ -50,15 +50,23 @@ enum { IDWALK_USER_ONE = (1 << 9), }; -/* Call a callback for each ID link which the given ID uses. +enum { + IDWALK_RET_NOP = 0, + IDWALK_RET_STOP_ITER = 1 << 0, /* Completly top iteration. */ + IDWALK_RET_STOP_RECURSION = 1 << 1, /* Stop recursion, that is, do not loop over ID used by current one. */ +}; + +/** + * Call a callback for each ID link which the given ID uses. * - * Return 'false' if you want to stop iteration. + * \return a set of flags to controll further iteration (0 to keep going). */ -typedef bool (*LibraryIDLinkCallback) (void *user_data, struct ID **id_pointer, int cd_flag); +typedef int (*LibraryIDLinkCallback) (void *user_data, struct ID *id_self, struct ID **id_pointer, int cd_flag); /* Flags for the foreach function itself. */ enum { IDWALK_READONLY = (1 << 0), + IDWALK_RECURSE = (1 << 1), /* Also implies IDWALK_READONLY. */ }; /* Loop over all of the ID's this datablock links to. */ |