diff options
author | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2014-06-17 16:59:33 (GMT) |
---|---|---|
committer | Jerome Soumagne <jsoumagne@hdfgroup.org> | 2014-06-17 16:59:33 (GMT) |
commit | a77417a9611716b73ef175065f723bc59d74d03d (patch) | |
tree | 8589dad8623ba52fc41233ee5716eabe279a5282 /src | |
parent | f5ddc36428e90357cb2fa9827cba69722295bc97 (diff) | |
download | hdf5-a77417a9611716b73ef175065f723bc59d74d03d.zip hdf5-a77417a9611716b73ef175065f723bc59d74d03d.tar.gz hdf5-a77417a9611716b73ef175065f723bc59d74d03d.tar.bz2 |
[svn-r25303] Split H5Qget_match_op into H5Qget_type and H5Qget_match_op
Track type of combined queries
H5Qget_type can be called on combined queries
Update example
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Q.c | 99 | ||||
-rw-r--r-- | src/H5Qprivate.h | 4 | ||||
-rw-r--r-- | src/H5Qpublic.h | 6 |
3 files changed, 88 insertions, 21 deletions
@@ -552,6 +552,7 @@ H5Q_t * H5Q_combine(H5Q_t *query1, H5Q_combine_op_t combine_op, H5Q_t *query2) { H5Q_t *query = NULL; + H5Q_type_t type1, type2; H5Q_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -575,6 +576,10 @@ H5Q_combine(H5Q_t *query1, H5Q_combine_op_t combine_op, H5Q_t *query2) query1->ref_count++; query->query.combine.r_query = query2; query2->ref_count++; + /* Work out query type of the combined query */ + type1 = (query1->is_combined) ? query1->query.combine.type : query1->query.select.type; + type2 = (query2->is_combined) ? query2->query.combine.type : query2->query.select.type; + query->query.combine.type = (type1 == type2) ? type1 : H5Q_TYPE_MISC; /* set return value */ ret_value = query; @@ -587,14 +592,73 @@ done: } /* end H5Q_combine() */ /*------------------------------------------------------------------------- - * Function: H5Qget_match_info - * - * Purpose: The H5Qget_match_info routine queries a singleton query object, - * given by query_id, for its match information, originally provided to - * H5Qcreate. Match information is returned through the match_type and - * match_op parameters, either of which may be NULL to avoid retrieving that - * information. See H5Qcreate for a table listing the complete set of values - * that may be returned for match_type and match_op. + * Function: H5Qget_type + * + * Purpose: The H5Qget_type routine queries a query object, + * given by query_id, for its type information, originally provided to + * H5Qcreate or created after a call to H5Qcombine. Information is returned + * through the query_type parameter. See H5Qcreate for a table listing the + * complete set of values that may be returned for query_type. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Qget_type(hid_t query_id, H5Q_type_t *query_type) +{ + H5Q_t *query = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*Qt*Qm", query_id, query_type, match_op); + + /* Check args and get the query objects */ + if (NULL == (query = (H5Q_t *) H5I_object_verify(query_id, H5I_QUERY))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a query ID"); + + /* Get match info */ + if (FAIL == H5Q_get_type(query, query_type)) + HGOTO_ERROR(H5E_QUERY, H5E_CANTGET, FAIL, "unable to get query type"); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Qget_type() */ + +/*------------------------------------------------------------------------- + * Function: H5Q_get_type + * + * Purpose: Private function for H5Qget_type. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5Q_get_type(H5Q_t *query, H5Q_type_t *query_type) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(query); + + if (query_type) + *query_type = (query->is_combined) ? query->query.combine.type : + query->query.select.type; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5Q_get_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5Qget_match_op + * + * Purpose: The H5Qget_match_op routine queries a singleton query object, + * given by query_id, for its op information, originally provided to + * H5Qcreate. Match information is returned through the + * match_op parameter. See H5Qcreate for a table listing the complete set of + * values that may be returned for match_op. * It is an error to perform this call on a compound query object (one which * was created with H5Qcombine). * @@ -603,7 +667,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Qget_match_info(hid_t query_id, H5Q_type_t *query_type, H5Q_match_op_t *match_op) +H5Qget_match_op(hid_t query_id, H5Q_match_op_t *match_op) { H5Q_t *query = NULL; herr_t ret_value = SUCCEED; /* Return value */ @@ -616,24 +680,24 @@ H5Qget_match_info(hid_t query_id, H5Q_type_t *query_type, H5Q_match_op_t *match_ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a query ID"); /* Get match info */ - if (FAIL == H5Q_get_match_info(query, query_type, match_op)) - HGOTO_ERROR(H5E_QUERY, H5E_CANTGET, FAIL, "unable to get match info"); + if (FAIL == H5Q_get_match_op(query, match_op)) + HGOTO_ERROR(H5E_QUERY, H5E_CANTGET, FAIL, "unable to get match op"); done: FUNC_LEAVE_API(ret_value) -} /* end H5Qget_match_info() */ +} /* end H5Qget_match_op() */ /*------------------------------------------------------------------------- - * Function: H5Q_get_match_info + * Function: H5Q_get_match_op * - * Purpose: Private function for H5Qget_match_info. + * Purpose: Private function for H5Qget_match_op. * * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ herr_t -H5Q_get_match_info(H5Q_t *query, H5Q_type_t *query_type, H5Q_match_op_t *match_op) +H5Q_get_match_op(H5Q_t *query, H5Q_match_op_t *match_op) { herr_t ret_value = SUCCEED; /* Return value */ @@ -642,14 +706,13 @@ H5Q_get_match_info(H5Q_t *query, H5Q_type_t *query_type, H5Q_match_op_t *match_o HDassert(query); if (query->is_combined) - HGOTO_ERROR(H5E_QUERY, H5E_CANTGET, FAIL, "cannot retrieve info from combined query"); + HGOTO_ERROR(H5E_QUERY, H5E_CANTGET, FAIL, "cannot retrieve op from combined query"); - if (query_type) *query_type = query->query.select.type; if (match_op) *match_op = query->query.select.match_op; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5Q_get_match_info() */ +} /* end H5Q_get_match_op() */ /*------------------------------------------------------------------------- * Function: H5Qget_components diff --git a/src/H5Qprivate.h b/src/H5Qprivate.h index b579234..f53fb3c 100644 --- a/src/H5Qprivate.h +++ b/src/H5Qprivate.h @@ -55,6 +55,7 @@ typedef struct H5Q_t H5Q_t; /* Combine query */ struct H5Q_combine { + H5Q_type_t type; /* type */ H5Q_combine_op_t op; /* op */ H5Q_t *l_query; /* left op query */ H5Q_t *r_query; /* right op query */ @@ -92,7 +93,8 @@ H5_DLL herr_t H5Q_init(void); H5_DLL H5Q_t *H5Q_create(H5Q_type_t query_type, H5Q_match_op_t match_op, ...); H5_DLL herr_t H5Q_close(H5Q_t *query); H5_DLL H5Q_t *H5Q_combine(H5Q_t *query1, H5Q_combine_op_t combine_op, H5Q_t *query2); -H5_DLL herr_t H5Q_get_match_info(H5Q_t *query, H5Q_type_t *query_type, H5Q_match_op_t *match_op); +H5_DLL herr_t H5Q_get_type(H5Q_t *query, H5Q_type_t *query_type); +H5_DLL herr_t H5Q_get_match_op(H5Q_t *query, H5Q_match_op_t *match_op); H5_DLL herr_t H5Q_get_components(H5Q_t *query, H5Q_t **sub_query1, H5Q_t **sub_query2); H5_DLL herr_t H5Q_get_combine_op(H5Q_t *query, H5Q_combine_op_t *op_type); diff --git a/src/H5Qpublic.h b/src/H5Qpublic.h index dec0f82..ded4fcc 100644 --- a/src/H5Qpublic.h +++ b/src/H5Qpublic.h @@ -37,7 +37,8 @@ typedef enum H5Q_type_t { H5Q_TYPE_DATA_ELEM, /* selects data elements */ H5Q_TYPE_ATTR_VALUE, /* selects attribute values */ H5Q_TYPE_ATTR_NAME, /* selects attributes */ - H5Q_TYPE_LINK_NAME /* selects objects */ + H5Q_TYPE_LINK_NAME, /* selects objects */ + H5Q_TYPE_MISC /* (for combine queries) selects misc objects */ } H5Q_type_t; /* Query match conditions */ @@ -70,7 +71,8 @@ extern "C" { H5_DLL hid_t H5Qcreate(H5Q_type_t query_type, H5Q_match_op_t match_op, ...); H5_DLL herr_t H5Qclose(hid_t query_id); H5_DLL hid_t H5Qcombine(hid_t query1_id, H5Q_combine_op_t combine_op, hid_t query2_id); -H5_DLL herr_t H5Qget_match_info(hid_t query_id, H5Q_type_t *query_type, H5Q_match_op_t *match_op); +H5_DLL herr_t H5Qget_type(hid_t query_id, H5Q_type_t *query_type); +H5_DLL herr_t H5Qget_match_op(hid_t query_id, H5Q_match_op_t *match_op); H5_DLL herr_t H5Qget_components(hid_t query_id, hid_t *sub_query1_id, hid_t *sub_query2_id); H5_DLL herr_t H5Qget_combine_op(hid_t query_id, H5Q_combine_op_t *op_type); |