Merge pull request #1667 in HDFFV/hdf5 from ~BMRIBLER/hdf5-bmr:develop to develop

* commit '3bc708078c6da432e68d7c8cda695ad7b794c860':
  Added more info to the function headers.
  Added new C++ wrappers - HDFFV-10622
This commit is contained in:
Binh-Minh Ribler 2019-04-27 23:14:36 -05:00
commit 3d904f8141
5 changed files with 176 additions and 13 deletions

View File

@ -102,6 +102,46 @@ LinkCreatPropList::LinkCreatPropList(const LinkCreatPropList& original) : PropLi
//--------------------------------------------------------------------------
LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id) {}
//--------------------------------------------------------------------------
// Function: LinkCreatPropList::setCreateIntermediateGroup
///\brief Specifies in property list whether to create missing
/// intermediate groups.
///\param crt_intmd_group - IN: Flag specifying whether to create
/// intermediate groups upon the creation of an object
///\exception H5::PropListIException
// April, 2019
//--------------------------------------------------------------------------
void LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const
{
herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group);
// Throw exception if H5Pset_create_intermediate_group returns failure
if (ret_value < 0)
{
throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed");
}
}
//--------------------------------------------------------------------------
// Function: LinkCreatPropList::getCreateIntermediateGroup
///\brief Determines whether property is set to enable creating missing
/// intermediate groups.
///\return true if creating intermediate groups is enabled, and false, otherwise
///\exception H5::PropListIException
// April, 2019
//--------------------------------------------------------------------------
bool LinkCreatPropList::getCreateIntermediateGroup() const
{
unsigned crt_intmd_group;
herr_t ret_value = H5Pget_create_intermediate_group(id, &crt_intmd_group);
// Throw exception if H5Pget_create_intermediate_group returns failure
if (ret_value < 0)
{
throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed");
}
return((bool)crt_intmd_group);
}
//--------------------------------------------------------------------------
// Function: LinkCreatPropList::setCharEncoding
///\brief Sets the character encoding of the string.

View File

@ -40,6 +40,14 @@ class H5_DLLCPP LinkCreatPropList : public PropList {
// using the property list id.
LinkCreatPropList (const hid_t plist_id);
// Specifies in property list whether to create missing
// intermediate groups
void setCreateIntermediateGroup(bool crt_intmd_group) const;
// Determines whether property is set to enable creating missing
// intermediate groups
bool getCreateIntermediateGroup() const;
// Sets the character encoding of the string.
void setCharEncoding(H5T_cset_t encoding) const;

View File

@ -1066,7 +1066,7 @@ void H5Location::link(const char *curr_name, const Group& new_loc,
hid_t lcpl_id = lcpl.getId();
hid_t lapl_id = lapl.getId();
ret_value = H5Lcreate_hard(getId(), curr_name, new_loc.getId(), new_name, H5P_DEFAULT, H5P_DEFAULT);
ret_value = H5Lcreate_hard(getId(), curr_name, new_loc_id, new_name, lcpl_id, lapl_id);
if (ret_value < 0)
throwException("link", "creating link failed");
}
@ -1102,14 +1102,13 @@ void H5Location::link(const H5std_string& curr_name, const Group& new_loc,
/// H5Lcreate_hard APIs in the HDF5 C Reference Manual.
// March 2018
//--------------------------------------------------------------------------
void H5Location::link(const char *curr_name, const hid_t same_loc,
const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const
void H5Location::link(const char *curr_name, const hid_t same_loc, const char *new_name, const LinkCreatPropList& lcpl, const LinkAccPropList& lapl) const
{
herr_t ret_value = -1;
hid_t lcpl_id = lcpl.getId();
hid_t lapl_id = lapl.getId();
ret_value = H5Lcreate_hard(getId(), curr_name, same_loc, new_name, H5P_DEFAULT, H5P_DEFAULT);
ret_value = H5Lcreate_hard(getId(), curr_name, same_loc, new_name, lcpl_id, lapl_id);
if (ret_value < 0)
throwException("link", "creating link failed");

View File

@ -614,6 +614,117 @@ static void test_getobjectinfo_same_file()
} // test_getobjectinfo_same_file
/*-------------------------------------------------------------------------
* Function: test_intermediate_groups
*
* Purpose Test that intermediate groups are created as specified by
* the property setting.
*
* Return None
*
* April, 2019
*-------------------------------------------------------------------------
*/
const H5std_string FILE_INTERGRPS("tobject_intergrps.h5");
const H5std_string GROUP10NAME("/group10");
const H5std_string GROUP11NAME("/group10/group11");
const H5std_string GROUP12NAME("/group10/group11/group12");
const H5std_string GROUP13NAME("/group10/group11/group12/group13");
const H5std_string GROUP14NAME("/group10/group11/group12/group13/group14");
const H5std_string GROUP14FROM13NAME("group14");
const H5std_string GROUP20NAME("/group20");
const H5std_string GROUP21NAME("/group20/group21");
const H5std_string GROUP22NAME("group21/group22");
const H5std_string GROUP22FULLNAME("/group20/group21/group22");
static void test_intermediate_groups()
{
// Output message about test being performed
SUBTEST("Group::set/getCreateIntermediateGroup");
try {
// Create a new HDF5 file
H5File file(FILE_INTERGRPS, H5F_ACC_TRUNC);
// Create a link create property list and set the "create
// intermediate groups" flag
LinkCreatPropList lcpl;
lcpl.setCreateIntermediateGroup(true);
// Verify value of create missing groups flag
bool crt_int_grps = lcpl.getCreateIntermediateGroup();
verify_val(crt_int_grps, true, "LinkCreatPropList::getCreateIntermediateGroup", __LINE__, __FILE__);
// Create GROUP12NAME with creating missing groups
Group grp12(file.createGroup(GROUP12NAME, lcpl));
// Missing groups: GROUP10NAME and GROUP11NAME
// Create GROUP14NAME without the use of link create plist, should
// fail because group GROUP13NAME is missing
try {
Group grp14_nopl(file.createGroup(GROUP14NAME));
} catch (FileIException& expected1) {} // Failure is ignored
// Create GROUP14NAME with the flag to create missing groups set
// to FALSE, should fail because group GROUP13NAME is missing
// Reset flag to not create missing groups
lcpl.setCreateIntermediateGroup(false);
// Verify value of create missing groups flag
crt_int_grps = lcpl.getCreateIntermediateGroup();
verify_val(crt_int_grps, false, "LinkCreatPropList::getCreateIntermediateGroup", __LINE__, __FILE__);
try {
Group grp14_false(file.createGroup(GROUP14NAME, lcpl));
} catch (FileIException& expected2) {} // Failure is ignored
// Set the flag to create missing groups set to TRUE
lcpl.setCreateIntermediateGroup(true);
crt_int_grps = lcpl.getCreateIntermediateGroup();
verify_val(crt_int_grps, true, "LinkCreatPropList::getCreateIntermediateGroup", __LINE__, __FILE__);
// Create GROUP14NAME with the use of link create plist
Group grp14(file.createGroup(GROUP14NAME, lcpl));
// Missing groups: GROUP13NAME
// Create group GROUP20NAME
Group grp20(file.createGroup(GROUP20NAME));
// Create group GROUP22NAME with missing group GROUP21NAME
Group grp22(grp20.createGroup(GROUP22NAME, lcpl));
// Close groups and file
grp12.close();
grp14.close();
grp20.close();
grp22.close();
file.close();
// Reopen the file
file.openFile(FILE_INTERGRPS, H5F_ACC_RDWR);
// Open the missing groups and various combinations
Group grp10(file.openGroup(GROUP10NAME));
Group grp11(file.openGroup(GROUP11NAME));
Group grp13(file.openGroup(GROUP13NAME));
Group grp14from13(grp13.openGroup(GROUP14FROM13NAME));
Group grp21(file.openGroup(GROUP21NAME));
Group grp22fromfile(file.openGroup(GROUP22FULLNAME));
PASSED();
} // end of try block
// catch all other exceptions
catch (Exception& E)
{
cerr << " in Exception " << E.getCFuncName() << "detail: " << E.getCDetailMsg() << endl;
issue_fail_msg("test_intermediate_groups()", __LINE__, __FILE__, E.getCDetailMsg());
}
} // test_intermediate_groups
/*-------------------------------------------------------------------------
* Function: test_object
*
@ -631,12 +742,13 @@ void test_object()
// Output message about test being performed
MESSAGE(5, ("Testing Object Functions\n"));
test_get_objname(); // Test get object name from groups/datasets
test_existance(); // Test check for object existance
test_get_objname_ontypes(); // Test get object name from types
test_get_objtype(); // Test get object type
test_open_object_header(); // Test object header functions (H5O)
test_getobjectinfo_same_file(); // Test object info in same file
test_get_objname(); // Test get object name from groups/datasets
test_existance(); // Test check for object existance
test_get_objname_ontypes(); // Test get object name from types
test_get_objtype(); // Test get object type
test_open_object_header(); // Test object header functions (H5O)
test_getobjectinfo_same_file(); // Test object info in same file
test_intermediate_groups(); // Test intermediate group property
} // test_object

View File

@ -183,13 +183,17 @@ New Features
C++ Library:
------------
- Added new function to the C++ interface
Added wrapper for H5Ovisit2:
- Added new wrapper for H5Ovisit2()
H5Object::visit()
(BMR - 2019/02/14, HDFFV-10532)
- Added new wrappers for H5Pset/get_create_intermediate_group()
LinkCreatPropList::setCreateIntermediateGroup()
LinkCreatPropList::getCreateIntermediateGroup()
(BMR - 2019/04/22, HDFFV-10622)
Java Library:
----------------