summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5Attribute.cpp10
-rw-r--r--c++/src/H5DataSet.cpp18
-rw-r--r--c++/src/H5DataSpace.cpp8
-rw-r--r--c++/src/H5DataType.cpp12
-rw-r--r--c++/src/H5DcreatProp.cpp2
-rw-r--r--c++/src/H5DxferProp.cpp2
-rw-r--r--c++/src/H5Exception.cpp4
-rw-r--r--c++/src/H5FaccProp.cpp2
-rw-r--r--c++/src/H5FcreatProp.cpp2
-rw-r--r--c++/src/H5File.cpp59
-rw-r--r--c++/src/H5Group.cpp12
-rw-r--r--c++/src/H5IdComponent.cpp98
-rw-r--r--c++/src/H5IdComponent.h21
-rw-r--r--c++/src/H5PropList.cpp10
14 files changed, 173 insertions, 87 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 515415d..ccfdd4c 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -135,7 +135,7 @@ void Attribute::read( const DataType& mem_type, string& strg ) const
throw AttributeIException("Attribute::read", "H5Aread failed");
}
strg = strg_C;
- delete strg_C;
+ delete []strg_C;
}
//--------------------------------------------------------------------------
@@ -205,7 +205,7 @@ ssize_t Attribute::getName( size_t buf_size, string& attr_name ) const
}
// otherwise, convert the C attribute name and return
attr_name = name_C;
- delete name_C;
+ delete []name_C;
return( name_size );
}
@@ -252,7 +252,7 @@ string Attribute::getName() const
else
attr_name = name_C;
- delete name_C;
+ delete []name_C;
return( attr_name );
}
@@ -294,8 +294,8 @@ hsize_t Attribute::getStorageSize() const
///\brief Properly terminates access to this attribute.
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
Attribute::~Attribute()
{
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index 899155d..e617634 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -117,7 +117,7 @@ DSetCreatPropList DataSet::getCreatePlist() const
//--------------------------------------------------------------------------
// Function: DataSet::getStorageSize
-///\brief Returns the amount of storage required for a dataset.
+///\brief Returns the amount of storage required for a dataset.
///\return Size of the storage or 0, for no data
///\exception H5::DataSetIException
// Note: H5Dget_storage_size returns 0 when there is no data. This
@@ -260,7 +260,7 @@ void DataSet::read( string& strg, const DataType& mem_type, const DataSpace& mem
// Get the String and clean up
strg = strg_C;
- delete strg_C;
+ delete []strg_C;
}
//--------------------------------------------------------------------------
@@ -413,7 +413,7 @@ void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space)
///\param dataspace - IN: Dataspace with selection
///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
///\return A reference
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
void* DataSet::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const
@@ -428,7 +428,7 @@ void* DataSet::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_
/// a reference to an HDF5 object, not to a dataset region.
///\param name - IN: Name of the object to be referenced
///\return A reference
-///\exception H5::ReferenceIException
+///\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
@@ -450,7 +450,7 @@ void* DataSet::Reference(const char* name) const
// H5G_GROUP Object is a group.
// H5G_DATASET Object is a dataset.
// H5G_TYPE Object is a named datatype
-// Exception H5::ReferenceIException
+// Exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
H5G_obj_t DataSet::getObjType(void *ref, H5R_type_t ref_type) const
@@ -465,7 +465,7 @@ H5G_obj_t DataSet::getObjType(void *ref, H5R_type_t ref_type) const
/// to H5R_DATASET_REGION
///\param ref - IN: Reference to get region of
///\return DataSpace instance
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
DataSpace DataSet::getRegion(void *ref, H5R_type_t ref_type) const
@@ -497,12 +497,12 @@ void DataSet::close()
///\brief Properly terminates access to this dataset.
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
DataSet::~DataSet()
{
- // The dataset id will be closed properly
+ // The dataset id will be closed properly
try {
decRefCount();
}
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index a2d1a4e..4a51c6b 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -94,8 +94,8 @@ DataSpace::DataSpace( const DataSpace& original ) : IdComponent( original ) {}
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
void DataSpace::copy( const DataSpace& like_space )
{
@@ -568,8 +568,8 @@ void DataSpace::close()
///\brief Properly terminates access to this dataspace.
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
DataSpace::~DataSpace()
{
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 6e5d584..1d2a519 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -96,7 +96,7 @@ DataType::DataType(const DataType& original) : H5Object(original)
// Programmer Binh-Minh Ribler - 2000
// Modification
// Replaced resetIdComponent with decRefCount to use C library
-// ID reference counting mechanism - BMR, Feb 20, 2005
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
void DataType::copy( const DataType& like_type )
{
@@ -538,7 +538,7 @@ bool DataType::isVariableStr() const
///\param dataspace - IN: Dataspace with selection
///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
///\return A reference
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
void* DataType::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const
@@ -553,7 +553,7 @@ void* DataType::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref
/// a reference to an HDF5 object, not to a dataset region.
///\param name - IN: Name of the object to be referenced
///\return A reference
-///\exception H5::ReferenceIException
+///\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
@@ -575,7 +575,7 @@ void* DataType::Reference(const char* name) const
/// \li \c H5G_GROUP Object is a group.
/// \li \c H5G_DATASET Object is a dataset.
/// \li \c H5G_TYPE Object is a named datatype
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
H5G_obj_t DataType::getObjType(void *ref, H5R_type_t ref_type) const
@@ -589,7 +589,7 @@ H5G_obj_t DataType::getObjType(void *ref, H5R_type_t ref_type) const
///\param ref - IN: Reference to get region of
///\param ref_type - IN: Type of reference to get region of - default
///\return DataSpace instance
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const
@@ -628,7 +628,7 @@ void DataType::close()
// Programmer Binh-Minh Ribler - 2000
// Modification
// Replaced resetIdComponent with decRefCount to use C library
-// ID reference counting mechanism - BMR, Feb 20, 2005
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
DataType::~DataType()
{
diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp
index b5e7288..9ecc9a3 100644
--- a/c++/src/H5DcreatProp.cpp
+++ b/c++/src/H5DcreatProp.cpp
@@ -30,7 +30,7 @@ namespace H5 {
//--------------------------------------------------------------------------
///\brief Constant for dataset creation default property
//--------------------------------------------------------------------------
-const DSetCreatPropList DSetCreatPropList::DEFAULT( H5P_DEFAULT );
+const DSetCreatPropList DSetCreatPropList::DEFAULT;
//--------------------------------------------------------------------------
// Function: DSetCreatPropList default constructor
diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp
index 14cdbd9..379e02e 100644
--- a/c++/src/H5DxferProp.cpp
+++ b/c++/src/H5DxferProp.cpp
@@ -27,7 +27,7 @@ namespace H5 {
//--------------------------------------------------------------------------
///\brief Constant for default dataset memory and transfer property list.
//--------------------------------------------------------------------------
-const DSetMemXferPropList DSetMemXferPropList::DEFAULT( H5P_DEFAULT );
+const DSetMemXferPropList DSetMemXferPropList::DEFAULT;
//--------------------------------------------------------------------------
// Function DSetMemXferPropList default constructor
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index aef0d9c..37d0da5 100644
--- a/c++/src/H5Exception.cpp
+++ b/c++/src/H5Exception.cpp
@@ -85,7 +85,7 @@ string Exception::getMajorString( hid_t err_major ) const
// Convert the C error description and return
string major_str(mesg_C);
- delete mesg_C;
+ delete []mesg_C;
return( major_str );
}
@@ -121,7 +121,7 @@ string Exception::getMinorString( hid_t err_minor ) const
// Convert the C error description and return
string minor_str(mesg_C);
- delete mesg_C;
+ delete []mesg_C;
return( minor_str );
}
diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp
index ec7d7be..7e96bc0 100644
--- a/c++/src/H5FaccProp.cpp
+++ b/c++/src/H5FaccProp.cpp
@@ -27,7 +27,7 @@ namespace H5 {
//--------------------------------------------------------------------------
///\brief Constant for default property
//--------------------------------------------------------------------------
-const FileAccPropList FileAccPropList::DEFAULT( H5P_DEFAULT );
+const FileAccPropList FileAccPropList::DEFAULT;
//--------------------------------------------------------------------------
// Function: Default Constructor
diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp
index 7cafd52..0eb9462 100644
--- a/c++/src/H5FcreatProp.cpp
+++ b/c++/src/H5FcreatProp.cpp
@@ -27,7 +27,7 @@ namespace H5 {
//--------------------------------------------------------------------------
///\brief Constant for default property
//--------------------------------------------------------------------------
-const FileCreatPropList FileCreatPropList::DEFAULT( H5P_DEFAULT );
+const FileCreatPropList FileCreatPropList::DEFAULT;
//--------------------------------------------------------------------------
// Function: FileCreatPropList default constructor
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index 1025c41..b9adbca 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -119,8 +119,7 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro
// Open the file if none of the bits above are set.
else
{
- // use create_plist for access plist because of the default argument
- hid_t access_plist_id = create_plist.getId();
+ hid_t access_plist_id = access_plist.getId();
id = H5Fopen( name, flags, access_plist_id );
if( id <= 0 ) // throw an exception when open/create fail
{
@@ -182,11 +181,11 @@ bool H5File::isHdf5(const string& name )
// If this object has represented another HDF5 file, the previous
// HDF5 file need to be closed first.
// Programmer Binh-Minh Ribler - 2000
+// Note: This wrapper doesn't seem right regarding the 'id' and should
+// be investigated. BMR - 2/20/2005
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
-// Note: This wrapper doesn't seem right regarding the 'id' and should
-// be investigated. BMR - 2/20/2005
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
void H5File::reOpen()
{
@@ -295,15 +294,15 @@ hssize_t H5File::getFreeSpace() const
///\return Number of opened object IDs
///\exception H5::FileIException
///\par Description
-/// The valid values for \a types include:
-/// \li \c H5F_OBJ_FILE - Files only
-/// \li \c H5F_OBJ_DATASET - Datasets only
-/// \li \c H5F_OBJ_GROUP - Groups only
-/// \li \c H5F_OBJ_DATATYPE - Named datatypes only
-/// \li \c H5F_OBJ_ATTR - Attributes only
-/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE
-/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP
-/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR
+/// The valid values for \a types include:
+/// \li \c H5F_OBJ_FILE - Files only
+/// \li \c H5F_OBJ_DATASET - Datasets only
+/// \li \c H5F_OBJ_GROUP - Groups only
+/// \li \c H5F_OBJ_DATATYPE - Named datatypes only
+/// \li \c H5F_OBJ_ATTR - Attributes only
+/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE
+/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP
+/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR
///\par
/// Multiple object types can be combined with the logical OR operator (|).
// Programmer Binh-Minh Ribler - May 2004
@@ -347,15 +346,15 @@ int H5File::getObjCount() const
///\param oid_list - List of open object identifiers
///\exception H5::FileIException
///\par Description
-/// The valid values for \a types include:
-/// \li \c H5F_OBJ_FILE - Files only
-/// \li \c H5F_OBJ_DATASET - Datasets only
-/// \li \c H5F_OBJ_GROUP - Groups only
-/// \li \c H5F_OBJ_DATATYPE - Named datatypes only
-/// \li \c H5F_OBJ_ATTR - Attributes only
-/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE
-/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP
-/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR
+/// The valid values for \a types include:
+/// \li \c H5F_OBJ_FILE - Files only
+/// \li \c H5F_OBJ_DATASET - Datasets only
+/// \li \c H5F_OBJ_GROUP - Groups only
+/// \li \c H5F_OBJ_DATATYPE - Named datatypes only
+/// \li \c H5F_OBJ_ATTR - Attributes only
+/// \li \c H5F_OBJ_ALL - All of the above, i.e., \c H5F_OBJ_FILE
+/// | \c H5F_OBJ_DATASET | \c H5F_OBJ_GROUP
+/// | \c H5F_OBJ_DATATYPE | \c H5F_OBJ_ATTR
///\par
/// Multiple object types can be combined with the logical OR operator (|).
//
@@ -438,7 +437,7 @@ string H5File::getFileName() const
///\param dataspace - IN: Dataspace with selection
///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
///\return A reference
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
///\par Description
/// Note that name must be an absolute path to the object in the file.
// Programmer Binh-Minh Ribler - May, 2004
@@ -455,7 +454,7 @@ void* H5File::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_t
/// a reference to an HDF5 object, not to a dataset region.
///\param name - IN: Name of the object to be referenced
///\return A reference
-///\exception H5::ReferenceIException
+///\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
@@ -480,7 +479,7 @@ void* H5File::Reference(const char* name) const
/// \li \c H5G_GROUP - Object is a group.
/// \li \c H5G_DATASET - Object is a dataset.
/// \li \c H5G_TYPE - Object is a named datatype
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
H5G_obj_t H5File::getObjType(void *ref, H5R_type_t ref_type) const
@@ -494,7 +493,7 @@ H5G_obj_t H5File::getObjType(void *ref, H5R_type_t ref_type) const
///\param ref - IN: Reference to get region of
///\param ref_type - IN: Type of reference to get region of - default
///\return DataSpace instance
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
DataSpace H5File::getRegion(void *ref, H5R_type_t ref_type) const
@@ -581,8 +580,8 @@ void H5File::throwException(const string func_name, const string msg) const
///\brief Properly terminates access to this file.
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
H5File::~H5File()
{
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index 50bc87f..384ea1e 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -81,7 +81,7 @@ Group::Group( const hid_t group_id ) : H5Object( group_id ) {}
///\param dataspace - IN: Dataspace with selection
///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
///\return A reference
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
void* Group::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const
@@ -96,7 +96,7 @@ void* Group::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_ty
/// a reference to an HDF5 object, not to a dataset region.
///\param name - IN: Name of the object to be referenced
///\return A reference
-///\exception H5::ReferenceIException
+///\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
@@ -118,7 +118,7 @@ void* Group::Reference(const char* name) const
// H5G_GROUP Object is a group.
// H5G_DATASET Object is a dataset.
// H5G_TYPE Object is a named datatype
-// Exception H5::ReferenceIException
+// Exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
H5G_obj_t Group::getObjType(void *ref, H5R_type_t ref_type) const
@@ -132,7 +132,7 @@ H5G_obj_t Group::getObjType(void *ref, H5R_type_t ref_type) const
///\param ref - IN: Reference to get region of
///\param ref_type - IN: Type of reference to get region of - default
///\return DataSpace instance
-///\exception H5::ReferenceIException
+///\exception H5::IdComponentException
// Programmer Binh-Minh Ribler - May, 2004
//--------------------------------------------------------------------------
DataSpace Group::getRegion(void *ref, H5R_type_t ref_type) const
@@ -185,8 +185,8 @@ void Group::throwException(const string func_name, const string msg) const
///\brief Properly terminates access to this group.
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
Group::~Group()
{
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index e4c5305..aed355d 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -41,35 +41,89 @@ IdComponent::IdComponent(const hid_t h5_id) : id(h5_id) {}
IdComponent::IdComponent( const IdComponent& original )
{
id = original.id;
- H5Iinc_ref(id); // increment number of references to this id
+ incRefCount(); // increment number of references to this id
}
//--------------------------------------------------------------------------
// Function: IdComponent::incRefCount
-///\brief Increment id reference counter.
+///\brief Increment reference counter for a given id.
+// Programmer Binh-Minh Ribler - May 2005
+//--------------------------------------------------------------------------
+void IdComponent::incRefCount(hid_t obj_id) const
+{
+ if (p_valid_id(obj_id))
+ if (H5Iinc_ref(obj_id) < 0)
+ throw IdComponentException("IdComponent::incRefCount", "incrementing object ref count failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: IdComponent::incRefCount
+///\brief Increment reference counter for the id of this object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void IdComponent::incRefCount() { H5Iinc_ref(id); }
+void IdComponent::incRefCount() const
+{
+ incRefCount(id);
+}
+
+//--------------------------------------------------------------------------
+// Function: IdComponent::decRefCount
+///\brief Decrement reference counter for a given id.
+// Programmer Binh-Minh Ribler - May 2005
+// Modification:
+// Added the check for ref counter to give a little more info
+// on why H5Idec_ref fails in some cases - BMR 5/19/2005
+//--------------------------------------------------------------------------
+void IdComponent::decRefCount(hid_t obj_id) const
+{
+ if (p_valid_id(obj_id))
+ if (H5Idec_ref(obj_id) < 0)
+ if (H5Iget_ref(obj_id) <= 0)
+ throw IdComponentException("IdComponent::decRefCount",
+ "object ref count is 0 or negative");
+ else
+ throw IdComponentException("IdComponent::decRefCount",
+ "decrementing object ref count failed");
+}
//--------------------------------------------------------------------------
// Function: IdComponent::decRefCount
-///\brief Decrement id reference counter.
+///\brief Decrement reference counter for the id of this object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void IdComponent::decRefCount()
+void IdComponent::decRefCount() const
{
- if(id>0)
- if(H5Idec_ref(id)<0)
- throw IdComponentException("IdComponent::decRefCount", "decrementing object ref count failed");
+ decRefCount(id);
}
//--------------------------------------------------------------------------
// Function: IdComponent::getCounter
-///\brief Returns the reference counter to this identifier.
+///\brief Returns the reference counter for a given id.
+///\return Reference count
+// Programmer Binh-Minh Ribler - May 2005
+//--------------------------------------------------------------------------
+int IdComponent::getCounter(hid_t obj_id) const
+{
+ int counter = 0;
+ if (p_valid_id(obj_id))
+ {
+ counter = H5Iget_ref(obj_id);
+ if (counter < 0)
+ throw IdComponentException("IdComponent::incRefCount", "incrementing object ref count failed");
+ }
+ return (counter);
+}
+
+//--------------------------------------------------------------------------
+// Function: IdComponent::getCounter
+///\brief Returns the reference counter for the id of this object.
///\return Reference count
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-int IdComponent::getCounter() { return( H5Iget_ref(id)); }
+int IdComponent::getCounter() const
+{
+ return (getCounter(id));
+}
//--------------------------------------------------------------------------
// Function: IdComponent::operator=
@@ -95,7 +149,7 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
id = rhs.id;
// increment the reference counter
- H5Iinc_ref(id);
+ incRefCount();
return( *this );
}
@@ -210,7 +264,7 @@ string IdComponent::p_get_file_name() const
// Convert the C file name and return
string file_name(name_C);
- delete name_C;
+ delete []name_C;
return(file_name);
}
@@ -284,6 +338,26 @@ hid_t IdComponent::p_get_region(void *ref, H5R_type_t ref_type) const
return(space_id);
}
+//
+// Local functions used in this class
+//
+
+//--------------------------------------------------------------------------
+// Function: p_valid_id
+// Purpose: Verifies that the given id is a valid id so it can be passed
+// into an H5I C function.
+// Return true if id is valid, false, otherwise
+// Programmer Binh-Minh Ribler - May, 2005
+//--------------------------------------------------------------------------
+bool IdComponent::p_valid_id(hid_t obj_id) const
+{
+ H5I_type_t id_type = H5Iget_type(obj_id);
+ if (id_type <= H5I_BADID || id_type >= H5I_NTYPES)
+ return false;
+ else
+ return true;
+}
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index 45dc2a5..e50eb2a 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -25,18 +25,21 @@ namespace H5 {
class H5_DLLCPP IdComponent {
public:
// Increment reference counter.
- void incRefCount();
+ void incRefCount(hid_t obj_id) const;
+ void incRefCount() const;
// Decrement reference counter.
- void decRefCount();
+ void decRefCount(hid_t obj_id) const;
+ void decRefCount() const;
// Get the reference counter to this identifier.
- int getCounter();
+ int getCounter(hid_t obj_id) const;
+ int getCounter() const;
// Assignment operator.
IdComponent& operator=( const IdComponent& rhs );
- void reset();
+ //void reset();
// Sets the identifier of this object to a new value.
void setId( hid_t new_id );
@@ -50,6 +53,12 @@ class H5_DLLCPP IdComponent {
// Gets the value of IdComponent's data member.
virtual hid_t getId () const;
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ // Pure virtual function for there are various H5*close for the
+ // subclasses.
+ virtual void close() = 0;
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
// Destructor
virtual ~IdComponent();
@@ -78,6 +87,10 @@ class H5_DLLCPP IdComponent {
// Retrieves a dataspace with the region pointed to selected.
hid_t p_get_region(void *ref, H5R_type_t ref_type) const;
+
+ // Verifies that the given id is valid.
+ bool p_valid_id(hid_t obj_id) const;
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
}; // end class IdComponent
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 11595f4..e0d0143 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -87,8 +87,8 @@ PropList::PropList( const hid_t plist_id ) : IdComponent(0)
///\exception H5::PropListIException
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
void PropList::copy( const PropList& like_plist )
{
@@ -303,7 +303,7 @@ string PropList::getProperty(const char* name) const
// Return propety value as a string after deleting temp C-string
string prop_strg = string(prop_strg_C);
- delete prop_strg_C;
+ delete []prop_strg_C;
return (prop_strg);
}
//--------------------------------------------------------------------------
@@ -581,8 +581,8 @@ PropList PropList::getClassParent() const
///\brief Properly terminates access to this property list.
// Programmer Binh-Minh Ribler - 2000
// Modification
-// Replaced resetIdComponent with decRefCount to use new ID
-// reference counting mechanisms by Quincey Koziol, June 1, 2004
+// Replaced resetIdComponent with decRefCount to use C library
+// ID reference counting mechanism - June 1, 2004
//--------------------------------------------------------------------------
PropList::~PropList()
{