summaryrefslogtreecommitdiffstats
path: root/c++/src/H5IdComponent.h
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2005-07-10 11:26:56 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2005-07-10 11:26:56 (GMT)
commitb14a4fd95f5c71f31ec344e13a7c398015da41e6 (patch)
treed51925c61682fdf2e3e9422abb08ca753749ab9b /c++/src/H5IdComponent.h
parent6aa7ea9331f4181f29d6a19bf9d53fc330c3ff88 (diff)
downloadhdf5-b14a4fd95f5c71f31ec344e13a7c398015da41e6.zip
hdf5-b14a4fd95f5c71f31ec344e13a7c398015da41e6.tar.gz
hdf5-b14a4fd95f5c71f31ec344e13a7c398015da41e6.tar.bz2
[svn-r11060] Purpose: Fix bug (reported by user)
Description: The use of FileCreatPropList::DEFAULT sometimes caused failure in the reference counting area. This occurs to all the default property lists, which also include FileAccPropList::DEFAULT, DSetCreatPropList::DEFAULT, and DSetMemXferPropList::DEFAULT. H5P_DEFAULT was used to create these default prop lists and because its value is 0, the id of these prop lists are 0, which is rejected by the H5I functions during the reference counting. Solution: The main action to fix the above problem was to use H5P_FILE_CREATE H5P_FILE_ACCESS H5P_DATASET_CREATE H5P_DATASET_XFER to define the default property lists accordingly. Yet, when this fix was applied, some bug in reference counting was revealed. It appeared that some ids were not incremented but were passed in for decrementing. The following actions were then taken to fix and improve the current use of reference counting H5I functions. * added private func IdComponent::p_valid_id to verify that the id is a valid id and can be passed into an H5I function * used p_valid_id to validate an id before calling an H5I functions in the reference-counting member functions incRefCount, decRefCount, and getCounter * changed to use member function incRefCount, decRefCount, and getCounter instead of the C APIs H5Iinc_ref, H5Idec_ref, and H5Iget_ref throughout IdComponent. In addition, overloadings were added for incRefCount, decRefCount, and getCounter to take an id different than the id of the current instance; they can be convenient during debugging. Platforms tested: Linux 2.4 (heping) SunOS 5.8 64-bit (sol) AIX 5.1 (copper)
Diffstat (limited to 'c++/src/H5IdComponent.h')
-rw-r--r--c++/src/H5IdComponent.h21
1 files changed, 17 insertions, 4 deletions
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