Page tree

The license could not be verified: License Certificate has expired!

 

JAVA

FORTRAN

C++

C

 

Link

H5O_VISIT_BY_NAME3

Recursively visits all objects starting from a specified object

Procedure:

H5O_VISIT_BY_NAME3 ( loc_id, obj_name, idx_type, order, op, op_data, fields, lapl_id )

Signature:

herr_t H5Ovisit_by_name3 ( hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate2_t op, void *op_data, 
             unsigned fields, hid_t lapl_id)

SUBROUTINE h5ovisit_by_name_f(loc_id, object_name, index_type, order, &
       op, op_data, return_value, hdferr, lapl_id)
    USE, INTRINSIC :: ISO_C_BINDING
    IMPLICIT NONE
    INTEGER(HID_T)  , INTENT(IN)             :: loc_id
    CHARACTER(LEN=*), INTENT(IN)             :: object_name
    INTEGER         , INTENT(IN)             :: index_type 
    INTEGER         , INTENT(IN)             :: order

    TYPE(C_FUNPTR)                           :: op
    TYPE(C_PTR)                              :: op_data
    INTEGER         , INTENT(OUT)            :: return_value
    INTEGER         , INTENT(OUT)            :: hdferr
    INTEGER(HID_T)  , INTENT(IN) , OPTIONAL  :: lapl_id

Parameters:
hid_t loc_idIN: Location identifier; may be a file, group, dataset, named datatype or attribute identifier
const char *obj_nameIN: Name of the object, generally relative to loc_id, that will serve as root of the iteration
H5_index_t idx_typeIN: Type of index; valid values include: 
         H5_INDEX_NAME 
         H5_INDEX_CRT_ORDER
H5_iter_order_t order    IN: Order in which index is traversed; valid values include: 
         H5_ITER_DEC 
         H5_ITER_INC 
         H5_ITER_NATIVE
H5O_iterate2_t opIN: Callback function passing data regarding the object to the calling application
void *op_dataIN: User-defined pointer to data required by the application for its processing of the object
unsigned fieldsIN: Flags specifying the fields to be retrieved to the callback function op
hid_t lapl_idIN: Link access property list identifier

Description:

H5O_VISIT_BY_NAME3 is a recursive iteration function to visit the object specified by the loc_id / obj_name parameter pair and, if that object is a group, all objects in and below it in an HDF5 file, thus providing a mechanism for an application to perform a common set of operations across all of those objects or a dynamically selected subset. For non-recursive iteration across the members of a group, see H5L_ITERATE2.

The object serving as the root of the iteration is specified by the loc_id / obj_name parameter pair. loc_id specifies a file or an object in a file; obj_name specifies either an object in the file (with an absolute name based in the file’s root group) or an object name relative to loc_id. If loc_id fully specifies the object that is to serve as the root of the iteration, obj_name should be '.' (a dot). (Note that when loc_id fully specifies the the object that is to serve as the root of the iteration, the user may wish to consider using H5O_VISIT3 instead of H5O_VISIT_BY_NAME3.)

Two parameters are used to establish the iteration: idx_type and order.

idx_type specifies the index to be used. If the links in a group 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 unnecesary, so the iteration may begin more quickly. Valid values include the following:

H5_INDEX_NAMEAlpha-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 idx_type. Valid values include the following:

H5_ITER_INCIncreasing order
H5_ITER_DECDecreasing order
H5_ITER_NATIVE    Fastest available order

The prototype of the callback function op is as follows (as defined in the source code file H5Opublic.h):

typedef herr_t (*H5O_iterate2_t)(hid_t obj, const char *name, const H5O_info2_t *info, void *op_data);

The parameters of this callback function have the following values or meanings:

objObject that serves as root of the iteration  
nameName of object, relative to obj, being examined at current step of the iteration
infoH5O_info2_t struct containing information regarding that object
op_dataUser-defined pointer to data required by the application in processing the object    

The H5O_info2_t  struct is defined (in  H5Opublic.h) as follows :

src / H5Opublic.h [129:141]  hdf5_1_12  HDFFV/hdf5
/* Data model information struct for objects */
/* (For H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx version 3) */
typedef struct H5O_info2_t {
    unsigned long   fileno;     /* File number that object is located in */
    H5O_token_t     token;      /* Token representing the object        */
    H5O_type_t 	    type;       /* Basic object type (group, dataset, etc.) */
    unsigned        rc;         /* Reference count of object            */
    time_t          atime;      /* Access time                          */
    time_t          mtime;      /* Modification time                    */
    time_t          ctime;      /* Change time                          */
    time_t          btime;      /* Birth time                           */
    hsize_t         num_attrs;  /* # of attributes attached to object   */
} H5O_info2_t;

H5O_token_t is defined in H5public.h as follows:

src / H5public.h [337:341]  hdf5_1_12  HDFFV/hdf5
/* Type for object tokens */
/* (Hoisted here, since it's used by both the H5Lpublic.h and H5Opublic.h headers) */
typedef struct H5O_token_t {
    uint8_t __data[H5O_MAX_TOKEN_SIZE];
} H5O_token_t;

The  H5O_type_t  enum indicates the object type and is defined (in  H5Opublic.h) as follows:

src / H5Opublic.h [101:109]  hdf5_1_12  HDFFV/hdf5
/* Types of objects in file */
typedef enum H5O_type_t {
    H5O_TYPE_UNKNOWN = -1,	/* Unknown object type		*/
    H5O_TYPE_GROUP,	        /* Object is a group		*/
    H5O_TYPE_DATASET,		/* Object is a dataset		*/
    H5O_TYPE_NAMED_DATATYPE, 	/* Object is a named data type	*/
    H5O_TYPE_MAP,               /* Object is a map */
    H5O_TYPE_NTYPES             /* Number of different object types (must be last!) */
} H5O_type_t;

   

 The H5O_VISIT_BY_NAME3 op_data parameter is a user-defined pointer to the data required to process objects in the course of the iteration. This pointer is passed back to each step of the iteration in the callback function’s op_data parameter.

lapl_id is a link access property list. In the general case, when default link access properties are acceptable, this can be passed in as H5P_DEFAULT. An example of a situation that requires a non-default link access property list is when the link is an external link; an external link may require that a link prefix be set in a link access property list (see H5P_SET_ELINK_PREFIX). 

The fields parameter contains flags to determine which fields will be retrieved by the op callback function. These flags are defined in the H5Opublic.h file:

FlagPurpose
H5O_INFO_BASICFill in the fileno, addr, type, and rc fields
H5O_INFO_TIMEFill in the atime, mtime, ctime, and btime fields
H5O_INFO_NUM_ATTRSFill in the num_attrs field
H5O_INFO_HDRFill in the hdr field
H5O_INFO_META_SIZEFill in the meta_size field
H5O_INFO_ALLH5O_INFO_BASIC | H5O_INFO_TIME | H5O_INFO_NUM_ATTRS | H5O_INFO_HDR | H5O_INFO_META_SIZE

H5L_VISIT_BY_NAME2 and H5O_VISIT_BY_NAME3 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.

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.

Returns:

On success, returns the return value of the first operator that returns a positive value, or zero if all members were processed with no operator returning non-zero.

On failure, returns a negative value if something goes wrong within the library, or the first negative value returned by an operator.

Example:

test / links.c [13057:13060]  hdf5_1_12  HDFFV/hdf5
    /* Visit all the objects reachable from the root group (with file ID) */
    udata.idx = 0;
    udata.info = new_format ? ovisit0_new : ovisit0_old;
    if(H5Ovisit_by_name3(fid, "/", H5_INDEX_NAME, H5_ITER_INC, visit_obj_cb, &udata, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR

History:
Release    Change
1.12.0The function was introduced in this release.

--- Last Modified: February 19, 2020 | 02:26 PM