summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2018-03-10 03:29:28 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2018-03-10 03:29:28 (GMT)
commit539f4691fa1cd9e86965106ce69b08d3e18a80a9 (patch)
treee5c29fb7f5258750094cc6292078b34b40b3370e /c++/src
parentace714c36a30efce3c84f94bc575b2f0ad07322b (diff)
downloadhdf5-539f4691fa1cd9e86965106ce69b08d3e18a80a9.zip
hdf5-539f4691fa1cd9e86965106ce69b08d3e18a80a9.tar.gz
hdf5-539f4691fa1cd9e86965106ce69b08d3e18a80a9.tar.bz2
Added C++ wrappers - HDFFV-10149
Description: Added the following wrappers to class H5::Group: + H5Lcreate_soft: // Creates a soft link from link_name to target_name. void newLink(const char *target_name, const char *link_name,...) void newLink(const H5std_string& target_name,...) + H5Lcreate_hard: // Creates a hard link from new_name to curr_name. void newLink(const char *curr_name, const Group& new_loc,...) void newLink(const H5std_string& curr_name, const Group& new_loc,...) // Creates a hard link from new_name to curr_name in same location. void newLink(const char *curr_name, const hid_t same_loc,...) void newLink(const H5std_string& curr_name, const hid_t same_loc,...) + H5Lcopy: // Copy an object from a group of file to another. void copyLink(const char *src_name, const Group& dst,...) void copyLink(const H5std_string& src_name, const Group& dst,...) // Copy an object from a group of file to the same location. void copyLink(const char *src_name, const char *dst_name,...) void copyLink(const H5std_string& src_name,...) + H5Lmove: // Rename an object in a group or file to a new location. void moveLink(const char* src_name, const Group& dst,...) void moveLink(const H5std_string& src_name, const Group& dst,...) // Rename an object in a group or file to the same location. void moveLink(const char* src_name, const char* dst_name,...) void moveLink(const H5std_string& src_name,...) Platforms tested: Linux/64 (jelly) Linux/ppc64 (ostrich) Darwin (osx1010test)
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5Group.cpp311
-rw-r--r--c++/src/H5Group.h69
-rw-r--r--c++/src/H5Location.cpp3
3 files changed, 363 insertions, 20 deletions
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index c0e0dd1..aa27a18 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -76,6 +76,297 @@ void Group::closeObjId(hid_t obj_id) const
}
}
+/*** For H5L API ***/
+
+//--------------------------------------------------------------------------
+// Function: Group::newLink
+///\brief Creates a soft link from \a link_name to \a target_name.
+///\param target_name - IN: Name of object, can be a non-existing object
+///\param link_name - IN: Link name for the target name
+///\param lcpl - IN: Link creation plist - default to PropList::DEFAULT
+///\param lapl - IN: Link access plist - default to PropList::DEFAULT
+///\exception H5::FileIException or H5::GroupIException
+///\par Description
+/// Note that both names are interpreted relative to the current
+/// location.
+/// For information on creating a soft link, please refer to the
+/// H5Lcreate_soft APIs in the HDF5 C Reference Manual.
+// March 2018
+//--------------------------------------------------------------------------
+void Group::newLink(const char *target_name, const char *link_name,
+ const PropList& lcpl, const PropList& lapl) const
+{
+ herr_t ret_value = -1;
+ hid_t lcpl_id = lcpl.getId();
+ hid_t lapl_id = lapl.getId();
+
+ ret_value = H5Lcreate_soft(target_name, id, link_name, lcpl_id, lapl_id);
+ if (ret_value < 0)
+ throwException("newLink", "creating soft link failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::newLink
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a target_name and \a link_name.
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::newLink(const H5std_string& target_name, const H5std_string&
+ link_name, const PropList& lcpl, const PropList& lapl) const
+{
+ newLink(target_name.c_str(), link_name.c_str(), lcpl, lapl);
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::newLink
+///\brief Creates a hard link from \a new_name to \a curr_name.
+///\param curr_name - IN: Name of the existing object
+///\param new_name - IN: New name for the object
+///\param lcpl - IN: Link creation plist - default to PropList::DEFAULT
+///\param lapl - IN: Link access plist - default to PropList::DEFAULT
+///\exception H5::FileIException or H5::GroupIException
+///\par Description
+/// Note that both names are interpreted relative to the
+/// specified location.
+/// For information on creating a hard link, please refer to the
+/// H5Lcreate_hard APIs in the HDF5 C Reference Manual.
+// March 2018
+//--------------------------------------------------------------------------
+void Group::newLink(const char *curr_name, const Group& new_loc,
+ const char *new_name, const PropList& lcpl, const PropList& lapl) const
+{
+ herr_t ret_value = -1;
+ hid_t new_loc_id = new_loc.getId();
+ 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);
+ if (ret_value < 0)
+ throwException("newLink", "creating link failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::newLink
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a curr_name and \a new_name.
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::newLink(const H5std_string& curr_name, const Group& new_loc,
+ const H5std_string& new_name, const PropList& lcpl, const PropList& lapl) const
+{
+ newLink(curr_name.c_str(), new_loc, new_name.c_str(), lcpl, lapl);
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::newLink
+///\brief Creates a hard link from \a new_name to \a curr_name - can be
+/// used to pass in H5L_SAME_LOC.
+///\param curr_name - IN: Name of the existing object
+///\param new_name - IN: New name for the object
+///\param lcpl - IN: Link creation plist - default to PropList::DEFAULT
+///\param lapl - IN: Link access plist - default to PropList::DEFAULT
+///\exception H5::FileIException or H5::GroupIException
+///\par Description
+/// Note that both names are interpreted relative to the
+/// specified location.
+/// For information on creating a hard link, please refer to the
+/// H5Lcreate_hard APIs in the HDF5 C Reference Manual.
+// March 2018
+//--------------------------------------------------------------------------
+void Group::newLink(const char *curr_name, const hid_t same_loc,
+ const char *new_name, const PropList& lcpl, const PropList& 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);
+
+ if (ret_value < 0)
+ throwException("newLink", "creating link failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::newLink
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a curr_name and \a new_name.
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::newLink(const H5std_string& curr_name, const hid_t same_loc,
+ const H5std_string& new_name, const PropList& lcpl, const PropList& lapl) const
+{
+ newLink(curr_name.c_str(), same_loc, new_name.c_str(), lcpl, lapl);
+}
+
+
+//--------------------------------------------------------------------------
+// Function: Group::copyLink
+///\brief Copies a link from one location to another.
+///\param src - IN: Source location
+///\param src_name - IN: Original name
+///\param dst - IN: Destination location
+///\param dst_name - IN: New name
+///\param lcpl - IN: Link creation plist - default PropList::DEFAULT
+///\param lapl - IN: Link access plist - default PropList::DEFAULT
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::copyLink(const char *src_name,
+ const Group& dst, const char *dst_name, const PropList& lcpl,
+ const PropList& lapl) const
+{
+ herr_t ret_value;
+ hid_t dst_id = dst.getId();
+ hid_t lcpl_id = lcpl.getId();
+ hid_t lapl_id = lapl.getId();
+
+ ret_value = H5Lcopy(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id);
+ if(ret_value < 0)
+ throwException("copyLink", "H5Lcopy failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::copyLink
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a src_name and \a dst_name.
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::copyLink(const H5std_string& src_name,
+ const Group& dst, const H5std_string& dst_name, const PropList& lcpl,
+ const PropList& lapl) const
+{
+ copyLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl);
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::copyLink
+///\brief Copies a link to the same location.
+///\param src - IN: Source location
+///\param src_name - IN: Original name
+///\param dst_name - IN: New name
+///\param lcpl - IN: Link creation plist - default PropList::DEFAULT
+///\param lapl - IN: Link access plist - default PropList::DEFAULT
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::copyLink(const char *src_name,
+ const char *dst_name, const PropList& lcpl,
+ const PropList& lapl) const
+{
+ herr_t ret_value;
+ hid_t lcpl_id = lcpl.getId();
+ hid_t lapl_id = lapl.getId();
+
+ ret_value = H5Lcopy(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id);
+ if(ret_value < 0)
+ throwException("copyLink", "H5Lcopy H5L_SAME_LOC failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::copyLink
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a src_name and \a dst_name.
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::copyLink(const H5std_string& src_name,
+ const H5std_string& dst_name, const PropList& lcpl,
+ const PropList& lapl) const
+{
+ copyLink(src_name.c_str(), dst_name.c_str(), lcpl, lapl);
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::moveLink
+///\brief Renames an object in a group/file and moves it to a new location.
+///\param src - IN: Source location
+///\param src_name - IN: Original name
+///\param dst - IN: Destination location
+///\param dst_name - IN: New name
+///\param lcpl - IN: Link creation plist - default PropList::DEFAULT
+///\param lapl - IN: Link access plist - default PropList::DEFAULT
+///\exception H5::FileIException or H5::GroupIException
+///\note
+/// Exercise care in moving groups as it is possible to render
+/// data in a file inaccessible with Group::moveLink. Please refer
+/// to the Group Interface in the HDF5 User's Guide for details.
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::moveLink(const char* src_name, const Group& dst, const char* dst_name, const PropList& lcpl, const PropList& lapl) const
+{
+ herr_t ret_value;
+ hid_t dst_id = dst.getId();
+ hid_t lcpl_id = lcpl.getId();
+ hid_t lapl_id = lapl.getId();
+
+ ret_value = H5Lmove(getId(), src_name, dst_id, dst_name, lcpl_id, lapl_id);
+ if (ret_value < 0)
+ throwException("moveLink", "H5Lmove failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::moveLink
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a src_name and \a dst_name.
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::moveLink(const H5std_string& src_name, const Group& dst, const H5std_string& dst_name, const PropList& lcpl, const PropList& lapl) const
+{
+ moveLink(src_name.c_str(), dst, dst_name.c_str(), lcpl, lapl);
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::moveLink
+///\brief Renames an object in a group or file to the same location.
+///\param src - IN: Source location
+///\param src_name - IN: Original name
+///\param dst_name - IN: New name
+///\param lcpl - IN: Link creation plist - default PropList::DEFAULT
+///\param lapl - IN: Link access plist - default PropList::DEFAULT
+///\exception H5::FileIException or H5::GroupIException
+///\note
+/// Exercise care in moving groups as it is possible to render
+/// data in a file inaccessible with Group::moveLink. Please refer
+/// to the Group Interface in the HDF5 User's Guide for details.
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::moveLink(const char* src_name, const char* dst_name, const PropList& lcpl, const PropList& lapl) const
+{
+ herr_t ret_value;
+ hid_t lcpl_id = lcpl.getId();
+ hid_t lapl_id = lapl.getId();
+
+ ret_value = H5Lmove(getId(), src_name, H5L_SAME_LOC, dst_name, lcpl_id, lapl_id);
+ if (ret_value < 0)
+ throwException("moveLink", "H5Lmove H5L_SAME_LOC failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::moveLink
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for \a src_name and \a dst_name.
+///\exception H5::FileIException or H5::GroupIException
+// March, 2018
+//--------------------------------------------------------------------------
+void Group::moveLink(const H5std_string& src_name, const H5std_string& dst_name, const PropList& lcpl, const PropList& lapl) const
+{
+ moveLink(src_name.c_str(), H5L_SAME_LOC, dst_name.c_str(), lcpl, lapl);
+}
+
+/*** End of H5L API section ***/
+
//--------------------------------------------------------------------------
// Function: Group::getLocId
// Purpose: Get the id of this group
@@ -123,26 +414,6 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const
}
//--------------------------------------------------------------------------
-// Function: Group overload constructor - dereference
-// brief Given a reference, ref, to an hdf5 group, creates a Group objec
-// param attr - IN: Specifying location where the referenced object is i
-// param ref - IN: Reference pointer
-// param ref_type - IN: Reference type - default to H5R_OBJECT
-// param plist - IN: Property list - default to PropList::DEFAULT
-// exception H5::ReferenceException
-// Programmer Binh-Minh Ribler - Oct, 2006
-// Modification
-// Mar, 2017
-// Removed in 1.10.1 because H5Location is Attribute's baseclass
-// now. -BMR
-//--------------------------------------------------------------------------
-/* Group::Group(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID)
-{
- id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference");
-}
- */
-
-//--------------------------------------------------------------------------
// Function: Group::getNumObjs
///\brief Returns the number of objects in this group.
///\return Number of objects
diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h
index b3a9007..d95d996 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -50,6 +50,75 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Closes an object opened by getObjId().
void closeObjId(hid_t obj_id) const;
+ /*** For H5L API ***/
+
+ // Creates a soft link from link_name to target_name.
+ void newLink(const char *target_name, const char *link_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+ void newLink(const H5std_string& target_name,
+ const H5std_string& link_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+
+ // Creates a hard link from new_name to curr_name.
+ void newLink(const char *curr_name,
+ const Group& new_loc, const char *new_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+ void newLink(const H5std_string& curr_name,
+ const Group& new_loc, const H5std_string& new_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+
+ // Creates a hard link from new_name to curr_name in same location.
+ void newLink(const char *curr_name,
+ const hid_t same_loc, const char *new_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+ void newLink(const H5std_string& curr_name,
+ const hid_t same_loc, const H5std_string& new_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+
+ // Copy an object from a group of file to another.
+ void copyLink(const char *src_name,
+ const Group& dst, const char *dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+ void copyLink(const H5std_string& src_name,
+ const Group& dst, const H5std_string& dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+
+ // Copy an object from a group of file to the same location.
+ void copyLink(const char *src_name, const char *dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+ void copyLink(const H5std_string& src_name,
+ const H5std_string& dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+
+ // Rename an object in a group or file to a new location.
+ void moveLink(const char* src_name,
+ const Group& dst, const char* dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+ void moveLink(const H5std_string& src_name,
+ const Group& dst, const H5std_string& dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+
+ // Rename an object in a group or file to the same location.
+ void moveLink(const char* src_name, const char* dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+ void moveLink(const H5std_string& src_name,
+ const H5std_string& dst_name,
+ const PropList& lcpl = PropList::DEFAULT,
+ const PropList& lapl = PropList::DEFAULT) const;
+
// default constructor
Group();
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 95c96ad..3ca080e 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -951,6 +951,9 @@ DataSet H5Location::openDataSet(const H5std_string& name) const
// Programmer Binh-Minh Ribler - 2000
// Modification
// 2007: QAK modified to use H5L APIs - BMR
+// Mar 2018: Inadequate functionality, new hard link is only in
+// H5L_SAME_LOC. This function will be retired in favor of
+// its replacement, Group::newLink(). - BMR
//--------------------------------------------------------------------------
void H5Location::link(H5L_type_t link_type, const char* curr_name, const char* new_name) const
{