diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2008-07-27 21:48:11 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2008-07-27 21:48:11 (GMT) |
commit | 4c280b326676380411eecedd03288bd335372565 (patch) | |
tree | 311041f55fc0d6a5329c5a443db088f25bfb3dbc /c++/src/H5DataSpace.cpp | |
parent | c0ab5a9098d07c4eaa83be17f6a99082b32c3923 (diff) | |
download | hdf5-4c280b326676380411eecedd03288bd335372565.zip hdf5-4c280b326676380411eecedd03288bd335372565.tar.gz hdf5-4c280b326676380411eecedd03288bd335372565.tar.bz2 |
[svn-r15412] 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.
Also change changed subclasses' setId to p_setId for internal uses,
and added setId to IdComponent for public API.
Platforms tested:
SunOS 5.10 (linew)
Linux 2.6 (kagiso)
FreeBSD (duty)
Diffstat (limited to 'c++/src/H5DataSpace.cpp')
-rw-r--r-- | c++/src/H5DataSpace.cpp | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index e5ef816..e755685 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,7 @@ 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 +90,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 +552,47 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h } //-------------------------------------------------------------------------- +// Function: DataSpace::getId +// Purpose: Get the id of this dataspace +// 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 dataspace to a new value. +/// +///\exception H5::IdComponentException when the attempt to close the +/// currently open dataspace 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 GroupIException("DataSpace::p_setId", close_error.getDetailMsg()); + } + // reset object's id to the given id + id = new_id; +} + +//-------------------------------------------------------------------------- // Function: DataSpace::close ///\brief Closes this dataspace. /// |