summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-24 21:18:28 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-24 21:18:28 (GMT)
commit836f7b53ccce4f67c1918b337c1a133191c58a98 (patch)
tree1fb98f124ac675a2a3e3a1ab62e6266d1a7f9900 /c++
parente1ee78dd0997e240247353fe1f363cd3ef0e4987 (diff)
downloadhdf5-836f7b53ccce4f67c1918b337c1a133191c58a98.zip
hdf5-836f7b53ccce4f67c1918b337c1a133191c58a98.tar.gz
hdf5-836f7b53ccce4f67c1918b337c1a133191c58a98.tar.bz2
[svn-r15401] Purpose: Fix bug
Description: Changed all subclasses' setId to p_setId and put back setId in IdComponent. p_setId is used in the library where the id provided by a C API passed on to user's application in the form of a C++ API object, which will be destroyed properly, and so p_setId does not call incRefCount. On the other hand, the public version setId is used by other applications, in which the id passed to setId needs to be closed properly by the application, so setId must call incRefCount for the new object to prevent prematurely closing of the id. Platforms tested: Linux 2.6 (kagiso) Still on going with these two platforms, but needed to check in before daily tests start. SunOS 5.10 (linew) FreeBSD (duty)
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5Attribute.cpp6
-rw-r--r--c++/src/H5Attribute.h2
-rw-r--r--c++/src/H5DataSet.cpp6
-rw-r--r--c++/src/H5DataSet.h2
-rw-r--r--c++/src/H5DataSpace.cpp6
-rw-r--r--c++/src/H5DataSpace.h2
-rw-r--r--c++/src/H5DataType.cpp6
-rw-r--r--c++/src/H5DataType.h2
-rw-r--r--c++/src/H5FaccProp.cpp2
-rw-r--r--c++/src/H5File.cpp6
-rw-r--r--c++/src/H5File.h2
-rw-r--r--c++/src/H5Group.cpp6
-rw-r--r--c++/src/H5Group.h2
-rw-r--r--c++/src/H5IdComponent.cpp33
-rw-r--r--c++/src/H5IdComponent.h6
-rw-r--r--c++/src/H5Object.cpp6
-rw-r--r--c++/src/H5PropList.cpp6
-rw-r--r--c++/src/H5PropList.h2
18 files changed, 68 insertions, 35 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index f85b87c..ed2e7f3 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -377,7 +377,7 @@ hid_t Attribute::getId() const
}
//--------------------------------------------------------------------------
-// Function: Attribute::setId
+// Function: Attribute::p_setId
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -388,14 +388,14 @@ hid_t Attribute::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void Attribute::setId(const hid_t new_id)
+void Attribute::p_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());
+ throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg());
}
// reset object's id to the given id
id = new_id;
diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h
index 49faeea..7da4798 100644
--- a/c++/src/H5Attribute.h
+++ b/c++/src/H5Attribute.h
@@ -66,7 +66,7 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent {
// Gets/Sets the attribute id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
+ virtual void p_setId(const hid_t new_id);
// Destructor: properly terminates access to this attribute.
virtual ~Attribute();
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index 5ee84b1..3051e08 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -534,7 +534,7 @@ hid_t DataSet::getId() const
}
//--------------------------------------------------------------------------
-// Function: DataSet::setId
+// Function: DataSet::p_setId
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -545,14 +545,14 @@ hid_t DataSet::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void DataSet::setId(const hid_t new_id)
+void DataSet::p_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());
+ throw DataSetIException(inMemFunc("p_setId"), close_error.getDetailMsg());
}
// reset object's id to the given id
id = new_id;
diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h
index f968932..6194cd8 100644
--- a/c++/src/H5DataSet.h
+++ b/c++/src/H5DataSet.h
@@ -99,7 +99,7 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
// Gets the dataset id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
+ virtual void p_setId(const hid_t new_id);
// Destructor: properly terminates access to this dataset.
virtual ~DataSet();
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index baad137..3d74b51 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -571,7 +571,7 @@ hid_t DataSpace::getId() const
}
//--------------------------------------------------------------------------
-// Function: DataSpace::setId
+// Function: DataSpace::p_setId
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -582,14 +582,14 @@ hid_t DataSpace::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void DataSpace::setId(const hid_t new_id)
+void DataSpace::p_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());
+ throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg());
}
// reset object's id to the given id
id = new_id;
diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h
index 1173c26..3e5776d 100644
--- a/c++/src/H5DataSpace.h
+++ b/c++/src/H5DataSpace.h
@@ -114,7 +114,7 @@ class H5_DLLCPP DataSpace : public IdComponent {
// Gets the dataspace id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
+ virtual void p_setId(const hid_t new_id);
// Destructor: properly terminates access to this dataspace.
virtual ~DataSpace();
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 9575823..e023bda 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -695,7 +695,7 @@ hid_t DataType::getId() const
}
//--------------------------------------------------------------------------
-// Function: DataType::setId
+// Function: DataType::p_setId
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -706,14 +706,14 @@ hid_t DataType::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void DataType::setId(const hid_t new_id)
+void DataType::p_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());
+ throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg());
}
// reset object's id to the given id
id = new_id;
diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h
index 509dd49..d00b807 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -119,7 +119,7 @@ class H5_DLLCPP DataType : public H5Object {
// Gets the datatype id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
+ virtual void p_setId(const hid_t new_id);
// Destructor: properly terminates access to this datatype.
virtual ~DataType();
diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp
index 6a70b3b..f2ab0f3 100644
--- a/c++/src/H5FaccProp.cpp
+++ b/c++/src/H5FaccProp.cpp
@@ -225,7 +225,7 @@ void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist)
{
throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed");
}
- memb_plist.setId(memb_plist_id);
+ memb_plist.p_setId(memb_plist_id);
}
//--------------------------------------------------------------------------
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index 7cd1936..0e71543 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -732,7 +732,7 @@ hid_t H5File::getId() const
}
//--------------------------------------------------------------------------
-// Function: H5File::setId
+// Function: H5File::p_setId
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -743,14 +743,14 @@ hid_t H5File::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void H5File::setId(const hid_t new_id)
+void H5File::p_setId(const hid_t new_id)
{
// handling references to this old id
try {
close();
}
catch (Exception E) {
- throw FileIException("H5File::setId", E.getDetailMsg());
+ throw FileIException("H5File::p_setId", E.getDetailMsg());
}
// reset object's id to the given id
id = new_id;
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index 92b1e20..060a121 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -111,7 +111,7 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
// Gets/Sets the HDF5 file id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
+ virtual void p_setId(const hid_t new_id);
// H5File destructor.
virtual ~H5File();
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index 6014466..f50691e 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -170,7 +170,7 @@ hid_t Group::getId() const
}
//--------------------------------------------------------------------------
-// Function: Group::setId
+// Function: Group::p_setId
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -181,14 +181,14 @@ hid_t Group::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void Group::setId(const hid_t new_id)
+void Group::p_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());
+ throw GroupIException("Group::p_setId", close_error.getDetailMsg());
}
// reset object's id to the given id
id = new_id;
diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h
index 091ea72..7fa7522 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -55,7 +55,7 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Gets the group id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
+ virtual void p_setId(const hid_t new_id);
// Destructor
virtual ~Group();
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index b22d869..c30164a 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -177,13 +177,44 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
// copy the data members from the rhs object
setId(rhs.getId());
- incRefCount(getId()); // a = b, so there are two objects with the same
+// incRefCount(getId()); // a = b, so there are two objects with the same
// hdf5 id
}
return *this;
}
//--------------------------------------------------------------------------
+// Function: IdComponent::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
+// Modification
+// 2008/7/23 - BMR
+// Changed all subclasses' setId to p_setId and put back setId
+// here. p_setId is used in the library where the id provided
+// by a C API passed on to user's application in the form of a
+// C++ API object, which will be destroyed properly, and so
+// p_setId does not call incRefCount. On the other hand, the
+// public version setId is used by other applications, in which
+// the id passed to setId already has a reference count, so setId
+// must call incRefCount.
+//--------------------------------------------------------------------------
+void IdComponent::setId(const hid_t new_id)
+{
+ // set to new_id
+ p_setId(new_id);
+
+ // increment the reference counter of the new id
+ incRefCount();
+}
+
+//--------------------------------------------------------------------------
// Function: IdComponent destructor
///\brief Noop destructor.
// Programmer Binh-Minh Ribler - 2000
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index c34b2da..5bbfb71 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -51,7 +51,7 @@ class H5_DLLCPP IdComponent {
virtual hid_t getId () const = 0;
// Sets the identifier of this object to a new value.
- virtual void setId(const hid_t new_id) = 0;
+ void setId(const hid_t new_id);
// Creates an object to hold an HDF5 identifier.
IdComponent( const hid_t h5_id );
@@ -85,6 +85,10 @@ class H5_DLLCPP IdComponent {
// Gets the name of the file, in which an HDF5 object belongs.
H5std_string p_get_file_name() const;
+ // Sets the identifier of this object to a new value. - this one
+ // doesn't increment reference count
+ virtual void p_setId(const hid_t new_id) = 0;
+
// Verifies that the given id is valid.
static bool p_valid_id(const hid_t obj_id);
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index de0f2d5..9dafea8 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -441,9 +441,7 @@ void H5Object::dereference(H5File& h5file, void* ref)
}
// No failure, set id to the object
- /* obj.setId(temp_id);
- */
- setId(temp_id);
+ p_setId(temp_id);
}
void H5Object::dereference(H5Object& obj, void* ref)
@@ -457,7 +455,7 @@ void H5Object::dereference(H5Object& obj, void* ref)
}
// No failure, set id to the object
- setId(temp_id);
+ p_setId(temp_id);
}
#ifndef H5_NO_DEPRECATED_SYMBOLS
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 085dfd1..020bf18 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -223,7 +223,7 @@ hid_t PropList::getId() const
}
//--------------------------------------------------------------------------
-// Function: PropList::setId
+// Function: PropList::p_setId
///\brief Sets the identifier of this object to a new value.
///
///\exception H5::IdComponentException when the attempt to close the HDF5
@@ -234,14 +234,14 @@ hid_t PropList::getId() const
// Then the object's id is reset to the new id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-void PropList::setId(const hid_t new_id)
+void PropList::p_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());
+ throw PropListIException(inMemFunc("p_setId"), close_error.getDetailMsg());
}
// reset object's id to the given id
id = new_id;
diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h
index 75a3d21..e25a8ab 100644
--- a/c++/src/H5PropList.h
+++ b/c++/src/H5PropList.h
@@ -105,7 +105,7 @@ class H5_DLLCPP PropList : public IdComponent {
// Gets the property list id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
+ virtual void p_setId(const hid_t new_id);
// Destructor: properly terminates access to this property list.
virtual ~PropList();