summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2016-03-07 15:42:30 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2016-03-07 15:42:30 (GMT)
commitb346cb0599da3b46f892365ad2ebd1e55ea173f3 (patch)
treea2c63f1639133b35138e171852118e2180d9c367 /c++/src
parent3247df1224d2f226a03144fb556b2a3435794871 (diff)
downloadhdf5-b346cb0599da3b46f892365ad2ebd1e55ea173f3.zip
hdf5-b346cb0599da3b46f892365ad2ebd1e55ea173f3.tar.gz
hdf5-b346cb0599da3b46f892365ad2ebd1e55ea173f3.tar.bz2
[svn-r29306] Purpose: Add function
Description: Added member function ArrayType::operator= because ArrayType has pointer data members. Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5AbstractDs.cpp2
-rw-r--r--c++/src/H5AbstractDs.h2
-rw-r--r--c++/src/H5ArrayType.cpp38
-rw-r--r--c++/src/H5ArrayType.h3
-rw-r--r--c++/src/H5Attribute.cpp6
-rw-r--r--c++/src/H5CommonFG.cpp2
-rw-r--r--c++/src/H5DataSet.cpp6
-rw-r--r--c++/src/H5DataSpace.cpp6
-rw-r--r--c++/src/H5DataType.cpp6
-rw-r--r--c++/src/H5Exception.cpp6
-rw-r--r--c++/src/H5Group.cpp6
-rw-r--r--c++/src/H5PropList.cpp3
12 files changed, 56 insertions, 30 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp
index 4e9a4d5..8d88c53 100644
--- a/c++/src/H5AbstractDs.cpp
+++ b/c++/src/H5AbstractDs.cpp
@@ -49,7 +49,7 @@ AbstractDs::AbstractDs(){}
// removal does not raise any problems in 1.10, it will be removed from 1.8 in
// subsequent releases.
//--------------------------------------------------------------------------
-AbstractDs::AbstractDs(const hid_t ds_id){}
+// Mar 2016 -BMR, AbstractDs::AbstractDs(const hid_t ds_id){}
//--------------------------------------------------------------------------
// Function: AbstractDs::getTypeClass
diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h
index ee2e45e..6975d6f 100644
--- a/c++/src/H5AbstractDs.h
+++ b/c++/src/H5AbstractDs.h
@@ -85,7 +85,7 @@ class H5_DLLCPP AbstractDs {
// other will be removed from 1.10 release, and then from 1.8 if its
// removal does not raise any problems in two 1.10 releases.
- AbstractDs(const hid_t h5_id);
+ // Mar 2016 -BMR, AbstractDs(const hid_t h5_id);
// Copy constructor
// AbstractDs( const AbstractDs& original );
diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp
index 0f09631..5792467 100644
--- a/c++/src/H5ArrayType.cpp
+++ b/c++/src/H5ArrayType.cpp
@@ -93,6 +93,44 @@ ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims)
}
//--------------------------------------------------------------------------
+// Function: ArrayType::operator=
+///\brief Assignment operator
+///\param rhs - IN: Reference to the existing array datatype
+///\return Reference to ArrayType instance
+///\exception H5::DataTypeIException
+/// std::bad_alloc
+// Description
+// Closes the id on the lhs object first with setId, then copies
+// each data member from the rhs object.
+// Programmer Binh-Minh Ribler - Mar 2016
+// Modification
+//--------------------------------------------------------------------------
+ArrayType& ArrayType::operator=(const ArrayType& rhs)
+{
+ if (this != &rhs)
+ {
+ // handling references to this id
+ try {
+ setId(rhs.id);
+ // Note: a = b, so there are two objects with the same hdf5 id
+ // that's why incRefCount is needed, and it is called by setId
+ }
+ catch (Exception close_error) {
+ throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg());
+ }
+
+ // Copy the rank of the rhs array
+ rank = rhs.rank;
+
+ // Allocate space then copy the dimensions from the rhs array
+ dimensions = new hsize_t[rank];
+ for (int i = 0; i < rank; i++)
+ dimensions[i] = rhs.dimensions[i];
+ }
+ return(*this);
+}
+
+//--------------------------------------------------------------------------
// Function: ArrayType::setArrayInfo
///\brief Retrieves the rank and dimensions from the array datatype
/// and store the info in this ArrayType object.
diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h
index c0f4b38..ddbb5e2 100644
--- a/c++/src/H5ArrayType.h
+++ b/c++/src/H5ArrayType.h
@@ -31,6 +31,9 @@ class H5_DLLCPP ArrayType : public DataType {
// specified base type.
ArrayType(const DataType& base_type, int ndims, const hsize_t* dims);
+ // Assignment operator
+ ArrayType& operator=(const ArrayType& rhs);
+
// Stores the rank and dimensions in memory.
void setArrayInfo();
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index ea8c5bb..a6a8fee 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -60,9 +60,8 @@ Attribute::Attribute() : AbstractDs(), IdComponent(), id(H5I_INVALID_HID) {}
///\param original - IN: Original Attribute object to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Attribute::Attribute(const Attribute& original) : AbstractDs(), IdComponent()
+Attribute::Attribute(const Attribute& original) : AbstractDs(), IdComponent(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
@@ -74,9 +73,8 @@ Attribute::Attribute(const Attribute& original) : AbstractDs(), IdComponent()
///\exception H5::AttributeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Attribute::Attribute(const hid_t existing_id) : AbstractDs(), IdComponent()
+Attribute::Attribute(const hid_t existing_id) : AbstractDs(), IdComponent(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index c88f6c1..8bb31c4 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -328,7 +328,7 @@ void CommonFG::unlink( const H5std_string& name ) const
/// Exercise care in moving groups as it is possible to render
/// data in a file inaccessible with Group::move. Please refer
/// to the Group Interface in the HDF5 User's Guide for details at:
-/// http://www.hdfgroup.org/HDF5/doc/UG/UG_frame09Groups.html
+/// https://www.hdfgroup.org/HDF5/doc/UG/HDF5_Users_Guide-Responsive%20HTML5/index.html#t=HDF5_Users_Guide%2FGroups%2FHDF5_Groups.htm
// Programmer Binh-Minh Ribler - 2000
// Modification
// 2007: QAK modified to use H5L APIs - BMR
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index 059da85..3747967 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -67,9 +67,8 @@ DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {}
// when one of those objects is deleted, the id will be closed if
// the reference counter is only 1.
//--------------------------------------------------------------------------
-DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs()
+DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
@@ -79,9 +78,8 @@ DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs()
///\param original - IN: DataSet instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs()
+DataSet::DataSet(const DataSet& original) : H5Object(), AbstractDs(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 311180f..42ac4c7 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -132,9 +132,8 @@ DataSpace::DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims) :
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace(const hid_t existing_id) : IdComponent()
+DataSpace::DataSpace(const hid_t existing_id) : IdComponent(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
@@ -144,9 +143,8 @@ DataSpace::DataSpace(const hid_t existing_id) : IdComponent()
///\param original - IN: DataSpace object to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace(const DataSpace& original) : IdComponent()
+DataSpace::DataSpace(const DataSpace& original) : IdComponent(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 1bbabe3..54df7e0 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -69,9 +69,8 @@ DataType::DataType() : H5Object(), id(H5I_INVALID_HID) {}
// Removed second argument, "predefined", after changing to the
// new ref counting mechanism that relies on C's ref counting.
//--------------------------------------------------------------------------
-DataType::DataType(const hid_t existing_id) : H5Object()
+DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
@@ -136,9 +135,8 @@ DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type,
///\brief Copy constructor: makes a copy of the original DataType object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataType::DataType(const DataType& original) : H5Object()
+DataType::DataType(const DataType& original) : H5Object(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index 1ca059b..270b232 100644
--- a/c++/src/H5Exception.cpp
+++ b/c++/src/H5Exception.cpp
@@ -47,11 +47,7 @@ Exception::Exception(const H5std_string& func, const H5std_string& message) : de
///\param orig - IN: Exception instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Exception::Exception( const Exception& orig )
-{
- detail_message = orig.detail_message;
- func_name = orig.func_name;
-}
+Exception::Exception( const Exception& orig ) : detail_message(orig.detail_message), func_name(orig.func_name) {}
//--------------------------------------------------------------------------
// Function: Exception::getMajorString
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index 0823d0e..f9aabcb 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -60,9 +60,8 @@ Group::Group() : H5Object(), CommonFG(), id(H5I_INVALID_HID) {}
///\param original - IN: Original group to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group::Group(const Group& original) : H5Object(), CommonFG()
+Group::Group(const Group& original) : H5Object(), CommonFG(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
@@ -83,9 +82,8 @@ hid_t Group::getLocId() const
///\param existing_id - IN: Id of an existing group
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group::Group(const hid_t existing_id) : H5Object(), CommonFG()
+Group::Group(const hid_t existing_id) : H5Object(), CommonFG(), id(existing_id)
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 807aa0a..81bb023 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -104,9 +104,8 @@ PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {}
///\param original - IN: The original property list to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList::PropList(const PropList& original) : IdComponent()
+PropList::PropList(const PropList& original) : IdComponent(), id(original.id)
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}