summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2015-03-28 04:15:43 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2015-03-28 04:15:43 (GMT)
commit72d896f70948d515cf047e76d1067ae5c3ccd35c (patch)
tree8284a0a63946e607a9957ab5524a498462c35204 /c++/src
parent6f75afd15ef87c7075512fa76422369320828717 (diff)
downloadhdf5-72d896f70948d515cf047e76d1067ae5c3ccd35c.zip
hdf5-72d896f70948d515cf047e76d1067ae5c3ccd35c.tar.gz
hdf5-72d896f70948d515cf047e76d1067ae5c3ccd35c.tar.bz2
[svn-r26640] Purpose: Fix bugs
Description: - Changed DataType::operator= to simply copy the id of rhs instead of calling H5Tcopy because, when the operator= is invoked, a different datatype id is created and it won't have the same characteristics as rhs', specifically, if the rhs represents a named datatype, "this" would still be a transient datatype. - Added a DataType constructor that takes a PredType object, and this constructor will cause H5Tcopy to generate another datatype id, from a predefined datatype. - Fixed various mistakes in tests. Platforms tested: Linux/64 (platypus) Linux/32 2.6 (jam/gnu and jam/icc 15) SunOS 5.11 (emu development/production)
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5DataType.cpp28
-rw-r--r--c++/src/H5DataType.h3
-rw-r--r--c++/src/H5IntType.h2
3 files changed, 31 insertions, 2 deletions
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index c4b1694..9040668 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -141,6 +141,22 @@ DataType::DataType(const DataType& original) : H5Object()
}
//--------------------------------------------------------------------------
+// Function: DataType overloaded constructor
+///\brief Creates a integer type using a predefined type
+///\param pred_type - IN: Predefined datatype
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - 2000
+// Description
+// This is so that when a predefined type is passed in, a
+// copy of it is made, not just a duplicate of the HDF5 id.
+//--------------------------------------------------------------------------
+DataType::DataType(const PredType& pred_type) : H5Object()
+{
+ // use DataType::copy to make a copy of this predefined type
+ copy(pred_type);
+}
+
+//--------------------------------------------------------------------------
// Function: DataType::copy
///\brief Copies an existing datatype to this datatype object
///\param like_type - IN: Datatype to be copied
@@ -203,11 +219,21 @@ void DataType::copy(const DataSet& dset)
// Makes a copy of the type on the right hand side and stores
// the new id in the left hand side object.
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// Changed operator= to simply copy the id of rhs instead of
+// calling H5Tcopy because, when the operator= is invoked, a
+// different datatype id is created and it won't have the same
+// characteristics as the original one, specifically, if the
+// rhs represents a named datatype, "this" would still be a
+// transient datatype.
//--------------------------------------------------------------------------
DataType& DataType::operator=( const DataType& rhs )
{
if (this != &rhs)
- copy(rhs);
+ {
+ id = rhs.id;
+ incRefCount(); // increment number of references to this id
+ }
return(*this);
}
diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h
index 064bfe1..e2af3f3 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -36,6 +36,9 @@ class H5_DLLCPP DataType : public H5Object {
// Copy constructor: makes a copy of the original object
DataType( const DataType& original );
+ // Creates a copy of a predefined type
+ DataType(const PredType& pred_type);
+
// Creates a datatype by way of dereference.
DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h
index 95fa642..e28f5c2 100644
--- a/c++/src/H5IntType.h
+++ b/c++/src/H5IntType.h
@@ -24,7 +24,7 @@ namespace H5 {
//! Class IntType operates on HDF5 integer datatype.
class H5_DLLCPP IntType : public AtomType {
public:
- // Creates a integer type using a predefined type
+ // Creates an integer type using a predefined type
IntType(const PredType& pred_type);
// Gets the integer datatype of the specified dataset