summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5Attribute.cpp21
-rw-r--r--c++/src/H5Attribute.h4
-rw-r--r--c++/src/H5DataSet.cpp70
-rw-r--r--c++/src/H5DataSet.h5
-rw-r--r--c++/src/H5DataType.cpp70
-rw-r--r--c++/src/H5DataType.h5
-rw-r--r--c++/src/H5Group.cpp57
-rw-r--r--c++/src/H5Group.h5
-rw-r--r--c++/src/H5IdComponent.cpp18
-rw-r--r--c++/src/H5IdComponent.h3
-rw-r--r--c++/src/H5Object.cpp94
-rw-r--r--c++/src/H5Object.h11
12 files changed, 263 insertions, 100 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index fd08744..c90076c 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -323,27 +323,6 @@ hsize_t Attribute::getStorageSize() const
}
//--------------------------------------------------------------------------
-// Function: Attribute::dereference
-// Purpose Dereference a ref into a DataSet object.
-// Parameters
-// ref - IN: Reference pointer
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - Oct, 2006
-// Modification
-// May 2008 - BMR
-// Moved from IdComponent into H5File, H5Object, and Attribute
-//--------------------------------------------------------------------------
-Attribute::Attribute(H5Object& obj, void* ref) : AbstractDs(), IdComponent()
-{
- id = obj.p_dereference(ref);
-}
-
-Attribute::Attribute(H5File& h5file, void* ref) : AbstractDs(), IdComponent()
-{
- id = h5file.p_dereference(ref);
-}
-
-//--------------------------------------------------------------------------
// Function: Attribute::getId
// Purpose: Get the id of this attribute
// Description:
diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h
index 7d7ca8d..9cf91ba 100644
--- a/c++/src/H5Attribute.h
+++ b/c++/src/H5Attribute.h
@@ -48,10 +48,6 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent {
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"); }
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index 6d7502a..494d3ea 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -35,6 +35,7 @@
#include "H5DataSpace.h"
#include "H5AbstractDs.h"
#include "H5File.h"
+#include "H5Attribute.h"
#include "H5DataSet.h"
#ifndef H5_NO_NAMESPACE
@@ -77,24 +78,75 @@ DataSet::DataSet(const DataSet& original) : AbstractDs(original), H5Object(origi
//--------------------------------------------------------------------------
// Function: DataSet overload constructor - dereference
-///\brief Given a reference to some object, returns that dataset
-/// obj - IN: Dataset reference object is in or location of
-/// object that the dataset is located within.
+///\brief Given a reference, ref, to an hdf5 dataset, creates a
+/// DataSet object
+///\param obj - IN: Dataset reference object is in or location of
+/// object that the dataset is located within.
///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
///\exception H5::DataSetIException
-///\parDescription
-/// \c obj can be DataSet, Group, H5File, or named DataType, that
+///\par Description
+/// \c obj can be DataSet, Group, H5File, or named DataType, that
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// Jul, 2008
+// Added for application convenience.
+//--------------------------------------------------------------------------
+DataSet::DataSet(H5Object& obj, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object()
+{
+ try {
+ id = p_dereference(obj.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("DataSet constructor - located by object",
+ deref_error.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: DataSet overload constructor - dereference
+///\brief Given a reference, ref, to an hdf5 dataset, creates a
+/// DataSet object
+///\param h5file - IN: Location referenced object is in
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::DataSetIException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// Jul, 2008
+// Added for application convenience.
//--------------------------------------------------------------------------
-DataSet::DataSet(H5Object& obj, void* ref) : AbstractDs(), H5Object()
+DataSet::DataSet(H5File& h5file, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object()
{
- id = obj.p_dereference(ref);
+ try {
+ id = p_dereference(h5file.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("DataSet constructor - located by HDF5 file",
+ deref_error.getDetailMsg());
+ }
}
-DataSet::DataSet(H5File& h5file, void* ref) : AbstractDs(), H5Object()
+//--------------------------------------------------------------------------
+// Function: DataSet overload constructor - dereference
+///\brief Given a reference, ref, to an hdf5 dataset, creates a
+/// DataSet object
+///\param attr - IN: Specifying location where the referenced object is in
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// Jul, 2008
+// Added for application convenience.
+//--------------------------------------------------------------------------
+DataSet::DataSet(Attribute& attr, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object()
{
- id = h5file.p_dereference(ref);
+ try {
+ id = p_dereference(attr.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("DataSet constructor - located by attribute",
+ deref_error.getDetailMsg());
+ }
}
//--------------------------------------------------------------------------
diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h
index f5d13d0..f26d775 100644
--- a/c++/src/H5DataSet.h
+++ b/c++/src/H5DataSet.h
@@ -85,8 +85,9 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
virtual H5std_string fromClass () const { return("DataSet"); }
// Creates a dataset by way of dereference.
- DataSet(H5Object& obj, void* ref);
- DataSet(H5File& file, void* ref);
+ DataSet(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ DataSet(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ DataSet(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
// Default constructor.
DataSet();
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 2b03ffc..9170dc2 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -38,6 +38,7 @@
#include "H5AbstractDs.h"
#include "H5DataSet.h"
#include "H5File.h"
+#include "H5Attribute.h"
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -87,27 +88,74 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object()
//--------------------------------------------------------------------------
// Function: DataType overload constructor - dereference
-///\brief Given a reference to some object, returns that datatype
-///\param obj - IN: Location reference object is in
+///\brief Given a reference, ref, to an hdf5 group, creates a
+/// DataType object
+///\param obj - IN: Specifying location referenced object is in
///\param ref - IN: Reference pointer
-///\parDescription
-/// \c obj can be DataSet, Group, H5File, or named DataType, that
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::ReferenceException
+///\par Description
+/// \c obj can be DataSet, Group, or named DataType, that
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// Jul, 2008
+// Added for application convenience.
//--------------------------------------------------------------------------
- /* DataType::DataType(IdComponent& obj, void* ref) : H5Object()
+DataType::DataType(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Object()
{
- H5Object::dereference(obj, ref);
+ try {
+ id = p_dereference(obj.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("DataType constructor - located by an H5Object",
+ deref_error.getDetailMsg());
+ }
}
- */
-DataType::DataType(H5Object& obj, void* ref) : H5Object()
+
+//--------------------------------------------------------------------------
+// Function: DataType overload constructor - dereference
+///\brief Given a reference, ref, to an hdf5 group, creates a
+/// DataType object
+///\param h5file - IN: Location referenced object is in
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// Jul, 2008
+// Added for application convenience.
+//--------------------------------------------------------------------------
+DataType::DataType(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Object()
{
- id = obj.p_dereference(ref);
+ try {
+ id = p_dereference(h5file.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("DataType constructor - located by an H5File",
+ deref_error.getDetailMsg());
+ }
}
-DataType::DataType(H5File& file, void* ref) : H5Object()
+//--------------------------------------------------------------------------
+// Function: DataType overload constructor - dereference
+///\brief Given a reference, ref, to an hdf5 group, creates a
+/// DataType object
+///\param attr - IN: Specifying location where the referenced object is in
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// Jul, 2008
+// Added for application convenience.
+//--------------------------------------------------------------------------
+DataType::DataType(Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object()
{
- id = file.p_dereference(ref);
+ try {
+ id = p_dereference(attr.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("DataType constructor - located by an Attribute",
+ deref_error.getDetailMsg());
+ }
}
//--------------------------------------------------------------------------
diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h
index 4e7ca03..48aeaf8 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -30,8 +30,9 @@ class H5_DLLCPP DataType : public H5Object {
DataType( const DataType& original );
// Creates a datatype by way of dereference.
- DataType(H5Object& obj, void* ref);
- DataType(H5File& file, void* ref);
+ DataType(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ DataType(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ DataType(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
// Closes this datatype.
virtual void close();
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index 6ae7cf7..02d9338 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -33,6 +33,7 @@
#include "H5DataSpace.h"
#include "H5DataSet.h"
#include "H5CommonFG.h"
+#include "H5Attribute.h"
#include "H5Group.h"
#include "H5File.h"
#include "H5Alltypes.h"
@@ -88,22 +89,62 @@ Group::Group(const hid_t existing_id) : H5Object()
//--------------------------------------------------------------------------
// Function: Group overload constructor - dereference
-///\brief Given a reference to some object, returns that group
-/// obj - IN: Location reference object is in
+///\brief Given a reference, ref, to an hdf5 group, creates a Group object
+///\param obj - IN: Specifying location referenced object is in
///\param ref - IN: Reference pointer
-///\parDescription
-/// \c obj can be DataSet, Group, H5File, or named DataType, that
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::ReferenceException
+///\par Description
+/// \c obj can be DataSet, Group, or named DataType, that
/// is a datatype that has been named by DataType::commit.
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
-Group::Group(H5Object& obj, void* ref) : H5Object()
+Group::Group(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Object()
{
- id = obj.p_dereference(ref);
+ try {
+ id = p_dereference(obj.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("Group constructor - located by an H5Object",
+ deref_error.getDetailMsg());
+ }
}
-Group::Group(H5File& h5file, void* ref) : H5Object()
+//--------------------------------------------------------------------------
+// Function: Group overload constructor - dereference
+///\brief Given a reference, ref, to an hdf5 group, creates a Group object
+///\param h5file - IN: Location referenced object is in
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+//--------------------------------------------------------------------------
+Group::Group(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Object()
{
- id = h5file.p_dereference(ref);
+ try {
+ id = p_dereference(h5file.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("Group constructor - located by an H5File",
+ deref_error.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: Group overload constructor - dereference
+///\brief Given a reference, ref, to an hdf5 group, creates a Group object
+///\param attr - IN: Specifying location where the referenced object is in
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type - default to H5R_OBJECT
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+//--------------------------------------------------------------------------
+Group::Group(Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object()
+{
+ try {
+ id = p_dereference(attr.getId(), ref, ref_type);
+ } catch (ReferenceException deref_error) {
+ throw ReferenceException("Group constructor - located by an Attribute",
+ deref_error.getDetailMsg());
+ }
}
#ifndef H5_NO_DEPRECATED_SYMBOLS
diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h
index d296b84..9978cf0 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -44,8 +44,9 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
virtual hid_t getLocId() const;
// Creates a group by way of dereference.
- Group(H5Object& obj, void* ref);
- Group(H5File& obj, void* ref);
+ Group(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ Group(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ Group(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
// default constructor
Group();
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index 747a479..ef01105 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -299,24 +299,6 @@ H5std_string IdComponent::p_get_file_name() const
return(file_name);
}
-//--------------------------------------------------------------------------
-// Function: H5Object::p_dereference (protected)
-// Purpose Opens the HDF5 object referenced.
-// Parameters
-// ref - IN: Reference pointer
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - Oct, 2006
-//--------------------------------------------------------------------------
-hid_t IdComponent::p_dereference(void* ref)
-{
- hid_t temp_id = H5Rdereference(getId(), H5R_OBJECT, ref);
- if (temp_id < 0)
- {
- throw ReferenceException("", "H5Rdereference failed");
- }
- return(temp_id);
-}
-
//
// Local functions used in this class
//
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index 7f573a1..b217c10 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -44,9 +44,6 @@ class H5_DLLCPP IdComponent {
// Assignment operator.
IdComponent& operator=( const IdComponent& rhs );
- // Opens the HDF5 object referenced.
- hid_t p_dereference(void* ref);
-
// Gets the identifier of this object.
virtual hid_t getId () const = 0;
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index dbfe6f2..2d32014 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -420,41 +420,101 @@ void H5Object::reference(void* ref, const H5std_string& name) const
}
//--------------------------------------------------------------------------
-// Function: H5Object::dereference
-// Purpose Dereference a ref into a DataSet object.
+// Function: H5Object::p_dereference (protected)
+// Purpose Dereference a ref into an hdf5 object.
// Parameters
-// ref - IN: Reference pointer
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - Oct, 2006
+// loc_id - IN: An hdf5 identifier specifying the location of the
+// referenced object
+// ref - IN: Reference pointer
+// ref_type - IN: Reference type
+// Exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
// Modification
// May 2008 - BMR
-// Moved from IdComponent into H5File and H5Object
+// Moved from IdComponent.
//--------------------------------------------------------------------------
-void H5Object::dereference(H5File& h5file, void* ref)
+hid_t H5Object::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type)
{
hid_t temp_id;
- try {
- temp_id = h5file.p_dereference(ref);
- }
- catch (ReferenceException ref_err) {
- throw (inMemFunc("dereference"), ref_err.getDetailMsg());
+ temp_id = H5Rdereference(loc_id, ref_type, ref);
+ if (temp_id < 0)
+ {
+ throw ReferenceException("", "H5Rdereference failed");
}
// No failure, set id to the object
+ return(temp_id);
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Object::dereference
+///\brief Dereferences a reference into an HDF5 object, given an HDF5 object.
+///\param obj - IN: Object specifying the location of the referenced object
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// May, 2008
+// Corrected missing parameters. - BMR
+//--------------------------------------------------------------------------
+void H5Object::dereference(H5Object& obj, const void* ref, H5R_type_t ref_type)
+{
+ hid_t temp_id;
+ try {
+ temp_id = p_dereference(obj.getId(), ref, ref_type);
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Object::dereference - located by object", E.getDetailMsg());
+ }
p_setId(temp_id);
}
-void H5Object::dereference(H5Object& obj, void* ref)
+//--------------------------------------------------------------------------
+// Function: H5Object::dereference
+///\brief Dereferences a reference into an HDF5 object, given an HDF5 file.
+///\param h5file - IN: HDF5 file specifying the location of the referenced object
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// May, 2008
+// Corrected missing parameters. - BMR
+//--------------------------------------------------------------------------
+void H5Object::dereference(H5File& h5file, const void* ref, H5R_type_t ref_type)
{
hid_t temp_id;
try {
- temp_id = obj.p_dereference(ref);
+ temp_id = p_dereference(h5file.getId(), ref, ref_type);
}
- catch (ReferenceException ref_err) {
- throw (inMemFunc("dereference"), ref_err.getDetailMsg());
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Object::dereference - located by file", E.getDetailMsg());
}
+ p_setId(temp_id);
+}
- // No failure, set id to the object
+//--------------------------------------------------------------------------
+// Function: H5Object::dereference
+///\brief Dereferences a reference into an HDF5 object, given an attribute.
+///\param attr - IN: Attribute specifying the location of the referenced object
+///\param ref - IN: Reference pointer
+///\param ref_type - IN: Reference type
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - Oct, 2006
+// Modification
+// May, 2008
+// Corrected missing parameters. - BMR
+//--------------------------------------------------------------------------
+void H5Object::dereference(Attribute& attr, const void* ref, H5R_type_t ref_type)
+{
+ hid_t temp_id;
+ try {
+ temp_id = p_dereference(attr.getId(), ref, ref_type);
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Object::dereference - located by attribute", E.getDetailMsg());
+ }
p_setId(temp_id);
}
diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h
index 49655a1..4ac417b 100644
--- a/c++/src/H5Object.h
+++ b/c++/src/H5Object.h
@@ -86,9 +86,11 @@ class H5_DLLCPP H5Object : public IdComponent {
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);
+ // Open a referenced HDF5 object whose location is specified by either
+ // a file, an HDF5 object, or an attribute.
+ void dereference(H5File& h5file, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ void dereference(H5Object& obj, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
+ void dereference(Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
// Copy constructor: makes copy of an H5Object object.
H5Object(const H5Object& original);
@@ -110,6 +112,9 @@ class H5_DLLCPP H5Object : public IdComponent {
// 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;
+ // Dereferences a ref into an hdf5 id.
+ hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type);
+
#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;