summaryrefslogtreecommitdiffstats
path: root/c++/src/H5DataType.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2016-12-19 06:34:18 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2016-12-19 06:34:18 (GMT)
commit798cdad29a49e0883446f7dad3c7992d53ea6ee3 (patch)
tree1de6ed6b6115be9cecd3753b63d3c69b54d03a80 /c++/src/H5DataType.cpp
parent700c6ae9851752d8ccf6fc18cdd5b44dcf9603a5 (diff)
downloadhdf5-798cdad29a49e0883446f7dad3c7992d53ea6ee3.zip
hdf5-798cdad29a49e0883446f7dad3c7992d53ea6ee3.tar.gz
hdf5-798cdad29a49e0883446f7dad3c7992d53ea6ee3.tar.bz2
Purpose: Improvement for HDFFV-10004
Description: When adding wrappers for H5Lexists, a new class, LinkAccPropList, was added to the C++ API, triggered complicated circular dependencies. Thus, some improvement was made to resolve the problems. - Replaced existing functions openXxxType with individual type constructors + Added individual XxxType constructors to replace the existing functions openXxxType because it's rather awkward to use these functions. + Moved openXxxType from H5Location back to CommonFG + Put back CommonFG as a baseclass of Group for openXxxType functions. + This replacement should improve usability and prevent the problem of circular dependencies. - Removed overloaded constructor that takes an Attribute when there is already one that takes H5Location because Attribute inherits from H5Location now. Platforms tested: Linux/32 2.6 (jam) Darwin (osx1010test) Linux/64 (platypus)
Diffstat (limited to 'c++/src/H5DataType.cpp')
-rw-r--r--c++/src/H5DataType.cpp66
1 files changed, 61 insertions, 5 deletions
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 7dcd343..3955ebf 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -23,13 +23,13 @@
#include "H5Include.h"
#include "H5Exception.h"
#include "H5IdComponent.h"
+#include "H5DataSpace.h"
#include "H5PropList.h"
#include "H5FaccProp.h"
#include "H5FcreatProp.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
-#include "H5DataSpace.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"
@@ -38,8 +38,6 @@
#include "H5private.h"
#include "H5AbstractDs.h"
#include "H5DataSet.h"
-#include "H5Group.h"
-#include "H5File.h"
#include "H5Attribute.h"
namespace H5 {
@@ -122,10 +120,11 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type,
// Jul, 2008
// Added for application convenience.
//--------------------------------------------------------------------------
-DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID)
+ /* DataType::DataType(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: DataType copy constructor
@@ -152,13 +151,49 @@ DataType::DataType(const DataType& original) : H5Object(), id(original.id)
//--------------------------------------------------------------------------
DataType::DataType(const PredType& pred_type) : H5Object()
{
- // call C routine to copy the datatype
+ // Call C routine to copy the datatype
id = H5Tcopy( pred_type.getId() );
if (id < 0)
throw DataTypeIException("DataType constructor", "H5Tcopy failed");
}
//--------------------------------------------------------------------------
+// Function: DataType overloaded constructor
+///\brief Creates a DataType instance by opening an HDF5 datatype given
+/// its name as a char*.
+///\param dtype_name - IN: Datatype name
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - Dec 2016
+// Description
+// In 1.10.1, this constructor was introduced and will replace the
+// existing function CommonFG::openDataType(const char*) to
+// improve usability.
+// -BMR, Dec 2016
+//--------------------------------------------------------------------------
+DataType::DataType(const H5Location& loc, const char *dtype_name) : H5Object()
+{
+ id = p_opentype(loc, dtype_name);
+}
+
+//--------------------------------------------------------------------------
+// Function: DataType overloaded constructor
+///\brief Creates a DataType instance by opening an HDF5 datatype given
+/// its name as an \c H5std_string.
+///\param dtype_name - IN: Datatype name
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - Dec 2016
+// Description
+// In 1.10.1, this constructor was introduced and will replace the
+// existing function CommonFG::openDataType(const H5std_string&) to
+// improve usability.
+// -BMR, Dec 2016
+//--------------------------------------------------------------------------
+DataType::DataType(const H5Location& loc, const H5std_string& dtype_name) : H5Object()
+{
+ id = p_opentype(loc, dtype_name.c_str());
+}
+
+//--------------------------------------------------------------------------
// Function: DataType::copy
///\brief Copies an existing datatype to this datatype object
///\param like_type - IN: Datatype to be copied
@@ -264,6 +299,27 @@ bool DataType::operator==(const DataType& compared_type ) const
}
//--------------------------------------------------------------------------
+// Function: DataType::p_opentype (private)
+///\brief Opens an HDF5 datatype given its name
+///\param dtype_name - IN: Datatype name
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - Dec 2016
+// Description
+// This function was introduced in 1.10.1 to be used by the new
+// XxxType constructors that were introduced to replace the
+// existing functions CommonFG::openXxxType(), which is awkward
+// to use. -BMR, Dec 2016
+//--------------------------------------------------------------------------
+hid_t DataType::p_opentype(const H5Location& loc, const char *dtype_name) const
+{
+ // Call C function to open the named datatype at this location
+ hid_t ret_value = H5Topen2(loc.getId(), dtype_name, H5P_DEFAULT);
+ if (ret_value < 0)
+ throw DataTypeIException("DataType constructor", "H5Topen2 failed");
+ return(ret_value);
+}
+
+//--------------------------------------------------------------------------
// Function: DataType::p_commit (private)
//\brief Commits a transient datatype to a file, creating a new
// named datatype