summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-02 14:44:57 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2008-07-02 14:44:57 (GMT)
commitd9533d055c7f306e66e5f972068c77c939d6fc16 (patch)
treeaf5d0f7fc67f008e2f718c6913ab3f7baf777abe
parent0e1432a18f999074e48e455aad6ee61c93f27ed1 (diff)
downloadhdf5-d9533d055c7f306e66e5f972068c77c939d6fc16.zip
hdf5-d9533d055c7f306e66e5f972068c77c939d6fc16.tar.gz
hdf5-d9533d055c7f306e66e5f972068c77c939d6fc16.tar.bz2
[svn-r15308] 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)
-rw-r--r--c++/src/H5AbstractDs.h5
-rw-r--r--c++/src/H5Attribute.h19
-rw-r--r--c++/src/H5Classes.h1
-rw-r--r--c++/src/H5DataSet.h19
-rw-r--r--c++/src/H5DataSpace.h7
-rw-r--r--c++/src/H5DataType.h18
-rw-r--r--c++/src/H5DxferProp.h1
-rw-r--r--c++/src/H5File.h30
-rw-r--r--c++/src/H5Group.h17
-rw-r--r--c++/src/H5IdComponent.h33
-rw-r--r--c++/src/H5Object.h29
-rw-r--r--c++/src/H5PropList.h7
12 files changed, 118 insertions, 68 deletions
diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h
index 2f4e520..c98e5e1 100644
--- a/c++/src/H5AbstractDs.h
+++ b/c++/src/H5AbstractDs.h
@@ -33,7 +33,7 @@ class FloatType;
class IntType;
class StrType;
class VarLenType;
-class H5_DLLCPP AbstractDs : public H5Object {
+class H5_DLLCPP AbstractDs {
public:
// Gets a copy the datatype of that this abstract dataset uses.
// Note that this datatype is a generic one and can only be accessed
@@ -62,6 +62,9 @@ class H5_DLLCPP AbstractDs : public H5Object {
// dataset - pure virtual.
virtual hsize_t getStorageSize() const = 0;
+ // Returns this class name
+ virtual H5std_string fromClass() const = 0;
+
// Copy constructor
AbstractDs( const AbstractDs& original );
diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h
index 513b6ab..49faeea 100644
--- a/c++/src/H5Attribute.h
+++ b/c++/src/H5Attribute.h
@@ -21,11 +21,14 @@
namespace H5 {
#endif
-class H5_DLLCPP Attribute : public AbstractDs {
+class H5_DLLCPP Attribute : public AbstractDs, public IdComponent {
public:
// Closes this attribute.
virtual void close();
+ // Gets the name of the file, in which this attribute belongs.
+ H5std_string getFileName() const;
+
// Gets the name of this attribute.
ssize_t getName( size_t buf_size, H5std_string& attr_name ) const;
H5std_string getName( size_t buf_size ) const; // returns name, not its length
@@ -45,11 +48,15 @@ class H5_DLLCPP Attribute : public AbstractDs {
void write(const DataType& mem_type, const void *buf ) const;
void write(const DataType& mem_type, const H5std_string& strg ) const;
+ // Creates an attribute by way of dereference.
+ Attribute(H5Object& obj, void* ref);
+ Attribute(H5File& file, void* ref);
+
// Returns this class name
virtual H5std_string fromClass () const { return("Attribute"); }
- // Creates a copy of an existing attribute using the attribute id
- Attribute( const hid_t attr_id );
+ // Creates a copy of an existing attribute using the attribute id
+ Attribute( const hid_t attr_id );
// Copy constructor: makes a copy of an existing Attribute object.
Attribute( const Attribute& original );
@@ -57,10 +64,16 @@ class H5_DLLCPP Attribute : public AbstractDs {
// Default constructor
Attribute();
+ // Gets/Sets 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();
private:
+ hid_t id; // HDF5 attribute id
+
// This function contains the common code that is used by
// getTypeClass and various API functions getXxxType
// defined in AbstractDs for generic datatype and specific
diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h
index 03f1257..f691548 100644
--- a/c++/src/H5Classes.h
+++ b/c++/src/H5Classes.h
@@ -21,7 +21,6 @@
namespace H5 {
#endif
class Exception;
- class ReferenceCounter;
class IdComponent;
class H5Object;
class PropList;
diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h
index 7323f52..f968932 100644
--- a/c++/src/H5DataSet.h
+++ b/c++/src/H5DataSet.h
@@ -23,7 +23,7 @@
namespace H5 {
#endif
-class H5_DLLCPP DataSet : public AbstractDs {
+class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
public:
// Close this dataset.
virtual void close();
@@ -81,19 +81,12 @@ class H5_DLLCPP DataSet : public AbstractDs {
// Retrieves a dataspace with the region pointed to selected.
DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
- // Creates a reference to a named Hdf5 object or to a dataset region
- // in this object.
- void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const;
-
- // Creates a reference to a named Hdf5 object in this object.
- void* Reference(const char* name) const; // will be obsolete
- void* Reference(const H5std_string& name) const; // will be obsolete
-
// Returns this class name
virtual H5std_string fromClass () const { return("DataSet"); }
// Creates a dataset by way of dereference.
- DataSet(IdComponent& obj, void* ref);
+ DataSet(H5Object& obj, void* ref);
+ DataSet(H5File& file, void* ref);
// Default constructor.
DataSet();
@@ -104,10 +97,16 @@ class H5_DLLCPP DataSet : public AbstractDs {
// Creates a copy of an existing DataSet using its id.
DataSet(const hid_t existing_id);
+ // 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();
private:
+ hid_t id; // HDF5 dataset id
+
// This function contains the common code that is used by
// getTypeClass and various API functions getXxxType
// defined in AbstractDs for generic datatype and specific
diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h
index e1c5ba4..1173c26 100644
--- a/c++/src/H5DataSpace.h
+++ b/c++/src/H5DataSpace.h
@@ -112,8 +112,15 @@ class H5_DLLCPP DataSpace : public IdComponent {
// Copy constructor: makes a copy of the original DataSpace object.
DataSpace(const DataSpace& original);
+ // 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
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h
index 588a57a..509dd49 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -30,7 +30,8 @@ class H5_DLLCPP DataType : public H5Object {
DataType( const DataType& original );
// Creates a datatype by way of dereference.
- DataType(IdComponent& obj, void* ref);
+ DataType(H5Object& obj, void* ref);
+ DataType(H5File& file, void* ref);
// Closes this datatype.
virtual void close();
@@ -99,14 +100,6 @@ class H5_DLLCPP DataType : public H5Object {
// Checks whether this datatype is a variable-length string.
bool isVariableStr() const;
- // Creates a reference to a named HDF5 object or to a dataset region
- // in this object.
- void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; // will be obsolete
-
- // Creates a reference to a named HDF5 object in this object.
- void* Reference(const char* name) const; // will be obsolete
- void* Reference(const H5std_string& name) const; // will be obsolete
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Retrieves the type of object that an object reference points to.
H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
@@ -124,8 +117,15 @@ class H5_DLLCPP DataType : public H5Object {
// Default constructor
DataType();
+ // 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
private:
void p_commit(hid_t loc_id, const char* name);
};
diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h
index 8da29c4..11e15fc 100644
--- a/c++/src/H5DxferProp.h
+++ b/c++/src/H5DxferProp.h
@@ -104,7 +104,6 @@ class H5_DLLCPP DSetMemXferPropList : public PropList {
// Noop destructor
virtual ~DSetMemXferPropList();
-
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index b239efe..92b1e20 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -89,11 +89,10 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
// Creates a reference to a named HDF5 object or to a dataset region
// in this object.
- void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; // will be obsolete
-
- // Creates a reference to a named Hdf5 object in this object.
- void* Reference(const char* name) const; // will be obsolete
- void* Reference(const H5std_string& name) const; // will be obsolete
+ void reference(void* ref, const char* name, const DataSpace& dataspace,
+ H5R_type_t ref_type = H5R_DATASET_REGION) const;
+ void reference(void* ref, const char* name) const;
+ void reference(void* ref, const H5std_string& name) const;
// Returns this class name
virtual H5std_string fromClass () const { return("H5File"); }
@@ -110,14 +109,35 @@ 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.
+ virtual hid_t getId() const;
+ virtual void setId(const hid_t new_id);
+
// H5File destructor.
virtual ~H5File();
private:
+ hid_t id; // HDF5 file id
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
// This function is private and contains common code between the
// constructors taking a string or a char*
void p_get_file( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist );
+ // Creates a reference to an HDF5 object or a dataset region.
+ void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ // Retrieves the type of object that an object reference points to.
+ H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+ // Retrieves a dataspace with the region pointed to selected.
+ hid_t p_get_region(void *ref, H5R_type_t ref_type) const;
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h
index 5df85bb..091ea72 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -34,14 +34,6 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Retrieves a dataspace with the region pointed to selected.
DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
- // Creates a reference to a named Hdf5 object or to a dataset region
- // in this object.
- void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; // will be obsolete
-
- // Creates a reference to a named Hdf5 object in this object.
- void* Reference(const char* name) const; // will be obsolete
- void* Reference(const H5std_string& name) const; // will be obsolete
-
// Returns this class name
virtual H5std_string fromClass () const { return("Group"); }
@@ -52,7 +44,8 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
virtual hid_t getLocId() const;
// Creates a group by way of dereference.
- Group(IdComponent& obj, void* ref);
+ Group(H5Object& obj, void* ref);
+ Group(H5File& obj, void* ref);
// default constructor
Group();
@@ -60,12 +53,18 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Copy constructor: makes a copy of the original object
Group(const Group& original);
+ // Gets the group id.
+ virtual hid_t getId() const;
+ virtual void setId(const hid_t new_id);
+
// Destructor
virtual ~Group();
// Creates a copy of an existing group using its id.
Group( const hid_t group_id );
+ private:
+ hid_t id; // HDF5 group id
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index facdefd..c34b2da 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -44,16 +44,14 @@ class H5_DLLCPP IdComponent {
// Assignment operator.
IdComponent& operator=( const IdComponent& rhs );
- void reference(void* ref, const char* name, const DataSpace& dataspace,
- H5R_type_t ref_type = H5R_DATASET_REGION) const;
- void reference(void* ref, const char* name) const;
- void reference(void* ref, const H5std_string& name) const;
+ // Opens the HDF5 object referenced.
+ hid_t p_dereference(void* ref);
- // Open a referenced HDF5 object.
- void dereference(IdComponent& obj, void* ref);
+ // Gets the identifier of this object.
+ virtual hid_t getId () const = 0;
// Sets the identifier of this object to a new value.
- void setId(const hid_t new_id);
+ virtual void setId(const hid_t new_id) = 0;
// Creates an object to hold an HDF5 identifier.
IdComponent( const hid_t h5_id );
@@ -61,9 +59,6 @@ class H5_DLLCPP IdComponent {
// Copy constructor: makes copy of the original IdComponent object.
IdComponent( const IdComponent& original );
- // 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.
@@ -83,7 +78,6 @@ class H5_DLLCPP IdComponent {
protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- hid_t id; // HDF5 object id
// Default constructor.
IdComponent();
@@ -91,23 +85,8 @@ class H5_DLLCPP IdComponent {
// Gets the name of the file, in which an HDF5 object belongs.
H5std_string p_get_file_name() const;
- // Gets the id of the H5 file in which the given object is located.
- hid_t p_get_file_id();
-
- // Creates a reference to an HDF5 object or a dataset region.
- void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
- void* p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const; // will be removed
-
-#ifndef H5_NO_DEPRECATED_SYMBOLS
- // Retrieves the type of object that an object reference points to.
- H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
- // 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(const hid_t obj_id) const;
+ static bool p_valid_id(const hid_t obj_id);
#endif // DOXYGEN_SHOULD_SKIP_THIS
diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h
index 77de529..49655a1 100644
--- a/c++/src/H5Object.h
+++ b/c++/src/H5Object.h
@@ -20,8 +20,7 @@
#include "H5Classes.h" // constains forward class declarations
// H5Object is a baseclass. It has these subclasses:
-// Group, AbstractDs, and DataType.
-// AbstractDs, in turn, has subclasses DataSet and Attribute.
+// Group, DataSet, and DataType.
// DataType, in turn, has several specific datatypes as subclasses.
#ifndef H5_NO_NAMESPACE
@@ -80,6 +79,17 @@ class H5_DLLCPP H5Object : public IdComponent {
void renameAttr(const char* oldname, const char* newname) const;
void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
+ // Creates a reference to a named Hdf5 object or to a dataset region
+ // in this object.
+ void reference(void* ref, const char* name, const DataSpace& dataspace,
+ H5R_type_t ref_type = H5R_DATASET_REGION) const;
+ void reference(void* ref, const char* name) const;
+ void reference(void* ref, const H5std_string& name) const;
+
+ // Open a referenced HDF5 object.
+ void dereference(H5File& h5file, void* ref);
+ void dereference(H5Object& obj, void* ref);
+
// Copy constructor: makes copy of an H5Object object.
H5Object(const H5Object& original);
@@ -93,6 +103,21 @@ class H5_DLLCPP H5Object : public IdComponent {
// Creates a copy of an existing object giving the object id
H5Object( const hid_t object_id );
+
+ // Gets the id of the H5 file in which the given object is located.
+ hid_t p_get_file_id();
+
+ // Creates a reference to an HDF5 object or a dataset region.
+ void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+ // Retrieves the type of object that an object reference points to.
+ H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+ // Retrieves a dataspace with the region pointed to selected.
+ hid_t p_get_region(void *ref, H5R_type_t ref_type) const;
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
}; /* end class H5Object */
diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h
index 09ea6f1..75a3d21 100644
--- a/c++/src/H5PropList.h
+++ b/c++/src/H5PropList.h
@@ -103,8 +103,15 @@ class H5_DLLCPP PropList : public IdComponent {
// Copy constructor: creates a copy of a PropList object.
PropList(const PropList& original);
+ // 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
};
#ifndef H5_NO_NAMESPACE