summaryrefslogtreecommitdiffstats
path: root/c++/src/H5DataSpace.cpp
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-10-21 19:10:01 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-10-21 19:10:01 (GMT)
commit27ae4bccfd866a9bf334dc191631499d3cea1b19 (patch)
tree828abaa9099bc36b176c8440f0d905ae267d5b02 /c++/src/H5DataSpace.cpp
parent22378dbd24c08d7153f4f295b5bca057191edc38 (diff)
downloadhdf5-27ae4bccfd866a9bf334dc191631499d3cea1b19.zip
hdf5-27ae4bccfd866a9bf334dc191631499d3cea1b19.tar.gz
hdf5-27ae4bccfd866a9bf334dc191631499d3cea1b19.tar.bz2
[svn-r15922] Description:
Bring revisions 15289:15457 from trunk into metadata journaling branch. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.5.2 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'c++/src/H5DataSpace.cpp')
-rw-r--r--c++/src/H5DataSpace.cpp65
1 files changed, 57 insertions, 8 deletions
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 245e27d..3d74b51 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -47,7 +47,7 @@ const DataSpace DataSpace::ALL( H5S_ALL );
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace( H5S_class_t type ) : IdComponent(0)
+DataSpace::DataSpace(H5S_class_t type) : IdComponent()
{
id = H5Screate( type );
if( id < 0 )
@@ -65,7 +65,7 @@ DataSpace::DataSpace( H5S_class_t type ) : IdComponent(0)
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent(0)
+DataSpace::DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims) : IdComponent()
{
id = H5Screate_simple( rank, dims, maxdims );
if( id < 0 )
@@ -82,7 +82,10 @@ 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(existing_id) {}
+DataSpace::DataSpace(const hid_t existing_id) : IdComponent()
+{
+ id = existing_id;
+}
//--------------------------------------------------------------------------
// Function: DataSpace copy constructor
@@ -90,7 +93,11 @@ DataSpace::DataSpace(const hid_t existing_id) : IdComponent(existing_id) {}
///\param original - IN: DataSpace object to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace( const DataSpace& original ) : IdComponent( original ) {}
+DataSpace::DataSpace(const DataSpace& original) : IdComponent(original)
+{
+ id = original.getId();
+ incRefCount(); // increment number of references to this id
+}
//--------------------------------------------------------------------------
// Function: DataSpace::copy
@@ -548,6 +555,47 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h
}
//--------------------------------------------------------------------------
+// Function: DataSpace::getId
+// Purpose: Get the id of this attribute
+// Modification:
+// May 2008 - BMR
+// 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 DataSpace::getId() const
+{
+ return(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: DataSpace::p_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 DataSpace::p_setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception close_error) {
+ throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg());
+ }
+ // reset object's id to the given id
+ id = new_id;
+}
+
+//--------------------------------------------------------------------------
// Function: DataSpace::close
///\brief Closes this dataspace.
///
@@ -564,8 +612,10 @@ void DataSpace::close()
{
throw DataSpaceIException("DataSpace::close", "H5Sclose failed");
}
- // reset the id because the dataspace that it represents is now closed
- id = 0;
+ // reset the id when the dataspace that it represents is no longer
+ // referenced
+ if (getCounter() == 0)
+ id = 0;
}
}
@@ -583,8 +633,7 @@ DataSpace::~DataSpace()
{
try {
close();
- }
- catch (Exception close_error) {
+ } catch (Exception close_error) {
cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl;
}
}