summaryrefslogtreecommitdiffstats
path: root/c++
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++
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++')
-rw-r--r--c++/src/H5AbstractDs.cpp12
-rw-r--r--c++/src/H5Attribute.cpp100
-rw-r--r--c++/src/H5CommonFG.cpp33
-rw-r--r--c++/src/H5DataSet.cpp115
-rw-r--r--c++/src/H5DataSpace.cpp74
-rw-r--r--c++/src/H5DataType.cpp133
-rw-r--r--c++/src/H5DcreatProp.cpp2
-rw-r--r--c++/src/H5File.cpp241
-rw-r--r--c++/src/H5Group.cpp108
-rw-r--r--c++/src/H5IdComponent.cpp200
-rw-r--r--c++/src/H5Object.cpp194
-rw-r--r--c++/src/H5PropList.cpp53
12 files changed, 864 insertions, 401 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp
index 7cb170d..a61cc88 100644
--- a/c++/src/H5AbstractDs.cpp
+++ b/c++/src/H5AbstractDs.cpp
@@ -34,21 +34,21 @@ namespace H5 {
///\brief Default constructor
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-AbstractDs::AbstractDs() : H5Object() {}
+AbstractDs::AbstractDs(){}
//--------------------------------------------------------------------------
// Function: AbstractDs default constructor
///\brief Creates an AbstractDs instance using an existing id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-AbstractDs::AbstractDs( const hid_t ds_id ) : H5Object( ds_id ) {}
+AbstractDs::AbstractDs(const hid_t ds_id){}
//--------------------------------------------------------------------------
// Function: AbstractDs copy constructor
///\brief Copy constructor: makes a copy of the original AbstractDs object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-AbstractDs::AbstractDs( const AbstractDs& original ) : H5Object( original ) {}
+AbstractDs::AbstractDs(const AbstractDs& original){}
//--------------------------------------------------------------------------
// Function: AbstractDs::getTypeClass
@@ -80,8 +80,10 @@ H5T_class_t AbstractDs::getTypeClass() const
return( type_class );
else
{
- throw DataTypeIException(inMemFunc("getTypeClass"),
- "H5Tget_class returns H5T_NO_CLASS");
+ if (fromClass() == "DataSet")
+ throw DataTypeIException("DataSet::getTypeClass", "H5Tget_class returns H5T_NO_CLASS");
+ else if (fromClass() == "Attribute")
+ throw DataTypeIException("Attribute::getTypeClass", "H5Tget_class returns H5T_NO_CLASS");
}
}
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 043dc4d..87521e1 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -26,12 +26,14 @@
#include "H5PropList.h"
#include "H5Object.h"
#include "H5AbstractDs.h"
-#include "H5Attribute.h"
+#include "H5FaccProp.h"
+#include "H5FcreatProp.h"
#include "H5DcreatProp.h"
#include "H5CommonFG.h"
#include "H5DataType.h"
#include "H5DataSpace.h"
-#include "H5private.h"
+#include "H5File.h"
+#include "H5Attribute.h"
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -46,7 +48,7 @@ namespace H5 {
///\brief Default constructor: Creates a stub attribute
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
-Attribute::Attribute() : AbstractDs() {}
+Attribute::Attribute() : AbstractDs(), IdComponent(), id(0) {}
//--------------------------------------------------------------------------
// Function: Attribute copy constructor
@@ -54,7 +56,11 @@ Attribute::Attribute() : AbstractDs() {}
///\param original - IN: Original Attribute object to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Attribute::Attribute( const Attribute& original ) : AbstractDs( original ) {}
+Attribute::Attribute(const Attribute& original) : AbstractDs(), IdComponent()
+{
+ id = original.getId();
+ incRefCount(); // increment number of references to this id
+}
//--------------------------------------------------------------------------
// Function: Attribute overloaded constructor
@@ -64,7 +70,10 @@ Attribute::Attribute( const Attribute& original ) : AbstractDs( original ) {}
///\exception H5::AttributeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Attribute::Attribute(const hid_t existing_id) : AbstractDs(existing_id) {}
+Attribute::Attribute(const hid_t existing_id) : AbstractDs(), IdComponent()
+{
+ id = existing_id;
+}
//--------------------------------------------------------------------------
// Function: Attribute::write
@@ -208,6 +217,23 @@ hid_t Attribute::p_get_type() const
}
//--------------------------------------------------------------------------
+// Function: Attribute::getFileName
+///\brief Gets the name of the file, in which this attribute belongs.
+///\return File name
+///\exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - Jul, 2004
+//--------------------------------------------------------------------------
+H5std_string Attribute::getFileName() const
+{
+ try {
+ return(p_get_file_name());
+ }
+ catch (IdComponentException E) {
+ throw FileIException("Attribute::getFileName", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
// Function: Attribute::getName
///\brief Gets the name of this attribute, returning its length.
///\param buf_size - IN: Desired length of the name
@@ -297,6 +323,70 @@ hsize_t Attribute::getStorageSize() const
}
//--------------------------------------------------------------------------
+// Function: Attribute::dereference
+// Purpose Dereference a ref into a DataSet object.
+// Parameters
+// ref - IN: Reference pointer
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// May 2008 - BMR
+// Moved from IdComponent into H5File, H5Object, and Attribute
+//--------------------------------------------------------------------------
+Attribute::Attribute(H5Object& obj, void* ref) : AbstractDs(), IdComponent()
+{
+ id = obj.p_dereference(ref);
+}
+
+Attribute::Attribute(H5File& h5file, void* ref) : AbstractDs(), IdComponent()
+{
+ id = h5file.p_dereference(ref);
+}
+
+//--------------------------------------------------------------------------
+// Function: Attribute::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 Attribute::getId() const
+{
+ return(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: Attribute::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 Attribute::setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception close_error) {
+ throw AttributeIException("Attribute::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: Attribute::close
///\brief Closes this attribute.
///
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 8386e03..364f639 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -15,6 +15,11 @@
#include <string>
+// remove when done
+#include <iostream>
+ using std::cerr;
+ using std::endl;
+
#include "H5Include.h"
#include "H5Exception.h"
#include "H5IdComponent.h"
@@ -239,7 +244,13 @@ DataSet CommonFG::openDataSet( const H5std_string& name ) const
///\par Description
/// Note that both names are interpreted relative to the
/// specified location.
+/// For information on creating hard link and soft link, please
+/// refer to the C layer Reference Manual at:
+/// http://hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-CreateHard and
+/// http://hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-CreateSoft
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// 2007: QAK modified to use H5L APIs - BMR
//--------------------------------------------------------------------------
void CommonFG::link( H5L_type_t link_type, const char* curr_name, const char* new_name ) const
{
@@ -283,6 +294,8 @@ void CommonFG::link( H5L_type_t link_type, const H5std_string& curr_name, const
///\param name - IN: Name of the object to be removed
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// 2007: QAK modified to use H5L APIs - BMR
//--------------------------------------------------------------------------
void CommonFG::unlink( const char* name ) const
{
@@ -317,6 +330,8 @@ void CommonFG::unlink( const H5std_string& name ) const
/// to the Group Interface in the HDF5 User's Guide at:
/// http://hdf.ncsa.uiuc.edu/HDF5/doc/Groups.html
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// 2007: QAK modified to use H5L APIs - BMR
//--------------------------------------------------------------------------
void CommonFG::move( const char* src, const char* dst ) const
{
@@ -380,6 +395,7 @@ void CommonFG::getObjinfo( const H5std_string& name, hbool_t follow_link, H5G_st
/// It differs from the above functions in that it doesn't have
/// the paramemter \a follow_link.
// Programmer Binh-Minh Ribler - Nov, 2005
+// Note: need to modify to use H5Oget_info and H5Lget_info - BMR
//--------------------------------------------------------------------------
void CommonFG::getObjinfo( const char* name, H5G_stat_t& statbuf ) const
{
@@ -452,6 +468,11 @@ H5std_string CommonFG::getLinkval( const H5std_string& name, size_t size ) const
/// object header, e.g., data sets, groups, named data types,
/// and data spaces, but not symbolic links.
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// 2007: QAK modified to use H5O APIs; however the first parameter is
+// no longer just file or group, this function should be moved
+// to another class to accommodate attribute, dataset, and named
+// datatype. - BMR
//--------------------------------------------------------------------------
void CommonFG::setComment( const char* name, const char* comment ) const
{
@@ -480,6 +501,10 @@ void CommonFG::setComment( const H5std_string& name, const H5std_string& comment
///\param name - IN: Name of the object
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - May 2005
+// 2007: QAK modified to use H5O APIs; however the first parameter is
+// no longer just file or group, this function should be moved
+// to another class to accommodate attribute, dataset, and named
+// datatype. - BMR
//--------------------------------------------------------------------------
void CommonFG::removeComment(const char* name) const
{
@@ -509,6 +534,10 @@ void CommonFG::removeComment(const H5std_string& name) const
///\return Comment string
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - May 2005
+// 2007: QAK modified to use H5O APIs; however the first parameter is
+// no longer just file or group, this function should be moved
+// to another class to accommodate attribute, dataset, and named
+// datatype. - BMR
//--------------------------------------------------------------------------
H5std_string CommonFG::getComment (const H5std_string& name) const
{
@@ -549,6 +578,10 @@ H5std_string CommonFG::getComment (const H5std_string& name) const
///\return Comment string
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - 2000
+// 2007: QAK modified to use H5O APIs; however the first parameter is
+// no longer just file or group, this function should be moved
+// to another class to accommodate attribute, dataset, and named
+// datatype. - BMR
//--------------------------------------------------------------------------
H5std_string CommonFG::getComment( const char* name, size_t bufsize ) const
{
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.
///
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 245e27d..adeb2db 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,50 @@ 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::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::setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception close_error) {
+ throw DataSpaceIException(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: DataSpace::close
///\brief Closes this dataspace.
///
@@ -581,11 +632,16 @@ void DataSpace::close()
//--------------------------------------------------------------------------
DataSpace::~DataSpace()
{
- try {
- close();
- }
- catch (Exception close_error) {
- cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl;
+ int counter = getCounter(id);
+ if (counter > 1)
+ decRefCount(id);
+ else if (counter == 1)
+ {
+ try {
+ close();
+ } catch (Exception close_error) {
+ cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl;
+ }
}
}
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index c31395e..592d800 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -62,7 +62,10 @@ namespace H5 {
// - BMR 5/2004
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataType::DataType(const hid_t existing_id) : H5Object(existing_id) {}
+DataType::DataType(const hid_t existing_id) : H5Object()
+{
+ id = existing_id;
+}
//--------------------------------------------------------------------------
// Function: DataType overloaded constructor
@@ -92,9 +95,19 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object()
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
-DataType::DataType(IdComponent& obj, void* ref) : H5Object()
+ /* DataType::DataType(IdComponent& obj, void* ref) : H5Object()
+{
+ H5Object::dereference(obj, ref);
+}
+ */
+DataType::DataType(H5Object& obj, void* ref) : H5Object()
{
- IdComponent::dereference(obj, ref);
+ id = obj.p_dereference(ref);
+}
+
+DataType::DataType(H5File& file, void* ref) : H5Object()
+{
+ id = file.p_dereference(ref);
}
//--------------------------------------------------------------------------
@@ -102,14 +115,18 @@ DataType::DataType(IdComponent& obj, void* ref) : H5Object()
///\brief Default constructor: Creates a stub datatype
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataType::DataType() : H5Object() {}
+DataType::DataType() : H5Object(), id(0) {}
//--------------------------------------------------------------------------
// Function: DataType copy constructor
///\brief Copy constructor: makes a copy of the original DataType object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataType::DataType(const DataType& original) : H5Object(original) {}
+DataType::DataType(const DataType& original) : H5Object(original)
+{
+ id = original.getId();
+ incRefCount(); // increment number of references to this id
+}
//--------------------------------------------------------------------------
// Function: DataType::copy
@@ -616,52 +633,6 @@ bool DataType::isVariableStr() const
}
}
-//--------------------------------------------------------------------------
-// Function: DataType::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// DataType::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* DataType::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 DataTypeIException(inMemFunc("Reference"), E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: DataType::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// DataType::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* DataType::Reference(const char* name) const
-{
- try {
- return(p_reference(name, -1, H5R_OBJECT));
- }
- catch (IdComponentException E) {
- throw DataTypeIException(inMemFunc("Reference"), E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: DataType::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// DataType::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* DataType::Reference(const H5std_string& name) const
-{
- return(Reference(name.c_str()));
-}
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
//--------------------------------------------------------------------------
// Function: DataType::getObjType
@@ -708,6 +679,50 @@ DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const
}
//--------------------------------------------------------------------------
+// Function: DataType::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 DataType::getId() const
+{
+ return(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: DataType::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 DataType::setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception close_error) {
+ throw DataTypeIException(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: DataType::close
///\brief Closes the datatype if it is not a predefined type.
///
@@ -740,14 +755,20 @@ void DataType::close()
//--------------------------------------------------------------------------
DataType::~DataType()
{
- try {
- close();
+ int counter = getCounter(id);
+ if (counter > 1)
+ {
+ decRefCount(id);
}
- catch (Exception close_error) {
- cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl;
+ else if (counter == 1)
+ {
+ try {
+ close();
+ } catch (Exception close_error) {
+ cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl;
+ }
}
}
-
#ifndef H5_NO_NAMESPACE
} // end namespace
#endif
diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp
index e524355..19a4e6e 100644
--- a/c++/src/H5DcreatProp.cpp
+++ b/c++/src/H5DcreatProp.cpp
@@ -54,7 +54,7 @@ DSetCreatPropList::DSetCreatPropList( const DSetCreatPropList& orig ) : PropList
/// existing dataset creation property list.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : PropList( plist_id ) {}
+DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : PropList(plist_id) {}
//--------------------------------------------------------------------------
// Function: DSetCreatPropList::setChunk
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index aa11e31..9f8e45f 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -50,7 +50,7 @@ namespace H5 {
///\brief Default constructor: creates a stub H5File object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File() : IdComponent(0) {}
+H5File::H5File() : IdComponent(), id(0) {}
//--------------------------------------------------------------------------
// Function: H5File overloaded constructor
@@ -140,7 +140,11 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro
///\param original - IN: H5File instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File( const H5File& original ) : IdComponent( original ) {}
+H5File::H5File(const H5File& original) : IdComponent(original)
+{
+ id = original.getId();
+ incRefCount(); // increment number of references to this id
+}
//--------------------------------------------------------------------------
// Function: H5File::flush
@@ -502,52 +506,6 @@ H5std_string H5File::getFileName() const
}
}
-//--------------------------------------------------------------------------
-// Function: H5File::Reference
-///\brief Important!!! - This functions does not work correctly, it
-/// will be removed in the near future. Please use
-/// H5File::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* H5File::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 FileIException("H5File::Reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5File::Reference
-///\brief Important!!! - This functions does not work correctly, it
-/// will be removed in the near future. Please use similar
-/// H5File::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* H5File::Reference(const char* name) const
-{
- try {
- return(p_reference(name, -1, H5R_OBJECT));
- }
- catch (IdComponentException E) {
- throw FileIException("H5File::Reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5File::Reference
-///\brief Important!!! - This functions does not work correctly, it
-/// will be removed in the near future. Please use similar
-/// H5File::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* H5File::Reference(const H5std_string& name) const
-{
- return(Reference(name.c_str()));
-}
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
//--------------------------------------------------------------------------
// Function: H5File::getObjType
@@ -617,6 +575,134 @@ hsize_t H5File::getFileSize() const
}
//--------------------------------------------------------------------------
+// Function: H5File::p_reference (protected)
+// Purpose Creates a reference to an HDF5 object or a dataset region.
+// Parameters
+// name - IN: Name of the object to be referenced
+// dataspace - IN: Dataspace with selection
+// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5File::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const
+{
+ herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id);
+ if (ret_value < 0)
+ {
+ throw IdComponentException("", "H5Rcreate failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5File::reference
+///\brief Creates a reference to an HDF5 object or a dataset region.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced
+///\param dataspace - IN: Dataspace with selection
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT \tReference is an object reference.
+/// \li \c H5R_DATASET_REGION \tReference is a dataset region
+/// reference. - this is the default
+///\exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5File::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const
+{
+ try {
+ p_reference(ref, name, dataspace.getId(), ref_type);
+ }
+ catch (IdComponentException E) {
+ throw IdComponentException("H5File::reference", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5File::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it only creates
+/// a reference to an HDF5 object, not to a dataset region.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced - \c char pointer
+///\exception H5::IdComponentException
+///\par Description
+// This function passes H5R_OBJECT and -1 to the protected
+// function for it to pass to the C API H5Rcreate
+// to create a reference to the named object.
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5File::reference(void* ref, const char* name) const
+{
+ try {
+ p_reference(ref, name, -1, H5R_OBJECT);
+ }
+ catch (IdComponentException E) {
+ throw IdComponentException("H5File::reference", E.getDetailMsg());
+ }
+}
+//--------------------------------------------------------------------------
+// Function: H5File::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it takes an
+/// \c std::string for the object's name.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced - \c std::string
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5File::reference(void* ref, const H5std_string& name) const
+{
+ reference(ref, name.c_str());
+}
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+//--------------------------------------------------------------------------
+// Function: H5File::p_get_obj_type (protected)
+// Purpose Retrieves the type of object that an object reference points to.
+// Parameters
+// ref - IN: Reference to query
+// ref_type - IN: Type of reference to query
+// Return An object type, which can be one of the following:
+// H5G_LINK Object is a symbolic link.
+// H5G_GROUP Object is a group.
+// H5G_DATASET Object is a dataset.
+// H5G_TYPE Object is a named datatype
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+H5G_obj_t H5File::p_get_obj_type(void *ref, H5R_type_t ref_type) const
+{
+ H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref);
+
+ if (obj_type == H5G_UNKNOWN)
+ {
+ throw IdComponentException("", "H5Rget_obj_type failed");
+ }
+ return(obj_type);
+}
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+
+//--------------------------------------------------------------------------
+// Function: H5File::p_get_region (protected)
+// Purpose Retrieves a dataspace with the region pointed to selected.
+// Parameters
+// ref_type - IN: Type of reference to get region of - default
+// to H5R_DATASET_REGION
+// ref - IN: Reference to get region of
+// Return Dataspace id
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+hid_t H5File::p_get_region(void *ref, H5R_type_t ref_type) const
+{
+ hid_t space_id = H5Rget_region(getId(), ref_type, ref);
+ if (space_id < 0)
+ {
+ throw IdComponentException("", "H5Rget_region failed");
+ }
+ return(space_id);
+}
+
+//--------------------------------------------------------------------------
// Function: H5File::getLocId
// Purpose: Get the id of this file
// Description
@@ -630,6 +716,50 @@ hid_t H5File::getLocId() const
}
//--------------------------------------------------------------------------
+// Function: H5File::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 H5File::getId() const
+{
+ return(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: H5File::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 H5File::setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception E) {
+ throw FileIException("H5File::setId", E.getDetailMsg());
+ }
+ // reset object's id to the given id
+ id = new_id;
+
+ // increment the reference counter of the new id
+ incRefCount();
+}
+
+//--------------------------------------------------------------------------
// Function: H5File::close
///\brief Closes this HDF5 file.
///
@@ -683,11 +813,18 @@ void H5File::throwException(const H5std_string& func_name, const H5std_string& m
//--------------------------------------------------------------------------
H5File::~H5File()
{
- try {
- close();
+ int counter = getCounter(id);
+ if (counter > 1)
+ {
+ decRefCount(id);
}
- catch (Exception close_error) {
- cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl;
+ else if (counter == 1)
+ {
+ try {
+ close();
+ } catch (Exception close_error) {
+ cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl;
+ }
}
}
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index f3c058a..7ab3b61 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -50,7 +50,7 @@ namespace H5 {
///\brief Default constructor: creates a stub Group.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group::Group() : H5Object() {}
+Group::Group() : H5Object(), id(0) {}
//--------------------------------------------------------------------------
// Function: Group copy constructor
@@ -58,7 +58,11 @@ Group::Group() : H5Object() {}
///\param original - IN: Original group to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group::Group( const Group& original ) : H5Object( original ) {}
+Group::Group(const Group& original) : H5Object(original)
+{
+ id = original.getId();
+ incRefCount(); // increment number of references to this id
+}
//--------------------------------------------------------------------------
// Function: Group::getLocId
@@ -77,7 +81,10 @@ hid_t Group::getLocId() const
///\param group_id - IN: Id of an existing group
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group::Group( const hid_t group_id ) : H5Object( group_id ) {}
+Group::Group(const hid_t existing_id) : H5Object()
+{
+ id = existing_id;
+}
//--------------------------------------------------------------------------
// Function: Group overload constructor - dereference
@@ -89,55 +96,14 @@ Group::Group( const hid_t group_id ) : H5Object( group_id ) {}
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
-Group::Group(IdComponent& obj, void* ref) : H5Object()
+Group::Group(H5Object& obj, void* ref) : H5Object()
{
- IdComponent::dereference(obj, ref);
-}
-
-//--------------------------------------------------------------------------
-// Function: Group::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// Group::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* Group::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 GroupIException("Group::Reference", E.getDetailMsg());
- }
+ id = obj.p_dereference(ref);
}
-//--------------------------------------------------------------------------
-// Function: Group::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// Group::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* Group::Reference(const char* name) const
+Group::Group(H5File& h5file, void* ref) : H5Object()
{
- try {
- return(p_reference(name, -1, H5R_OBJECT));
- }
- catch (IdComponentException E) {
- throw GroupIException("Group::Reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: Group::Reference
-///\brief Important!!! - This functions may not work correctly, it
-/// will be removed in the near future. Please use similar
-/// Group::reference instead!
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void* Group::Reference(const H5std_string& name) const
-{
- return(Reference(name.c_str()));
+ id = h5file.p_dereference(ref);
}
#ifndef H5_NO_DEPRECATED_SYMBOLS
@@ -188,6 +154,50 @@ DataSpace Group::getRegion(void *ref, H5R_type_t ref_type) const
}
//--------------------------------------------------------------------------
+// Function: Group::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 Group::getId() const
+{
+ return(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: Group::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 Group::setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception close_error) {
+ throw GroupIException("Group::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: Group::close
///\brief Closes this group.
///
@@ -196,6 +206,8 @@ DataSpace Group::getRegion(void *ref, H5R_type_t ref_type) const
//--------------------------------------------------------------------------
void Group::close()
{
+ /* cerr << "Group::close/p_valid_id" << endl;
+ */
if (p_valid_id(id))
{
herr_t ret_value = H5Gclose( id );
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index bb015fb..fa2f3db 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -18,7 +18,6 @@
#endif /*H5_VMS*/
#include <string>
-
#include "H5Include.h"
#include "H5Exception.h"
#include "H5Library.h"
@@ -36,7 +35,7 @@ namespace H5 {
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-IdComponent::IdComponent(const hid_t h5_id) : id(h5_id) {}
+IdComponent::IdComponent(const hid_t h5_id) {}
//--------------------------------------------------------------------------
// Function: IdComponent copy constructor
@@ -44,11 +43,7 @@ IdComponent::IdComponent(const hid_t h5_id) : id(h5_id) {}
///\param original - IN: IdComponent instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-IdComponent::IdComponent( const IdComponent& original )
-{
- id = original.id;
- incRefCount(); // increment number of references to this id
-}
+IdComponent::IdComponent( const IdComponent& original ) {}
//--------------------------------------------------------------------------
// Function: IdComponent::incRefCount
@@ -69,7 +64,7 @@ void IdComponent::incRefCount(const hid_t obj_id) const
//--------------------------------------------------------------------------
void IdComponent::incRefCount() const
{
- incRefCount(id);
+ incRefCount(getId());
}
//--------------------------------------------------------------------------
@@ -99,7 +94,7 @@ void IdComponent::decRefCount(const hid_t obj_id) const
//--------------------------------------------------------------------------
void IdComponent::decRefCount() const
{
- decRefCount(id);
+ decRefCount(getId());
}
//--------------------------------------------------------------------------
@@ -128,7 +123,7 @@ int IdComponent::getCounter(const hid_t obj_id) const
//--------------------------------------------------------------------------
int IdComponent::getCounter() const
{
- return (getCounter(id));
+ return (getCounter(getId()));
}
//--------------------------------------------------------------------------
@@ -173,7 +168,7 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
if (this != &rhs)
{
// handling references to this id
- try {
+ try {
close();
}
catch (Exception close_error) {
@@ -181,10 +176,9 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
}
// copy the data members from the rhs object
- id = rhs.id;
-
- // increment the reference counter
- incRefCount();
+ setId(rhs.getId());
+ /* id = rhs.id;
+ */
}
return *this;
}
@@ -201,6 +195,7 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
+#if 0
void IdComponent::setId(const hid_t new_id)
{
// handling references to this old id
@@ -212,11 +207,14 @@ void IdComponent::setId(const hid_t new_id)
}
// reset object's id to the given id
- id = new_id;
+ /* id = new_id;
+ */
+ setId(new_id);
// increment the reference counter of the new id
incRefCount();
}
+#endif
//--------------------------------------------------------------------------
// Function: IdComponent::getId
@@ -224,10 +222,12 @@ void IdComponent::setId(const hid_t new_id)
///\return HDF5 id
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
+/*
hid_t IdComponent::getId () const
{
return(id);
}
+*/
//--------------------------------------------------------------------------
// Function: IdComponent destructor
@@ -273,7 +273,10 @@ H5std_string IdComponent::inMemFunc(const char* func_name) const
///\brief Default constructor.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-IdComponent::IdComponent() : id(-1) {}
+IdComponent::IdComponent() {
+ /* setId(-1);
+ */
+}
//--------------------------------------------------------------------------
// Function: IdComponent::p_get_file_name (protected)
@@ -287,8 +290,10 @@ IdComponent::IdComponent() : id(-1) {}
//--------------------------------------------------------------------------
H5std_string IdComponent::p_get_file_name() const
{
+ hid_t temp_id = getId();
+
// Preliminary call to H5Fget_name to get the length of the file name
- ssize_t name_size = H5Fget_name(id, NULL, 0);
+ ssize_t name_size = H5Fget_name(temp_id, NULL, 0);
// If H5Aget_name returns a negative value, raise an exception,
if( name_size < 0 )
@@ -298,7 +303,7 @@ H5std_string IdComponent::p_get_file_name() const
// Call H5Fget_name again to get the actual file name
char* name_C = new char[name_size+1]; // temporary C-string for C API
- name_size = H5Fget_name(id, name_C, name_size+1);
+ name_size = H5Fget_name(temp_id, name_C, name_size+1);
// Check for failure again
if( name_size < 0 )
@@ -313,83 +318,21 @@ H5std_string IdComponent::p_get_file_name() const
}
//--------------------------------------------------------------------------
-// Function: IdComponent::p_reference (protected)
-// Purpose Creates a reference to an HDF5 object or a dataset region.
+// Function: H5Object::p_dereference (protected)
+// Purpose Opens the HDF5 object referenced.
// Parameters
-// name - IN: Name of the object to be referenced
-// dataspace - IN: Dataspace with selection
-// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
+// ref - IN: Reference pointer
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
-void IdComponent::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const
+hid_t IdComponent::p_dereference(void* ref)
{
- herr_t ret_value = H5Rcreate(ref, id, name, ref_type, space_id);
- if (ret_value < 0)
+ hid_t temp_id = H5Rdereference(getId(), H5R_OBJECT, ref);
+ if (temp_id < 0)
{
- throw IdComponentException("", "H5Rcreate failed");
+ throw ReferenceException("", "H5Rdereference failed");
}
-}
-
-//--------------------------------------------------------------------------
-// Function: IdComponent::reference
-///\brief Creates a reference to an HDF5 object or a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced
-///\param dataspace - IN: Dataspace with selection
-///\param ref_type - IN: Type of reference to query, valid values are:
-/// \li \c H5R_OBJECT \tReference is an object reference.
-/// \li \c H5R_DATASET_REGION \tReference is a dataset region
-/// reference. - this is the default
-///\exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void IdComponent::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const
-{
- try {
- p_reference(ref, name, dataspace.getId(), ref_type);
- }
- catch (IdComponentException E) {
- throw IdComponentException("IdComponent::reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: IdComponent::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it only creates
-/// a reference to an HDF5 object, not to a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c char pointer
-///\exception H5::IdComponentException
-///\par Description
-// This function passes H5R_OBJECT and -1 to the protected
-// function for it to pass to the C API H5Rcreate
-// to create a reference to the named object.
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void IdComponent::reference(void* ref, const char* name) const
-{
- try {
- p_reference(ref, name, -1, H5R_OBJECT);
- }
- catch (IdComponentException E) {
- throw IdComponentException("IdComponent::reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: IdComponent::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it takes an
-/// \c std::string for the object's name.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c std::string
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void IdComponent::reference(void* ref, const H5std_string& name) const
-{
- reference(ref, name.c_str());
+ return(temp_id);
}
//--------------------------------------------------------------------------
@@ -406,84 +349,17 @@ void IdComponent::reference(void* ref, const H5std_string& name) const
// BMR - Oct 8, 2006
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
-void* IdComponent::p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const
+ /* void* IdComponent::p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const
{
hobj_ref_t ref;
- herr_t ret_value = H5Rcreate(&ref, id, name, ref_type, space_id);
+ herr_t ret_value = H5Rcreate(&ref, getId(), name, ref_type, space_id);
if (ret_value < 0)
{
throw IdComponentException("", "H5Rcreate failed");
}
return (reinterpret_cast<void*>(ref));
}
-
-//--------------------------------------------------------------------------
-// Function: IdComponent::dereference
-// Purpose Opens the HDF5 object referenced.
-// Parameters
-// obj - IN: Dataset reference object is in or location of
-// object that the dataset is located within.
-// ref - IN: Reference pointer
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - Oct, 2006
-//--------------------------------------------------------------------------
-void IdComponent::dereference(IdComponent& obj, void* ref)
-{
- id = H5Rdereference(obj.getId(), H5R_OBJECT, ref);
- if (id < 0)
- {
- throw IdComponentException("", "H5Rdereference failed");
- }
-}
-
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-//--------------------------------------------------------------------------
-// Function: IdComponent::p_get_obj_type (protected)
-// Purpose Retrieves the type of object that an object reference points to.
-// Parameters
-// ref - IN: Reference to query
-// ref_type - IN: Type of reference to query
-// Return An object type, which can be one of the following:
-// H5G_LINK Object is a symbolic link.
-// H5G_GROUP Object is a group.
-// H5G_DATASET Object is a dataset.
-// H5G_TYPE Object is a named datatype
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-H5G_obj_t IdComponent::p_get_obj_type(void *ref, H5R_type_t ref_type) const
-{
- H5G_obj_t obj_type = H5Rget_obj_type1(id, ref_type, ref);
-
- if (obj_type == H5G_UNKNOWN)
- {
- throw IdComponentException("", "H5Rget_obj_type failed");
- }
- return(obj_type);
-}
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
-//--------------------------------------------------------------------------
-// Function: IdComponent::p_get_region (protected)
-// Purpose Retrieves a dataspace with the region pointed to selected.
-// Parameters
-// ref_type - IN: Type of reference to get region of - default
-// to H5R_DATASET_REGION
-// ref - IN: Reference to get region of
-// Return Dataspace id
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-hid_t IdComponent::p_get_region(void *ref, H5R_type_t ref_type) const
-{
- hid_t space_id = H5Rget_region(id, ref_type, ref);
- if (space_id < 0)
- {
- throw IdComponentException("", "H5Rget_region failed");
- }
- return(space_id);
-}
-
+ */
//
// Local functions used in this class
//
@@ -495,7 +371,7 @@ hid_t IdComponent::p_get_region(void *ref, H5R_type_t ref_type) const
// Return true if id is valid, false, otherwise
// Programmer Binh-Minh Ribler - May, 2005
//--------------------------------------------------------------------------
-bool IdComponent::p_valid_id(const hid_t obj_id) const
+bool IdComponent::p_valid_id(const hid_t obj_id)
{
H5I_type_t id_type = H5Iget_type(obj_id);
if (id_type <= H5I_BADID || id_type >= H5I_NTYPES)
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index c027f51..b2bdefb 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -21,10 +21,15 @@
#include "H5PropList.h"
#include "H5Object.h"
#include "H5DcreatProp.h"
+#include "H5DxferProp.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"
#include "H5Attribute.h"
#ifndef H5_NO_NAMESPACE
@@ -103,7 +108,7 @@ Attribute H5Object::createAttribute( const char* name, const DataType& data_type
hid_t type_id = data_type.getId();
hid_t space_id = data_space.getId();
hid_t plist_id = create_plist.getId();
- hid_t attr_id = H5Acreate2(id, name, type_id, space_id, plist_id, H5P_DEFAULT );
+ hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT );
// If the attribute id is valid, create and return the Attribute object
if( attr_id > 0 )
@@ -137,7 +142,7 @@ Attribute H5Object::createAttribute( const H5std_string& name, const DataType& d
//--------------------------------------------------------------------------
Attribute H5Object::openAttribute( const char* name ) const
{
- hid_t attr_id = H5Aopen( id, name, H5P_DEFAULT );
+ hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT);
if( attr_id > 0 )
{
Attribute attr( attr_id );
@@ -171,7 +176,8 @@ Attribute H5Object::openAttribute( const H5std_string& name ) const
//--------------------------------------------------------------------------
Attribute H5Object::openAttribute( const unsigned int idx ) const
{
- hid_t attr_id = H5Aopen_by_idx(id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx, H5P_DEFAULT, H5P_DEFAULT);
+ hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER,
+ H5_ITER_INC, (hsize_t)idx, H5P_DEFAULT, H5P_DEFAULT);
if( attr_id > 0 )
{
Attribute attr( attr_id );
@@ -209,7 +215,8 @@ int H5Object::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_da
// call the C library routine H5Aiterate2 to iterate the attributes
hsize_t idx = (hsize_t)*_idx;
- int ret_value = H5Aiterate2(id, H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, (void *) userData);
+ int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx,
+ userAttrOpWrpr, (void *) userData);
// release memory
delete userData;
@@ -235,7 +242,7 @@ int H5Object::getNumAttrs() const
{
H5O_info_t oinfo; /* Object info */
- if(H5Oget_info(id, &oinfo) < 0)
+ if(H5Oget_info(getId(), &oinfo) < 0)
throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed");
else
return( (int)oinfo.num_attrs );
@@ -250,7 +257,7 @@ int H5Object::getNumAttrs() const
//--------------------------------------------------------------------------
void H5Object::removeAttr( const char* name ) const
{
- herr_t ret_value = H5Adelete(id, name);
+ herr_t ret_value = H5Adelete(getId(), name);
if( ret_value < 0 )
throw AttributeIException(inMemFunc("removeAttr"), "H5Adelete failed");
}
@@ -277,7 +284,7 @@ void H5Object::removeAttr( const H5std_string& name ) const
//--------------------------------------------------------------------------
void H5Object::renameAttr(const char* oldname, const char* newname) const
{
- herr_t ret_value = H5Arename(id, oldname, newname);
+ herr_t ret_value = H5Arename(getId(), oldname, newname);
if (ret_value < 0)
throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed");
}
@@ -306,9 +313,9 @@ void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newna
/// This object is used to identify the file to be flushed.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void H5Object::flush(H5F_scope_t scope ) const
+void H5Object::flush(H5F_scope_t scope) const
{
- herr_t ret_value = H5Fflush( id, scope );
+ herr_t ret_value = H5Fflush(getId(), scope);
if( ret_value < 0 )
{
throw FileIException(inMemFunc("flush"), "H5Fflush failed");
@@ -333,6 +340,175 @@ H5std_string H5Object::getFileName() const
}
//--------------------------------------------------------------------------
+// Function: H5Object::p_reference (protected)
+// Purpose Creates a reference to an HDF5 object or a dataset region.
+// Parameters
+// name - IN: Name of the object to be referenced
+// dataspace - IN: Dataspace with selection
+// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Object::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const
+{
+ herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id);
+ if (ret_value < 0)
+ {
+ throw IdComponentException("", "H5Rcreate failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Object::reference
+///\brief Creates a reference to an HDF5 object or a dataset region.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced
+///\param dataspace - IN: Dataspace with selection
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT \tReference is an object reference.
+/// \li \c H5R_DATASET_REGION \tReference is a dataset region
+/// reference. - this is the default
+///\exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Object::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const
+{
+ try {
+ p_reference(ref, name, dataspace.getId(), ref_type);
+ }
+ catch (IdComponentException E) {
+ throw IdComponentException("H5Object::reference", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Object::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it only creates
+/// a reference to an HDF5 object, not to a dataset region.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced - \c char pointer
+///\exception H5::IdComponentException
+///\par Description
+// This function passes H5R_OBJECT and -1 to the protected
+// function for it to pass to the C API H5Rcreate
+// to create a reference to the named object.
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Object::reference(void* ref, const char* name) const
+{
+ try {
+ p_reference(ref, name, -1, H5R_OBJECT);
+ }
+ catch (IdComponentException E) {
+ throw IdComponentException("H5Object::reference", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Object::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it takes an
+/// \c std::string for the object's name.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced - \c std::string
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Object::reference(void* ref, const H5std_string& name) const
+{
+ reference(ref, name.c_str());
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Object::dereference
+// Purpose Dereference a ref into a DataSet object.
+// Parameters
+// ref - IN: Reference pointer
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// May 2008 - BMR
+// Moved from IdComponent into H5File and H5Object
+//--------------------------------------------------------------------------
+void H5Object::dereference(H5File& h5file, void* ref)
+{
+ hid_t temp_id;
+ try {
+ temp_id = h5file.p_dereference(ref);
+ }
+ catch (ReferenceException ref_err) {
+ throw (inMemFunc("dereference"), ref_err.getDetailMsg());
+ }
+
+ // No failure, set id to the object
+ setId(temp_id);
+}
+
+void H5Object::dereference(H5Object& obj, void* ref)
+{
+ hid_t temp_id;
+ try {
+ temp_id = obj.p_dereference(ref);
+ }
+ catch (ReferenceException ref_err) {
+ throw (inMemFunc("dereference"), ref_err.getDetailMsg());
+ }
+
+ // No failure, set id to the object
+ setId(temp_id);
+}
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+//--------------------------------------------------------------------------
+// Function: H5Object::p_get_obj_type (protected)
+// Purpose Retrieves the type of object that an object reference points to.
+// Parameters
+// ref - IN: Reference to query
+// ref_type - IN: Type of reference to query
+// Return An object type, which can be one of the following:
+// H5G_LINK Object is a symbolic link.
+// H5G_GROUP Object is a group.
+// H5G_DATASET Object is a dataset.
+// H5G_TYPE Object is a named datatype
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+H5G_obj_t H5Object::p_get_obj_type(void *ref, H5R_type_t ref_type) const
+{
+ H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref);
+
+ if (obj_type == H5G_UNKNOWN)
+ {
+ throw IdComponentException("", "H5Rget_obj_type failed");
+ }
+ return(obj_type);
+}
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+
+//--------------------------------------------------------------------------
+// Function: H5Object::p_get_region (protected)
+// Purpose Retrieves a dataspace with the region pointed to selected.
+// Parameters
+// ref_type - IN: Type of reference to get region of - default
+// to H5R_DATASET_REGION
+// ref - IN: Reference to get region of
+// Return Dataspace id
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+hid_t H5Object::p_get_region(void *ref, H5R_type_t ref_type) const
+{
+ hid_t space_id = H5Rget_region(getId(), ref_type, ref);
+ if (space_id < 0)
+ {
+ throw IdComponentException("", "H5Rget_region failed");
+ }
+ return(space_id);
+}
+
+
+//--------------------------------------------------------------------------
// Function: H5Object destructor
///\brief Noop destructor.
// Programmer Binh-Minh Ribler - 2000
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 76bc089..a65c300 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -45,7 +45,7 @@ const PropList PropList::DEFAULT( H5P_DEFAULT );
///\brief Default constructor: creates a stub property list object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList::PropList() : IdComponent( 0 ) {}
+PropList::PropList() : IdComponent(), id(0) {}
//--------------------------------------------------------------------------
// Function: PropList copy constructor
@@ -53,7 +53,11 @@ PropList::PropList() : IdComponent( 0 ) {}
///\param original - IN: The original property list to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList::PropList( const PropList& original ) : IdComponent( original ) {}
+PropList::PropList(const PropList& original) : IdComponent(original)
+{
+ id = original.getId();
+ incRefCount(); // increment number of references to this id
+}
//--------------------------------------------------------------------------
// Function: PropList overloaded constructor
@@ -69,7 +73,7 @@ PropList::PropList( const PropList& original ) : IdComponent( original ) {}
// description was what I came up with from reading the code.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList::PropList( const hid_t plist_id ) : IdComponent(0)
+PropList::PropList( const hid_t plist_id ) : IdComponent()
{
if (H5I_GENPROP_CLS == H5Iget_type(plist_id)) {
// call C routine to create the new property
@@ -204,6 +208,49 @@ void PropList::copyProp( PropList& dest, PropList& src, const H5std_string& name
}
//--------------------------------------------------------------------------
+// Function: PropList::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 PropList::getId() const
+{
+ return(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: PropList::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 PropList::setId(const hid_t new_id)
+{
+ // handling references to this old id
+ try {
+ close();
+ }
+ catch (Exception close_error) {
+ throw PropListIException(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: PropList::close
///\brief Closes the property list if it is not a default one.
///