summaryrefslogtreecommitdiffstats
path: root/c++/src/H5ArrayType.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++/src/H5ArrayType.cpp')
-rw-r--r--c++/src/H5ArrayType.cpp38
1 files changed, 38 insertions, 0 deletions
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.