summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5Attribute.cpp6
-rw-r--r--c++/src/H5Attribute.h7
-rw-r--r--c++/src/H5DataSet.cpp6
-rw-r--r--c++/src/H5DataSet.h5
-rw-r--r--c++/src/H5DataSpace.cpp6
-rw-r--r--c++/src/H5DataSpace.h5
-rw-r--r--c++/src/H5DataType.cpp6
-rw-r--r--c++/src/H5DataType.h5
-rw-r--r--c++/src/H5FaccProp.cpp2
-rw-r--r--c++/src/H5File.cpp6
-rw-r--r--c++/src/H5File.h7
-rw-r--r--c++/src/H5Group.cpp6
-rw-r--r--c++/src/H5Group.h5
-rw-r--r--c++/src/H5IdComponent.cpp33
-rw-r--r--c++/src/H5IdComponent.h6
-rw-r--r--c++/src/H5Object.cpp4
-rw-r--r--c++/src/H5PropList.cpp6
-rw-r--r--c++/src/H5PropList.h4
18 files changed, 90 insertions, 35 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index bdb6276..64993a2 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -359,7 +359,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
@@ -370,14 +370,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..7d7ca8d 100644
--- a/c++/src/H5Attribute.h
+++ b/c++/src/H5Attribute.h
@@ -64,13 +64,16 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent {
// Default constructor
Attribute();
- // Gets/Sets the attribute id.
+ // Gets the attribute id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
// Destructor: properly terminates access to this attribute.
virtual ~Attribute();
+ protected:
+ // Sets the attribute id.
+ virtual void p_setId(const hid_t new_id);
+
private:
hid_t id; // HDF5 attribute id
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..f5d13d0 100644
--- a/c++/src/H5DataSet.h
+++ b/c++/src/H5DataSet.h
@@ -99,7 +99,6 @@ 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);
// Destructor: properly terminates access to this dataset.
virtual ~DataSet();
@@ -112,6 +111,10 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
// defined in AbstractDs for generic datatype and specific
// sub-types
virtual hid_t p_get_type() const;
+
+ protected:
+ // Sets the dataset id.
+ virtual void p_setId(const hid_t new_id);
};
#ifndef H5_NO_NAMESPACE
}
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..80842f7 100644
--- a/c++/src/H5DataSpace.h
+++ b/c++/src/H5DataSpace.h
@@ -114,13 +114,16 @@ class H5_DLLCPP DataSpace : public IdComponent {
// Gets the dataspace id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
// Destructor: properly terminates access to this dataspace.
virtual ~DataSpace();
private:
hid_t id; // HDF5 dataspace id
+
+ protected:
+ // Sets the dataspace id.
+ virtual void p_setId(const hid_t new_id);
};
#ifndef H5_NO_NAMESPACE
}
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..4e7ca03 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -119,13 +119,16 @@ class H5_DLLCPP DataType : public H5Object {
// Gets the datatype id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
// Destructor: properly terminates access to this datatype.
virtual ~DataType();
protected:
hid_t id; // HDF5 datatype id
+
+ // Sets the datatype id.
+ virtual void p_setId(const hid_t new_id);
+
private:
void p_commit(hid_t loc_id, const char* name);
};
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..b49118e 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -109,9 +109,8 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
// Copy constructor: makes a copy of the original H5File object.
H5File(const H5File& original);
- // Gets/Sets the HDF5 file id.
+ // Gets the HDF5 file id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
// H5File destructor.
virtual ~H5File();
@@ -136,6 +135,10 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
// Retrieves a dataspace with the region pointed to selected.
hid_t p_get_region(void *ref, H5R_type_t ref_type) const;
+ protected:
+ // Sets the HDF5 file id.
+ virtual void p_setId(const hid_t new_id);
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
};
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..d296b84 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -55,7 +55,6 @@ 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);
// Destructor
virtual ~Group();
@@ -65,6 +64,10 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
private:
hid_t id; // HDF5 group id
+
+ protected:
+ // Sets the group id.
+ virtual void p_setId(const hid_t new_id);
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index b22d869..a068b20 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -176,7 +176,7 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
}
// copy the data members from the rhs object
- setId(rhs.getId());
+ p_setId(rhs.getId());
incRefCount(getId()); // a = b, so there are two objects with the same
// hdf5 id
}
@@ -184,6 +184,37 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
}
//--------------------------------------------------------------------------
+// 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..7f573a1 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 );
@@ -88,6 +88,10 @@ class H5_DLLCPP IdComponent {
// Verifies that the given id is valid.
static bool p_valid_id(const hid_t obj_id);
+ // 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;
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
}; // end class IdComponent
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index b2bdefb..9dafea8 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -441,7 +441,7 @@ void H5Object::dereference(H5File& h5file, void* ref)
}
// No failure, set id to the object
- setId(temp_id);
+ p_setId(temp_id);
}
void H5Object::dereference(H5Object& obj, void* ref)
@@ -455,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..5dfa538 100644
--- a/c++/src/H5PropList.h
+++ b/c++/src/H5PropList.h
@@ -105,13 +105,15 @@ class H5_DLLCPP PropList : public IdComponent {
// Gets the property list id.
virtual hid_t getId() const;
- virtual void setId(const hid_t new_id);
// Destructor: properly terminates access to this property list.
virtual ~PropList();
protected:
hid_t id; // HDF5 property list id
+
+ // Sets the property list id.
+ virtual void p_setId(const hid_t new_id);
};
#ifndef H5_NO_NAMESPACE