H5L_VISIT1 is a recursive iteration function to visit all links in and below a group in an HDF5 file, thus providing a mechanism for an application to perform a common set of operations across all of those links or a dynamically selected subset. For non-recursive iteration across the members of a group, see H5L_ITERATE1 . The group serving as the root of the iteration is specified by its group or file identifier, group_id . Two parameters are used to establish the iteration: idx_type and order . idx_type specifies the index to be used. If the links have not been indexed by the index type, they will first be sorted by that index then the iteration will begin; if the links have been so indexed, the sorting step will be unnecessary, so the iteration may begin more quickly. Valid values include the following:
H5_INDEX_NAME | Alpha-numeric index on name | H5_INDEX_CRT_ORDER | Index on creation order |
Note that the index type passed in idx_type is a best effort setting. If the application passes in a value indicating iteration in creation order and a group is encountered that was not tracked in creation order, that group will be iterated over in alpha-numeric order by name, or name order. (Name order is the native order used by the HDF5 library and is always available.) order specifies the order in which objects are to be inspected along the index specified in index_type . Valid values include the following:
H5_ITER_INC | Increasing order | H5_ITER_DEC | Decreasing order | H5_ITER_NATIVE | Fastest available order |
The prototype of the callback function op is as follows (as defined in the source code file H5Lpublic.h ): typedef herr_t (*H5L_iterate1_t)(hid_t group, const char *name, const H5L_info1_t *info, void *op_data);
The parameters of this callback function have the following values or meanings: group | Group that serves as root of the iteration; same value as the H5L_VISIT group_id parameter | name | Name of link, relative to g_id , being examined at current step of the iteration | info | H5L_info_t struct containing information regarding that link | op_data | User-defined pointer to data required by the application in processing the link; a pass-through of the op_data pointer provided with the H5L_VISIT function call |
The H5L_info1_t struct is defined (in H5Lpublic.h ) as follows: typedef struct {
H5L_type_t type; /* Type of link */
hbool_t corder_valid; /* Indicates whether creation */
/* order is valid */
int64_t corder; /* Creation order */
H5T_cset_t cset; /* Character set of link name */
union {
haddr_t address; /* Address hard link points to */
size_t val_size; /* Size of soft link or */
/* user-defined link value */
} u;
} H5L_info1_t;
The possible return values from the callback function, and the effect of each, are as follows: - Zero causes the visit iterator to continue, returning zero when all group members have been processed.
- A positive value causes the visit iterator to immediately return that positive value, indicating short-circuit success.
- A negative value causes the visit iterator to immediately return that value, indicating failure.
The H5L_VISIT1 op_data parameter is a user-defined pointer to the data required to process links in the course of the iteration. This pointer is passed back to each step of the iteration in the op callback function’s op_data parameter. H5L_VISIT1 and H5O_VISIT1 are companion functions: one for examining and operating on links; the other for examining and operating on the objects that those links point to. Both functions ensure that by the time the function completes successfully, every link or object below the specified point in the file has been presented to the application for whatever processing the application requires. Note |
---|
Programming Note for C++ Developers Using C Functions: If a C routine that takes a function pointer as an argument is called from within C++ code, the C routine should be returned from normally. Examples of this kind of routine include callbacks such as H5P_SET_ELINK_CB and H5P_SET_TYPE_CONV_CB and functions such as H5T_CONVERT and H5E_WALK2. Exiting the routine in its normal fashion allows the HDF5 C library to clean up its work properly. In other words, if the C++ application jumps out of the routine back to the C++ “catch” statement, the library is not given the opportunity to close any temporary data structures that were set up when the routine was called. The C++ application should save some state as the routine is started so that any problem that occurs might be diagnosed. |
|