summaryrefslogtreecommitdiffstats
path: root/c++/src/H5DataSet.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-02 14:56:42 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-02 14:56:42 (GMT)
commite5df9bb33aa8b88bd0df21479942c1156ffd52aa (patch)
tree48c4dc2f0e08512addab592c0306fa57ded0898a /c++/src/H5DataSet.cpp
parentd9533d055c7f306e66e5f972068c77c939d6fc16 (diff)
downloadhdf5-e5df9bb33aa8b88bd0df21479942c1156ffd52aa.zip
hdf5-e5df9bb33aa8b88bd0df21479942c1156ffd52aa.tar.gz
hdf5-e5df9bb33aa8b88bd0df21479942c1156ffd52aa.tar.bz2
[svn-r15309] Purpose: Fixed bugs
Description: The class hierarchy was revised to address the problem reported in bugzilla #1068. Classes AbstractDS and Attribute are moved out of H5Object. Class Attribute now multiply inherits from IdComponent and AbstractDs and class DataSet from H5Object and AbstractDs. In addition, data member IdComponent::id was moved into subclasses: Attribute, DataSet, DataSpace, DataType, H5File, Group, and PropList. Platforms tested: SunOS 5.10 (linew) Linux 2.6 (kagiso) FreeBSD (duty)
Diffstat (limited to 'c++/src/H5DataSet.cpp')
-rw-r--r--c++/src/H5DataSet.cpp115
1 files changed, 64 insertions, 51 deletions
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index 9858e7d..be80949 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -28,10 +28,13 @@
#include "H5PropList.h"
#include "H5DxferProp.h"
#include "H5DcreatProp.h"
+#include "H5FaccProp.h"
+#include "H5FcreatProp.h"
#include "H5CommonFG.h"
#include "H5DataType.h"
#include "H5DataSpace.h"
#include "H5AbstractDs.h"
+#include "H5File.h"
#include "H5DataSet.h"
#ifndef H5_NO_NAMESPACE
@@ -47,7 +50,7 @@ namespace H5 {
///\brief Default constructor: creates a stub DataSet.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSet::DataSet() : AbstractDs() {}
+DataSet::DataSet() : AbstractDs(), H5Object(), id(0) {}
//--------------------------------------------------------------------------
// Function: DataSet overloaded constructor
@@ -55,7 +58,10 @@ DataSet::DataSet() : AbstractDs() {}
///\param existing_id - IN: Id of an existing dataset
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSet::DataSet(const hid_t existing_id) : AbstractDs(existing_id) {}
+DataSet::DataSet(const hid_t existing_id) : AbstractDs(), H5Object()
+{
+ id = existing_id;
+}
//--------------------------------------------------------------------------
// Function: DataSet copy constructor
@@ -63,7 +69,12 @@ DataSet::DataSet(const hid_t existing_id) : AbstractDs(existing_id) {}
///\param original - IN: DataSet instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSet::DataSet( const DataSet& original ) : AbstractDs( original ) {}
+DataSet::DataSet(const DataSet& original) : AbstractDs(original), H5Object()
+{
+ id = original.getId();
+ incRefCount(); // increment number of references to this id
+
+}
//--------------------------------------------------------------------------
// Function: DataSet overload constructor - dereference
@@ -77,9 +88,14 @@ DataSet::DataSet( const DataSet& original ) : AbstractDs( original ) {}
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
-DataSet::DataSet(IdComponent& obj, void* ref) : AbstractDs()
+DataSet::DataSet(H5Object& obj, void* ref) : AbstractDs(), H5Object()
{
- IdComponent::dereference(obj, ref);
+ id = obj.p_dereference(ref);
+}
+
+DataSet::DataSet(H5File& h5file, void* ref) : AbstractDs(), H5Object()
+{
+ id = h5file.p_dereference(ref);
}
//--------------------------------------------------------------------------
@@ -455,52 +471,6 @@ void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space)
}
}
-//--------------------------------------------------------------------------
-// Function: DataSet::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use
-/// DataSet::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* DataSet::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const
-{
- try {
- return(p_reference(name, dataspace.getId(), ref_type));
- }
- catch (IdComponentException E) {
- throw DataSetIException("DataSet::Reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: DataSet::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// DataSet::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* DataSet::Reference(const char* name) const
-{
- try {
- return(p_reference(name, -1, H5R_OBJECT));
- }
- catch (IdComponentException E) {
- throw DataSetIException("DataSet::Reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: DataSet::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// DataSet::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* DataSet::Reference(const H5std_string& name) const
-{
- return(Reference(name.c_str()));
-}
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
//--------------------------------------------------------------------------
// Function: DataSet::getObjType
@@ -550,6 +520,49 @@ DataSpace DataSet::getRegion(void *ref, H5R_type_t ref_type) const
}
//--------------------------------------------------------------------------
+// Function: DataSet::getId
+// Purpose: Get the id of this attribute
+// Description:
+// Class hierarchy is revised to address bugzilla 1068. Class
+// AbstractDs and Attribute are moved out of H5Object. In
+// addition, member IdComponent::id is moved into subclasses, and
+// IdComponent::getId now becomes pure virtual function.
+// Programmer Binh-Minh Ribler - May, 2008
+//--------------------------------------------------------------------------
+hid_t DataSet::getId() const
+{
+ return(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: DataSet::setId
+///\brief Sets the identifier of this object to a new value.
+///
+///\exception H5::IdComponentException when the attempt to close the HDF5
+/// object fails
+// Description:
+// The underlaying reference counting in the C library ensures
+// that the current valid id of this object is properly closed.
+// Then the object's id is reset to the new id.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+void DataSet::setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception close_error) {
+ throw DataSetIException(inMemFunc("setId"), close_error.getDetailMsg());
+ }
+ // reset object's id to the given id
+ id = new_id;
+
+ // increment the reference counter of the new id
+ incRefCount();
+}
+
+//--------------------------------------------------------------------------
// Function: DataSet::close
///\brief Closes this dataset.
///