summaryrefslogtreecommitdiffstats
path: root/c++/src
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2012-09-27 23:26:16 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2012-09-27 23:26:16 (GMT)
commit5fcec401bd019aa0928e11c3d4cff62ea064c1ef (patch)
treeebd883ef4019a33ef8e5b4b34bf53e815067a7cb /c++/src
parente488529430ae2f90f9d327959a4610d5786a3350 (diff)
downloadhdf5-5fcec401bd019aa0928e11c3d4cff62ea064c1ef.zip
hdf5-5fcec401bd019aa0928e11c3d4cff62ea064c1ef.tar.gz
hdf5-5fcec401bd019aa0928e11c3d4cff62ea064c1ef.tar.bz2
[svn-r22836] Purpose: Fix bug HDFFV-533 and add other missing functions
Description: In this bug, H5File doesn't have the ability to create attribute. The following changes will provide that functionality and several others that were also missing: - Added an abstract class H5Location in between IdComponent and H5Object. - New class structure of IdComponent, H5Location, H5Object, H5File IdComponent | H5Location / \ H5Object H5File - Wrappers in H5Object were moved to H5Location because the related C functions take either file, group, dataset, or named datatype ID. - Added wrapper for H5Rget_obj_type2 - Added tests for file attributes and H5Rget_obj_type2 wrapper Platforms tested: Linux/32 2.6 (jam) Linux/64 2.6 (koala) SunOS 5.10 (linew)
Diffstat (limited to 'c++/src')
-rw-r--r--c++/src/H5AbstractDs.cpp5
-rw-r--r--c++/src/H5Attribute.cpp25
-rw-r--r--c++/src/H5Attribute.h4
-rw-r--r--c++/src/H5Classes.h1
-rw-r--r--c++/src/H5Cpp.h1
-rw-r--r--c++/src/H5DataSet.cpp27
-rw-r--r--c++/src/H5DataSet.h5
-rw-r--r--c++/src/H5DataType.cpp25
-rw-r--r--c++/src/H5DataType.h5
-rw-r--r--c++/src/H5File.cpp157
-rw-r--r--c++/src/H5File.h20
-rw-r--r--c++/src/H5Group.cpp27
-rw-r--r--c++/src/H5Group.h5
-rw-r--r--c++/src/H5Location.cpp669
-rw-r--r--c++/src/H5Location.h146
-rw-r--r--c++/src/H5Object.cpp501
-rw-r--r--c++/src/H5Object.h81
-rw-r--r--c++/src/Makefile.am17
-rw-r--r--c++/src/Makefile.in34
19 files changed, 898 insertions, 857 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp
index 9cf1ee8..e6cacf9 100644
--- a/c++/src/H5AbstractDs.cpp
+++ b/c++/src/H5AbstractDs.cpp
@@ -25,11 +25,6 @@
#include "H5CommonFG.h"
#include "H5Alltypes.h"
-#include <iostream> // remove when done
-
- using std::cerr;
- using std::endl;
-
#ifndef H5_NO_NAMESPACE
namespace H5 {
#endif
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 226ae5c..120ed39 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -385,6 +385,31 @@ hsize_t Attribute::getStorageSize() const
}
//--------------------------------------------------------------------------
+// Function: Attribute::flush
+///\brief Flushes all buffers associated with a file specified by
+/// this attribute, to disk.
+///\param scope - IN: Specifies the scope of the flushing action,
+/// which can be either of these values:
+/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file
+/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file
+///\exception H5::AttributeIException
+///\par Description
+/// This attribute is used to identify the file to be flushed.
+// Programmer Binh-Minh Ribler - 2012
+// Modification
+// Sep 2012 - BMR
+// Duplicated from H5Location
+//--------------------------------------------------------------------------
+void Attribute::flush(H5F_scope_t scope) const
+{
+ herr_t ret_value = H5Fflush(getId(), scope);
+ if( ret_value < 0 )
+ {
+ throw AttributeIException("Attribute::flush", "H5Fflush failed");
+ }
+}
+
+//--------------------------------------------------------------------------
// Function: Attribute::getId
// Purpose: Get the id of this attribute
// Description:
diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h
index 284e5bc..ff4dac6 100644
--- a/c++/src/H5Attribute.h
+++ b/c++/src/H5Attribute.h
@@ -51,6 +51,10 @@ 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;
+ // Flushes all buffers associated with the file specified by this
+ // attribute to disk
+ void flush( H5F_scope_t scope ) const;
+
// Returns this class name
virtual H5std_string fromClass () const { return("Attribute"); }
diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h
index f691548..c3b61ca 100644
--- a/c++/src/H5Classes.h
+++ b/c++/src/H5Classes.h
@@ -22,6 +22,7 @@ namespace H5 {
#endif
class Exception;
class IdComponent;
+ class H5Location;
class H5Object;
class PropList;
class FileCreatPropList;
diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h
index 75d82ba..ddf4f19 100644
--- a/c++/src/H5Cpp.h
+++ b/c++/src/H5Cpp.h
@@ -22,6 +22,7 @@
#include "H5IdComponent.h"
#include "H5DataSpace.h"
#include "H5PropList.h"
+#include "H5Location.h"
#include "H5Object.h"
#include "H5AbstractDs.h"
#include "H5Attribute.h"
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index f7aaa72..624aa6f 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -644,33 +644,6 @@ void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space)
}
}
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-//--------------------------------------------------------------------------
-// Function: DataSet::getObjType
-///\brief Retrieves the type of object that an object reference points to.
-///\param ref_type - IN: Type of reference to query, valid values are:
-/// \li \c H5R_OBJECT - Reference is an object reference.
-/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference.
-///\param ref - IN: Reference to query
-///\return An object type, which can be one of the following:
-/// \li \c H5G_LINK (0) - Object is a symbolic link.
-/// \li \c H5G_GROUP (1) - Object is a group.
-/// \li \c H5G_DATASET (2) - Object is a dataset.
-/// \li \c H5G_TYPE (3) - Object is a named datatype
-///\exception H5::DataSetIException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-H5G_obj_t DataSet::getObjType(void *ref, H5R_type_t ref_type) const
-{
- try {
- return(p_get_obj_type(ref, ref_type));
- }
- catch (IdComponentException E) {
- throw DataSetIException("DataSet::getObjType", E.getDetailMsg());
- }
-}
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
//--------------------------------------------------------------------------
// Function: DataSet::getRegion
///\brief Retrieves a dataspace with the region pointed to selected.
diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h
index 3d9183d..406f7e2 100644
--- a/c++/src/H5DataSet.h
+++ b/c++/src/H5DataSet.h
@@ -76,11 +76,6 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs {
// Iterates the selected elements in the specified dataspace - not implemented in C++ style yet
int iterateElems( void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL );
-#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;
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
// Retrieves a dataspace with the region pointed to selected.
DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 3edb163..7533da2 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -679,31 +679,6 @@ bool DataType::isVariableStr() const
}
}
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-//--------------------------------------------------------------------------
-// Function: DataType::getObjType
-///\brief Retrieves the type of object that an object reference points to.
-///\param ref - IN: Reference to query
-///\param ref_type - IN: Type of reference to query
-///\return Object type, which can be one of the following:
-/// \li \c H5G_LINK Object is a symbolic link.
-/// \li \c H5G_GROUP Object is a group.
-/// \li \c H5G_DATASET Object is a dataset.
-/// \li \c H5G_TYPE Object is a named datatype
-///\exception H5::DataTypeIException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-H5G_obj_t DataType::getObjType(void *ref, H5R_type_t ref_type) const
-{
- try {
- return(p_get_obj_type(ref, ref_type));
- }
- catch (IdComponentException E) {
- throw DataTypeIException(inMemFunc("getObjType"), E.getDetailMsg());
- }
-}
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
//--------------------------------------------------------------------------
// Function: DataType::getRegion
///\brief Retrieves a dataspace with the region pointed to selected.
diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h
index 48aeaf8..258bdc7 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -101,11 +101,6 @@ class H5_DLLCPP DataType : public H5Object {
// Checks whether this datatype is a variable-length string.
bool isVariableStr() const;
-#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;
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
// Retrieves a dataspace with the region pointed to selected.
DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index da0241f..d023001 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -50,7 +50,7 @@ namespace H5 {
///\brief Default constructor: creates a stub H5File object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File() : IdComponent(), id(0) {}
+H5File::H5File() : H5Location(0) {}
//--------------------------------------------------------------------------
// Function: H5File overloaded constructor
@@ -79,7 +79,7 @@ H5File::H5File() : IdComponent(), id(0) {}
/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-Create
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent(0)
+H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(0)
{
p_get_file(name, flags, create_plist, access_plist);
}
@@ -97,7 +97,7 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c
/// FileCreatPropList::DEFAULT
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent(0)
+H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(0)
{
p_get_file(name.c_str(), flags, create_plist, access_plist);
}
@@ -140,32 +140,13 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro
///\param original - IN: H5File instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5File::H5File(const H5File& original) : IdComponent(original)
+H5File::H5File(const H5File& original) : H5Location(original)
{
id = original.getId();
incRefCount(); // increment number of references to this id
}
//--------------------------------------------------------------------------
-// Function: H5File::flush
-///\brief Flushes all buffers associated with a file to disk.
-///\param scope - IN: Specifies the scope of the flushing action,
-/// which can be either of these values:
-/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file
-/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file
-///\exception H5::FileIException
-// Programmer Binh-Minh Ribler - Dec. 2005
-//--------------------------------------------------------------------------
-void H5File::flush(H5F_scope_t scope) const
-{
- herr_t ret_value = H5Fflush( id, scope );
- if( ret_value < 0 )
- {
- throw FileIException("H5File::flush", "H5Fflush failed");
- }
-}
-
-//--------------------------------------------------------------------------
// Function: H5File::isHdf5
///\brief Determines whether a file in HDF5 format.
///\param name - IN: Name of the file
@@ -489,49 +470,6 @@ void H5File::getVFDHandle(void **file_handle) const
}
}
-//--------------------------------------------------------------------------
-// Function: H5File::getFileName
-///\brief Gets the name of this file.
-///\return File name
-///\exception H5::FileIException
-// Programmer Binh-Minh Ribler - Jul, 2004
-//--------------------------------------------------------------------------
-H5std_string H5File::getFileName() const
-{
- try {
- return(p_get_file_name());
- }
- catch (IdComponentException E) {
- throw FileIException("H5File::getFileName", E.getDetailMsg());
- }
-}
-
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-//--------------------------------------------------------------------------
-// Function: H5File::getObjType
-///\brief Retrieves the type of object that an object reference points to.
-///\param ref - IN: Reference to query
-///\param ref_type - IN: Type of reference, valid values are:
-/// \li \c H5R_OBJECT - Reference is an object reference
-/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference
-///\return Object type, which can be one of the following:
-/// \li \c H5G_LINK - Object is a symbolic link.
-/// \li \c H5G_GROUP - Object is a group.
-/// \li \c H5G_DATASET - Object is a dataset.
-/// \li \c H5G_TYPE - Object is a named datatype
-///\exception H5::FileIException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-H5G_obj_t H5File::getObjType(void *ref, H5R_type_t ref_type) const
-{
- try {
- return(p_get_obj_type(ref, ref_type));
- }
- catch (IdComponentException E) {
- throw FileIException("H5File::getObjType", E.getDetailMsg());
- }
-}
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
//--------------------------------------------------------------------------
// Function: H5File::getRegion
@@ -593,93 +531,6 @@ void H5File::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t
}
}
-//--------------------------------------------------------------------------
-// Function: H5File::reference
-///\brief Creates a reference to an HDF5 object or a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced
-///\param dataspace - IN: Dataspace with selection
-///\param ref_type - IN: Type of reference to query, valid values are:
-/// \li \c H5R_OBJECT - Reference is an object reference
-/// \li \c H5R_DATASET_REGION - Reference is a dataset region
-/// reference - this is the default
-///\exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void H5File::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const
-{
- try {
- p_reference(ref, name, dataspace.getId(), ref_type);
- }
- catch (IdComponentException E) {
- throw IdComponentException("H5File::reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5File::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it only creates
-/// a reference to an HDF5 object, not to a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c char pointer
-///\exception H5::IdComponentException
-///\par Description
-// This function passes H5R_OBJECT and -1 to the protected
-// function for it to pass to the C API H5Rcreate
-// to create a reference to the named object.
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void H5File::reference(void* ref, const char* name) const
-{
- try {
- p_reference(ref, name, -1, H5R_OBJECT);
- }
- catch (IdComponentException E) {
- throw IdComponentException("H5File::reference", E.getDetailMsg());
- }
-}
-//--------------------------------------------------------------------------
-// Function: H5File::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it takes an
-/// \c H5std_string for the object's name.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c H5std_string
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void H5File::reference(void* ref, const H5std_string& name) const
-{
- reference(ref, name.c_str());
-}
-
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-//--------------------------------------------------------------------------
-// Function: H5File::p_get_obj_type (protected)
-// Purpose Retrieves the type of object that an object reference points to.
-// Parameters
-// ref - IN: Reference to query
-// ref_type - IN: Type of reference to query
-// Return An object type, which can be one of the following:
-// H5G_LINK Object is a symbolic link.
-// H5G_GROUP Object is a group.
-// H5G_DATASET Object is a dataset.
-// H5G_TYPE Object is a named datatype
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-H5G_obj_t H5File::p_get_obj_type(void *ref, H5R_type_t ref_type) const
-{
- H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref);
-
- if (obj_type == H5G_UNKNOWN)
- {
- throw IdComponentException("", "H5Rget_obj_type failed");
- }
- return(obj_type);
-}
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
//--------------------------------------------------------------------------
// Function: H5File::p_get_region (protected)
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index b69c963..ad1dee7 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -21,7 +21,7 @@
namespace H5 {
#endif
-class H5_DLLCPP H5File : public IdComponent, public CommonFG {
+class H5_DLLCPP H5File : public H5Location, public CommonFG {
public:
// Creates or opens an HDF5 file.
H5File( const char* name, unsigned int flags,
@@ -40,18 +40,12 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
// Close this file.
virtual void close();
- // Flushes all buffers associated with this file to disk
- void flush(H5F_scope_t scope) const;
-
// Gets the access property list of this file.
FileAccPropList getAccessPlist() const;
// Gets the creation property list of this file.
FileCreatPropList getCreatePlist() const;
- // Gets the name of this file.
- H5std_string getFileName() const;
-
// Retrieves the file size of an opened file.
hsize_t getFileSize() const;
@@ -67,11 +61,6 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
// and datatypes) in the same file.
void getObjIDs(unsigned types, size_t max_objs, hid_t *oid_list) const;
-#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;
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
// Retrieves a dataspace with the region pointed to selected.
DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
@@ -87,13 +76,6 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG {
void reOpen(); // added for better name
void reopen();
- // 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;
-
// Returns this class name
virtual H5std_string fromClass () const { return("H5File"); }
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index 6ec2dbb..f620310 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -147,33 +147,6 @@ Group::Group(Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object()
}
}
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-//--------------------------------------------------------------------------
-// Function: Group::getObjType
-///\brief Retrieves the type of object that an object reference points to.
-///\param ref - IN: Reference to query
-///\param ref_type - IN: Type of reference to query, valid values are:
-/// \li \c H5R_OBJECT - Reference is an object reference.
-/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference.
-///\return An object type, which can be one of the following:
-/// \li \c H5G_LINK (0) - Object is a symbolic link.
-/// \li \c H5G_GROUP (1) - Object is a group.
-/// \li \c H5G_DATASET (2) - Object is a dataset.
-/// \li \c H5G_TYPE (3) - Object is a named datatype
-///\exception H5::GroupIException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-H5G_obj_t Group::getObjType(void *ref, H5R_type_t ref_type) const
-{
- try {
- return(p_get_obj_type(ref, ref_type));
- }
- catch (IdComponentException E) {
- throw GroupIException("Group::getObjType", E.getDetailMsg());
- }
-}
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
//--------------------------------------------------------------------------
// Function: Group::getRegion
///\brief Retrieves a dataspace with the region pointed to selected.
diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h
index 9978cf0..c4213a8 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -26,11 +26,6 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
// Close this group.
virtual void close();
-#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;
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
// Retrieves a dataspace with the region pointed to selected.
DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
new file mode 100644
index 0000000..b93cd86
--- /dev/null
+++ b/c++/src/H5Location.cpp
@@ -0,0 +1,669 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#include <string>
+
+#include "H5Include.h"
+#include "H5Exception.h"
+#include "H5IdComponent.h"
+#include "H5PropList.h"
+#include "H5Location.h"
+#include "H5Object.h"
+#include "H5DcreatProp.h"
+#include "H5DxferProp.h"
+#include "H5FaccProp.h"
+#include "H5FcreatProp.h"
+#include "H5CommonFG.h"
+#include "H5DataType.h"
+#include "H5DataSpace.h"
+#include "H5AbstractDs.h"
+#include "H5File.h"
+#include "H5DataSet.h"
+#include "H5Attribute.h"
+
+#ifndef H5_NO_NAMESPACE
+namespace H5 {
+#endif
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// userAttrOpWrpr simply interfaces between the user's function and the
+// C library function H5Aiterate2; used to resolve the different prototype
+// problem. May be moved to Iterator later.
+extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name,
+ const H5A_info_t *ainfo, void *op_data)
+{
+ H5std_string s_attr_name = H5std_string( attr_name );
+#ifdef NO_STATIC_CAST
+ UserData4Aiterate* myData = (UserData4Aiterate *) op_data;
+#else
+ UserData4Aiterate* myData = static_cast <UserData4Aiterate *> (op_data);
+#endif
+ myData->op( *myData->location, s_attr_name, myData->opData );
+ return 0;
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location default constructor (protected)
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+H5Location::H5Location() : IdComponent(0) {}
+
+//--------------------------------------------------------------------------
+// Function: H5Location overloaded constructor (protected)
+// Purpose Creates an H5Location object using the id of an existing HDF5
+// object.
+// Parameters object_id - IN: Id of an existing HDF5 object
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+H5Location::H5Location(const hid_t object_id) : IdComponent(object_id) {}
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+//--------------------------------------------------------------------------
+// Function: H5Location copy constructor
+///\brief Copy constructor: makes a copy of the original H5Location
+/// instance.
+///\param original - IN: H5Location instance to copy
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+H5Location::H5Location( const H5Location& original ) : IdComponent( original ) {}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::createAttribute
+///\brief Creates an attribute for a group, dataset, or named datatype.
+///\param name - IN: Name of the attribute
+///\param data_type - IN: Datatype for the attribute
+///\param data_space - IN: Dataspace for the attribute - only simple
+/// dataspaces are allowed at this time
+///\param create_plist - IN: Creation property list - default to
+/// PropList::DEFAULT
+///\return Attribute instance
+///\exception H5::AttributeIException
+///\par Description
+/// The attribute name specified in \a name must be unique.
+/// Attempting to create an attribute with the same name as an
+/// existing attribute will raise an exception, leaving the
+/// pre-existing attribute intact. To overwrite an existing
+/// attribute with a new attribute of the same name, first
+/// delete the existing one with \c H5Location::removeAttr, then
+/// recreate it with this function.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+Attribute H5Location::createAttribute( const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const
+{
+ hid_t type_id = data_type.getId();
+ hid_t space_id = data_space.getId();
+ hid_t plist_id = create_plist.getId();
+ hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT );
+
+ // If the attribute id is valid, create and return the Attribute object
+ if( attr_id > 0 )
+ {
+ Attribute attr( attr_id );
+ return( attr );
+ }
+ else
+ throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::createAttribute
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes
+/// a reference to an \c H5std_string for \a name.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+Attribute H5Location::createAttribute( const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const
+{
+ return( createAttribute( name.c_str(), data_type, data_space, create_plist ));
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::openAttribute
+///\brief Opens an attribute given its name.
+///\param name - IN: Name of the attribute
+///\return Attribute instance
+///\exception H5::AttributeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+Attribute H5Location::openAttribute( const char* name ) const
+{
+ hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT);
+ if( attr_id > 0 )
+ {
+ Attribute attr( attr_id );
+ return( attr );
+ }
+ else
+ {
+ throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::openAttribute
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes
+/// a reference to an \c H5std_string for \a name.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+Attribute H5Location::openAttribute( const H5std_string& name ) const
+{
+ return( openAttribute( name.c_str()) );
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::openAttribute
+///\brief Opens an attribute given its index.
+///\param idx - IN: Index of the attribute, a 0-based, non-negative integer
+///\return Attribute instance
+///\exception H5::AttributeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+Attribute H5Location::openAttribute( const unsigned int idx ) const
+{
+ hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER,
+ H5_ITER_INC, (hsize_t)idx, H5P_DEFAULT, H5P_DEFAULT);
+ if( attr_id > 0 )
+ {
+ Attribute attr( attr_id );
+ return( attr );
+ }
+ else
+ {
+ throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::iterateAttrs
+///\brief Iterates a user's function over all the attributes of an H5
+/// object, which may be a group, dataset or named datatype.
+///\param user_op - IN: User's function to operate on each attribute
+///\param _idx - IN/OUT: Starting (IN) and ending (OUT) attribute indices
+///\param op_data - IN: User's data to pass to user's operator function
+///\return Returned value of the last operator if it was non-zero, or
+/// zero if all attributes were processed
+///\exception H5::AttributeIException
+///\par Description
+/// The signature of user_op is
+/// void (*)(H5::H5Location&, H5std_string, void*).
+/// For information, please refer to the C layer Reference Manual
+/// at:
+/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5A.html#Annot-Iterate
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+int H5Location::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_data )
+{
+ // store the user's function and data
+ UserData4Aiterate* userData = new UserData4Aiterate;
+ userData->opData = op_data;
+ userData->op = user_op;
+ userData->location = this;
+
+ // call the C library routine H5Aiterate2 to iterate the attributes
+ hsize_t idx = _idx ? (hsize_t)*_idx : 0;
+ int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx,
+ userAttrOpWrpr, (void *) userData);
+
+ // release memory
+ delete userData;
+
+ if( ret_value >= 0 ) {
+ /* Pass back update index value to calling code */
+ if (_idx)
+ *_idx = (unsigned)idx;
+
+ return( ret_value );
+ }
+ else // raise exception when H5Aiterate returns a negative value
+ throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::getNumAttrs
+///\brief Returns the number of attributes attached to this HDF5 object.
+///\return Number of attributes
+///\exception H5::AttributeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+int H5Location::getNumAttrs() const
+{
+ H5O_info_t oinfo; /* Object info */
+
+ if(H5Oget_info(getId(), &oinfo) < 0)
+ throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed");
+ else
+ return( (int)oinfo.num_attrs );
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::removeAttr
+///\brief Removes the named attribute from this object.
+///\param name - IN: Name of the attribute to be removed
+///\exception H5::AttributeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+void H5Location::removeAttr( const char* name ) const
+{
+ herr_t ret_value = H5Adelete(getId(), name);
+ if( ret_value < 0 )
+ throw AttributeIException(inMemFunc("removeAttr"), "H5Adelete failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::removeAttr
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes
+/// a reference to an \c H5std_string for \a name.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+void H5Location::removeAttr( const H5std_string& name ) const
+{
+ removeAttr( name.c_str() );
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::renameAttr
+///\brief Renames the named attribute from this object.
+///\param oldname - IN: Name of the attribute to be renamed
+///\param newname - IN: New name ame of the attribute
+///\exception H5::AttributeIException
+// Programmer Binh-Minh Ribler - Mar, 2005
+//--------------------------------------------------------------------------
+void H5Location::renameAttr(const char* oldname, const char* newname) const
+{
+ herr_t ret_value = H5Arename(getId(), oldname, newname);
+ if (ret_value < 0)
+ throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::renameAttr
+///\brief This is an overloaded member function, provided for convenience.
+/// It differs from the above function in that it takes
+/// a reference to an \c H5std_string for the names.
+// Programmer Binh-Minh Ribler - Mar, 2005
+//--------------------------------------------------------------------------
+void H5Location::renameAttr(const H5std_string& oldname, const H5std_string& newname) const
+{
+ renameAttr (oldname.c_str(), newname.c_str());
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::flush
+///\brief Flushes all buffers associated with a location to disk.
+///\param scope - IN: Specifies the scope of the flushing action,
+/// which can be either of these values:
+/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file
+/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file
+///\exception H5::FileIException
+///\par Description
+/// This location is used to identify the file to be flushed.
+// Programmer Binh-Minh Ribler - 2012
+// Modification
+// Sep 2012 - BMR
+// Moved from H5File/H5Object
+//--------------------------------------------------------------------------
+void H5Location::flush(H5F_scope_t scope) const
+{
+ herr_t ret_value = H5Fflush(getId(), scope);
+ if( ret_value < 0 )
+ {
+ throw FileIException(inMemFunc("flush"), "H5Fflush failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::getFileName
+///\brief Gets the name of the file, in which this HDF5 object belongs.
+///\return File name
+///\exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - Jul, 2004
+//--------------------------------------------------------------------------
+H5std_string H5Location::getFileName() const
+{
+ try {
+ return(p_get_file_name());
+ }
+ catch (IdComponentException E) {
+ throw FileIException(inMemFunc("getFileName"), E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::p_reference (protected)
+// Purpose Creates a reference to an HDF5 object or a dataset region.
+// Parameters
+// name - IN: Name of the object to be referenced
+// dataspace - IN: Dataspace with selection
+// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
+// Exception H5::IdComponentException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Location::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const
+{
+ herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id);
+ if (ret_value < 0)
+ {
+ throw ReferenceException("", "H5Rcreate failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::reference
+///\brief Creates a reference to an HDF5 object or a dataset region.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced
+///\param dataspace - IN: Dataspace with selection
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT - Reference is an object reference.
+/// \li \c H5R_DATASET_REGION - Reference is a dataset region
+/// reference. - this is the default
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Location::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const
+{
+ try {
+ p_reference(ref, name, dataspace.getId(), ref_type);
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Location::reference", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it only creates
+/// a reference to an HDF5 object, not to a dataset region.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced - \c char pointer
+///\exception H5::ReferenceException
+///\par Description
+// This function passes H5R_OBJECT and -1 to the protected
+// function for it to pass to the C API H5Rcreate
+// to create a reference to the named object.
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Location::reference(void* ref, const char* name) const
+{
+ try {
+ p_reference(ref, name, -1, H5R_OBJECT);
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Location::reference", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::reference
+///\brief This is an overloaded function, provided for your convenience.
+/// It differs from the above function in that it takes an
+/// \c H5std_string for the object's name.
+///\param ref - IN: Reference pointer
+///\param name - IN: Name of the object to be referenced - \c H5std_string
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+void H5Location::reference(void* ref, const H5std_string& name) const
+{
+ reference(ref, name.c_str());
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::p_dereference (protected)
+// Purpose Dereference a ref into an hdf5 object.
+// Parameters
+// 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.
+//--------------------------------------------------------------------------
+hid_t H5Location::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type)
+{
+ hid_t temp_id;
+ temp_id = H5Rdereference2(loc_id, H5P_DEFAULT, ref_type, ref);
+ if (temp_id < 0)
+ {
+ throw ReferenceException("", "H5Rdereference failed");
+ }
+
+ // No failure, set id to the object
+ return(temp_id);
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::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 H5Location::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("H5Location::dereference - located by object", E.getDetailMsg());
+ }
+ p_setId(temp_id);
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::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 H5Location::dereference(H5File& h5file, const void* ref, H5R_type_t ref_type)
+{
+ hid_t temp_id;
+ try {
+ temp_id = p_dereference(h5file.getId(), ref, ref_type);
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Location::dereference - located by file", E.getDetailMsg());
+ }
+ p_setId(temp_id);
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::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 H5Location::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("H5Location::dereference - located by attribute", E.getDetailMsg());
+ }
+ p_setId(temp_id);
+}
+
+#ifndef H5_NO_DEPRECATED_SYMBOLS
+//--------------------------------------------------------------------------
+// Function: H5Location::getObjType
+///\brief Retrieves the type of object that an object reference points to.
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT \tReference is an object reference.
+/// \li \c H5R_DATASET_REGION \tReference is a dataset region reference.
+///\param ref - IN: Reference to query
+///\return An object type, which can be one of the following:
+/// \li \c H5G_UNKNOWN \tA failure occurs. (-1)
+/// \li \c H5G_GROUP \tObject is a group.
+/// \li \c H5G_DATASET \tObject is a dataset.
+/// \li \c H5G_TYPE Object \tis a named datatype
+/// \li \c H5G_LINK \tObject is a symbolic link.
+/// \li \c H5G_UDLINK \tObject is a user-defined link.
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
+// Modification
+// Sep 2012: Moved up from H5File, Group, DataSet, and DataType
+//--------------------------------------------------------------------------
+H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const
+{
+ try {
+ return(p_get_obj_type(ref, ref_type));
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Location::getObjType", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::p_get_obj_type (protected)
+// Purpose Retrieves the type of object that an object reference points to.
+// Parameters
+// ref - IN: Reference to query
+// ref_type - IN: Type of reference to query
+// Return An object type, which can be one of the following:
+// H5G_UNKNOWN \tFailure occurs (-1)
+// H5G_GROUP \tObject is a group.
+// H5G_DATASET \tObject is a dataset.
+// H5G_TYPE Object \tis a named datatype.
+// H5G_LINK \tObject is a symbolic link.
+// H5G_UDLINK \tObject is a user-defined link.
+// Exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+H5G_obj_t H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const
+{
+ H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref);
+
+ if (obj_type == H5G_UNKNOWN)
+ {
+ throw ReferenceException("", "H5Rget_obj_type1 failed");
+ }
+ return(obj_type);
+}
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+
+//--------------------------------------------------------------------------
+// Function: H5Location::getRefObjType
+///\brief Retrieves the type of object that an object reference points to.
+///\param ref - IN: Reference to query
+///\param ref_type - IN: Type of reference to query, valid values are:
+/// \li \c H5R_OBJECT - Reference is an object reference.
+/// \li \c H5R_DATASET_REGION - Reference is a dataset region reference.
+///\return An object type, which can be one of the following:
+/// \li \c H5O_TYPE_UNKNOWN - Unknown object type (-1)
+/// \li \c H5O_TYPE_GROUP - Object is a group
+/// \li \c H5O_TYPE_DATASET - Object is a dataset
+/// \li \c H5O_TYPE_NAMED_DATATYPE - Object is a named datatype
+/// \li \c H5O_TYPE_NTYPES - Number of different object types
+///\exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const
+{
+ try {
+ return(p_get_ref_obj_type(ref, ref_type));
+ }
+ catch (ReferenceException E) {
+ throw ReferenceException("H5Location::getRefObjType", E.getDetailMsg());
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Location::p_get_ref_obj_type (protected)
+// Purpose Retrieves the type of object that an object reference points to.
+// Parameters
+// ref - IN: Reference to query
+// ref_type - IN: Type of reference to query
+// Return An object type, which can be one of the following:
+// H5O_TYPE_UNKNOWN - Unknown object type (-1)
+// H5O_TYPE_GROUP - Object is a group
+// H5O_TYPE_DATASET - Object is a dataset
+// H5O_TYPE_NAMED_DATATYPE - Object is a named datatype
+// H5O_TYPE_NTYPES - Number of object types
+// Exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+H5O_type_t H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const
+{
+ H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
+ herr_t ret_value = H5Rget_obj_type2(getId(), ref_type, ref, &obj_type);
+
+ if (obj_type == H5O_TYPE_UNKNOWN || obj_type >= H5O_TYPE_NTYPES)
+ {
+ throw ReferenceException("", "H5Rget_obj_type2 failed");
+ }
+ return(obj_type);
+}
+
+
+//--------------------------------------------------------------------------
+// Function: H5Location::p_get_region (protected)
+// Purpose Retrieves a dataspace with the region pointed to selected.
+// Parameters
+// ref_type - IN: Type of reference to get region of - default
+// to H5R_DATASET_REGION
+// ref - IN: Reference to get region of
+// Return Dataspace id
+// Exception H5::ReferenceException
+// Programmer Binh-Minh Ribler - May, 2004
+//--------------------------------------------------------------------------
+hid_t H5Location::p_get_region(void *ref, H5R_type_t ref_type) const
+{
+ hid_t space_id = H5Rget_region(getId(), ref_type, ref);
+ if (space_id < 0)
+ {
+ throw ReferenceException("", "H5Rget_region failed");
+ }
+ return(space_id);
+}
+
+
+//--------------------------------------------------------------------------
+// Function: H5Location destructor
+///\brief Noop destructor.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+H5Location::~H5Location() {}
+
+#ifndef H5_NO_NAMESPACE
+} // end namespace
+#endif
diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h
new file mode 100644
index 0000000..d1dd892
--- /dev/null
+++ b/c++/src/H5Location.h
@@ -0,0 +1,146 @@
+// C++ informative line for the emacs editor: -*- C++ -*-
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef _H5Location_H
+#define _H5Location_H
+
+#include "H5Classes.h" // constains forward class declarations
+
+// H5Location is an abstract class. It provides a collection of wrappers
+// of C functions which take location IDs. Most of these were in H5Object
+// but are now moved here for H5File's access.
+
+#ifndef H5_NO_NAMESPACE
+namespace H5 {
+#endif
+
+class H5_DLLCPP H5Location; // forward declaration for UserData4Aiterate
+
+// Define the operator function pointer for H5Aiterate().
+typedef void (*attr_operator_t)( H5Location& loc/*in*/,
+ const H5std_string attr_name/*in*/,
+ void *operator_data/*in,out*/);
+
+class UserData4Aiterate { // user data for attribute iteration
+ public:
+ attr_operator_t op;
+ void* opData;
+ H5Location* location;
+};
+
+// An H5Location can be a file, group, dataset, named datatype, or attribute.
+
+class H5_DLLCPP H5Location : public IdComponent {
+ public:
+ // Creates an attribute for the specified object at this location
+ // PropList is currently not used, so always be default.
+ Attribute createAttribute( const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
+ Attribute createAttribute( const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
+
+ // Given its name, opens the attribute that belongs to an object at
+ // this location.
+ Attribute openAttribute( const char* name ) const;
+ Attribute openAttribute( const H5std_string& name ) const;
+
+ // Given its index, opens the attribute that belongs to an object at
+ // this location.
+ Attribute openAttribute( const unsigned int idx ) const;
+
+ // Flushes all buffers associated with this location to disk.
+ void flush( H5F_scope_t scope ) const;
+
+ // Gets the name of the file, specified by this location.
+ H5std_string getFileName() const;
+
+ // Determines the number of attributes at this location.
+ int getNumAttrs() const;
+
+#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;
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+ // Retrieves the type of object that an object reference points to.
+ H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
+ // Note: getRefObjType deprecates getObjType, but getObjType's name is
+ // misleading, so getRefObjType is used in the new function instead.
+
+ // Iterate user's function over the attributes at this location.
+ int iterateAttrs( attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL );
+
+ // Removes the named attribute from this location.
+ void removeAttr( const char* name ) const;
+ void removeAttr( const H5std_string& name ) const;
+
+ // Renames the named attribute to a new name.
+ 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 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 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);
+
+ // For subclasses.
+ virtual hid_t getId() const = 0;
+
+ protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ // Default constructor,
+ H5Location();
+
+ // Creates a copy of an existing object giving the location id.
+ H5Location(const hid_t loc_id);
+
+ // Copy constructor.
+ H5Location(const H5Location& original);
+
+ // 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;
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
+
+ // Retrieves the type of object that an object reference points to.
+ H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
+
+ // Retrieves a dataspace with the region pointed to selected.
+ hid_t p_get_region(void *ref, H5R_type_t ref_type) const;
+
+ // Noop destructor.
+ virtual ~H5Location();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+}; /* end class H5Location */
+
+#ifndef H5_NO_NAMESPACE
+}
+#endif
+#endif
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index 3c85502..1fdaf3f 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -40,7 +40,7 @@ namespace H5 {
// userAttrOpWrpr simply interfaces between the user's function and the
// C library function H5Aiterate2; used to resolve the different prototype
// problem. May be moved to Iterator later.
-extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name,
+extern "C" herr_t userAttrOpWrpr1(hid_t loc_id, const char *attr_name,
const H5A_info_t *ainfo, void *op_data)
{
H5std_string s_attr_name = H5std_string( attr_name );
@@ -49,18 +49,18 @@ extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name,
#else
UserData4Aiterate* myData = static_cast <UserData4Aiterate *> (op_data);
#endif
- myData->op( *myData->object, s_attr_name, myData->opData );
+ myData->op( *myData->location, s_attr_name, myData->opData );
return 0;
}
//--------------------------------------------------------------------------
// Function: H5Object default constructor (protected)
// Description
-// The id is set by IdComponent() but subclass constructor will
+// The id is set by H5Location() but subclass constructor will
// set it to a valid HDF5 id.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5Object::H5Object() : IdComponent(0) {}
+H5Object::H5Object() : H5Location(0) {}
//--------------------------------------------------------------------------
// Function: H5Object overloaded constructor (protected)
@@ -69,7 +69,7 @@ H5Object::H5Object() : IdComponent(0) {}
// Parameters object_id - IN: Id of an existing HDF5 object
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5Object::H5Object( const hid_t object_id ) : IdComponent( object_id ) {}
+H5Object::H5Object( const hid_t object_id ) : H5Location( object_id ) {}
#endif // DOXYGEN_SHOULD_SKIP_THIS
@@ -80,496 +80,7 @@ H5Object::H5Object( const hid_t object_id ) : IdComponent( object_id ) {}
///\param original - IN: H5Object instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-H5Object::H5Object( const H5Object& original ) : IdComponent( original ) {}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::createAttribute
-///\brief Creates an attribute for a group, dataset, or named datatype.
-///\param name - IN: Name of the attribute
-///\param data_type - IN: Datatype for the attribute
-///\param data_space - IN: Dataspace for the attribute - only simple
-/// dataspaces are allowed at this time
-///\param create_plist - IN: Creation property list - default to
-/// PropList::DEFAULT
-///\return Attribute instance
-///\exception H5::AttributeIException
-///\par Description
-/// The attribute name specified in \a name must be unique.
-/// Attempting to create an attribute with the same name as an
-/// existing attribute will raise an exception, leaving the
-/// pre-existing attribute intact. To overwrite an existing
-/// attribute with a new attribute of the same name, first
-/// delete the existing one with \c H5Object::removeAttr, then
-/// recreate it with this function.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-Attribute H5Object::createAttribute( const char* name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const
-{
- hid_t type_id = data_type.getId();
- hid_t space_id = data_space.getId();
- hid_t plist_id = create_plist.getId();
- hid_t attr_id = H5Acreate2(getId(), name, type_id, space_id, plist_id, H5P_DEFAULT );
-
- // If the attribute id is valid, create and return the Attribute object
- if( attr_id > 0 )
- {
- Attribute attr( attr_id );
- return( attr );
- }
- else
- throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate2 failed");
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::createAttribute
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function in that it takes
-/// a reference to an \c H5std_string for \a name.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-Attribute H5Object::createAttribute( const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const PropList& create_plist ) const
-{
- return( createAttribute( name.c_str(), data_type, data_space, create_plist ));
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::openAttribute
-///\brief Opens an attribute given its name.
-///\param name - IN: Name of the attribute
-///\return Attribute instance
-///\exception H5::AttributeIException
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-Attribute H5Object::openAttribute( const char* name ) const
-{
- hid_t attr_id = H5Aopen(getId(), name, H5P_DEFAULT);
- if( attr_id > 0 )
- {
- Attribute attr( attr_id );
- return( attr );
- }
- else
- {
- throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen failed");
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::openAttribute
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function in that it takes
-/// a reference to an \c H5std_string for \a name.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-Attribute H5Object::openAttribute( const H5std_string& name ) const
-{
- return( openAttribute( name.c_str()) );
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::openAttribute
-///\brief Opens an attribute given its index.
-///\param idx - IN: Index of the attribute, a 0-based, non-negative integer
-///\return Attribute instance
-///\exception H5::AttributeIException
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-Attribute H5Object::openAttribute( const unsigned int idx ) const
-{
- hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER,
- H5_ITER_INC, (hsize_t)idx, H5P_DEFAULT, H5P_DEFAULT);
- if( attr_id > 0 )
- {
- Attribute attr( attr_id );
- return( attr );
- }
- else
- {
- throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_by_idx failed");
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::iterateAttrs
-///\brief Iterates a user's function over all the attributes of an H5
-/// object, which may be a group, dataset or named datatype.
-///\param user_op - IN: User's function to operate on each attribute
-///\param _idx - IN/OUT: Starting (IN) and ending (OUT) attribute indices
-///\param op_data - IN: User's data to pass to user's operator function
-///\return Returned value of the last operator if it was non-zero, or
-/// zero if all attributes were processed
-///\exception H5::AttributeIException
-///\par Description
-/// The signature of user_op is
-/// void (*)(H5::H5Object&, H5std_string, void*).
-/// For information, please refer to the C layer Reference Manual
-/// at:
-/// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5A.html#Annot-Iterate
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-int H5Object::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_data )
-{
- // store the user's function and data
- UserData4Aiterate* userData = new UserData4Aiterate;
- userData->opData = op_data;
- userData->op = user_op;
- userData->object = this;
-
- // call the C library routine H5Aiterate2 to iterate the attributes
- hsize_t idx = _idx ? (hsize_t)*_idx : 0;
- int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx,
- userAttrOpWrpr, (void *) userData);
-
- // release memory
- delete userData;
-
- if( ret_value >= 0 ) {
- /* Pass back update index value to calling code */
- if (_idx)
- *_idx = (unsigned)idx;
-
- return( ret_value );
- }
- else // raise exception when H5Aiterate returns a negative value
- throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed");
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::getNumAttrs
-///\brief Returns the number of attributes attached to this HDF5 object.
-///\return Number of attributes
-///\exception H5::AttributeIException
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-int H5Object::getNumAttrs() const
-{
- H5O_info_t oinfo; /* Object info */
-
- if(H5Oget_info(getId(), &oinfo) < 0)
- throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed");
- else
- return( (int)oinfo.num_attrs );
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::removeAttr
-///\brief Removes the named attribute from this object.
-///\param name - IN: Name of the attribute to be removed
-///\exception H5::AttributeIException
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-void H5Object::removeAttr( const char* name ) const
-{
- herr_t ret_value = H5Adelete(getId(), name);
- if( ret_value < 0 )
- throw AttributeIException(inMemFunc("removeAttr"), "H5Adelete failed");
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::removeAttr
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function in that it takes
-/// a reference to an \c H5std_string for \a name.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-void H5Object::removeAttr( const H5std_string& name ) const
-{
- removeAttr( name.c_str() );
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::renameAttr
-///\brief Renames the named attribute from this object.
-///\param oldname - IN: Name of the attribute to be renamed
-///\param newname - IN: New name ame of the attribute
-///\exception H5::AttributeIException
-// Programmer Binh-Minh Ribler - Mar, 2005
-//--------------------------------------------------------------------------
-void H5Object::renameAttr(const char* oldname, const char* newname) const
-{
- herr_t ret_value = H5Arename(getId(), oldname, newname);
- if (ret_value < 0)
- throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed");
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::renameAttr
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function in that it takes
-/// a reference to an \c H5std_string for the names.
-// Programmer Binh-Minh Ribler - Mar, 2005
-//--------------------------------------------------------------------------
-void H5Object::renameAttr(const H5std_string& oldname, const H5std_string& newname) const
-{
- renameAttr (oldname.c_str(), newname.c_str());
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::flush
-///\brief Flushes all buffers associated with a file to disk.
-///\param scope - IN: Specifies the scope of the flushing action,
-/// which can be either of these values:
-/// \li \c H5F_SCOPE_GLOBAL - Flushes the entire virtual file
-/// \li \c H5F_SCOPE_LOCAL - Flushes only the specified file
-///\exception H5::AttributeIException
-///\par Description
-/// This object is used to identify the file to be flushed.
-// Programmer Binh-Minh Ribler - 2000
-//--------------------------------------------------------------------------
-void H5Object::flush(H5F_scope_t scope) const
-{
- herr_t ret_value = H5Fflush(getId(), scope);
- if( ret_value < 0 )
- {
- throw FileIException(inMemFunc("flush"), "H5Fflush failed");
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::getFileName
-///\brief Gets the name of the file, in which this HDF5 object belongs.
-///\return File name
-///\exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - Jul, 2004
-//--------------------------------------------------------------------------
-H5std_string H5Object::getFileName() const
-{
- try {
- return(p_get_file_name());
- }
- catch (IdComponentException E) {
- throw FileIException(inMemFunc("getFileName"), E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::p_reference (protected)
-// Purpose Creates a reference to an HDF5 object or a dataset region.
-// Parameters
-// name - IN: Name of the object to be referenced
-// dataspace - IN: Dataspace with selection
-// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void H5Object::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const
-{
- herr_t ret_value = H5Rcreate(ref, getId(), name, ref_type, space_id);
- if (ret_value < 0)
- {
- throw IdComponentException("", "H5Rcreate failed");
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::reference
-///\brief Creates a reference to an HDF5 object or a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced
-///\param dataspace - IN: Dataspace with selection
-///\param ref_type - IN: Type of reference to query, valid values are:
-/// \li \c H5R_OBJECT - Reference is an object reference.
-/// \li \c H5R_DATASET_REGION - Reference is a dataset region
-/// reference. - this is the default
-///\exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void H5Object::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const
-{
- try {
- p_reference(ref, name, dataspace.getId(), ref_type);
- }
- catch (IdComponentException E) {
- throw IdComponentException("H5Object::reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it only creates
-/// a reference to an HDF5 object, not to a dataset region.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c char pointer
-///\exception H5::IdComponentException
-///\par Description
-// This function passes H5R_OBJECT and -1 to the protected
-// function for it to pass to the C API H5Rcreate
-// to create a reference to the named object.
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void H5Object::reference(void* ref, const char* name) const
-{
- try {
- p_reference(ref, name, -1, H5R_OBJECT);
- }
- catch (IdComponentException E) {
- throw IdComponentException("H5Object::reference", E.getDetailMsg());
- }
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::reference
-///\brief This is an overloaded function, provided for your convenience.
-/// It differs from the above function in that it takes an
-/// \c H5std_string for the object's name.
-///\param ref - IN: Reference pointer
-///\param name - IN: Name of the object to be referenced - \c H5std_string
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-void H5Object::reference(void* ref, const H5std_string& name) const
-{
- reference(ref, name.c_str());
-}
-
-//--------------------------------------------------------------------------
-// Function: H5Object::p_dereference (protected)
-// Purpose Dereference a ref into an hdf5 object.
-// Parameters
-// 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.
-//--------------------------------------------------------------------------
-hid_t H5Object::p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type)
-{
- hid_t temp_id;
- temp_id = H5Rdereference2(loc_id, H5P_DEFAULT, 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);
-}
-
-//--------------------------------------------------------------------------
-// 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 = p_dereference(h5file.getId(), ref, ref_type);
- }
- catch (ReferenceException E) {
- throw ReferenceException("H5Object::dereference - located by file", E.getDetailMsg());
- }
- p_setId(temp_id);
-}
-
-//--------------------------------------------------------------------------
-// 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);
-}
-
-#ifndef H5_NO_DEPRECATED_SYMBOLS
-//--------------------------------------------------------------------------
-// Function: H5Object::p_get_obj_type (protected)
-// Purpose Retrieves the type of object that an object reference points to.
-// Parameters
-// ref - IN: Reference to query
-// ref_type - IN: Type of reference to query
-// Return An object type, which can be one of the following:
-// H5G_LINK Object is a symbolic link.
-// H5G_GROUP Object is a group.
-// H5G_DATASET Object is a dataset.
-// H5G_TYPE Object is a named datatype
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-H5G_obj_t H5Object::p_get_obj_type(void *ref, H5R_type_t ref_type) const
-{
- H5G_obj_t obj_type = H5Rget_obj_type1(getId(), ref_type, ref);
-
- if (obj_type == H5G_UNKNOWN)
- {
- throw IdComponentException("", "H5Rget_obj_type failed");
- }
- return(obj_type);
-}
-#endif /* H5_NO_DEPRECATED_SYMBOLS */
-
-
-//--------------------------------------------------------------------------
-// Function: H5Object::p_get_region (protected)
-// Purpose Retrieves a dataspace with the region pointed to selected.
-// Parameters
-// ref_type - IN: Type of reference to get region of - default
-// to H5R_DATASET_REGION
-// ref - IN: Reference to get region of
-// Return Dataspace id
-// Exception H5::IdComponentException
-// Programmer Binh-Minh Ribler - May, 2004
-//--------------------------------------------------------------------------
-hid_t H5Object::p_get_region(void *ref, H5R_type_t ref_type) const
-{
- hid_t space_id = H5Rget_region(getId(), ref_type, ref);
- if (space_id < 0)
- {
- throw IdComponentException("", "H5Rget_region failed");
- }
- return(space_id);
-}
-
+H5Object::H5Object( const H5Object& original ) : H5Location( original ) {}
//--------------------------------------------------------------------------
// Function: H5Object destructor
diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h
index 4ac417b..5c264ec 100644
--- a/c++/src/H5Object.h
+++ b/c++/src/H5Object.h
@@ -17,11 +17,22 @@
#ifndef _H5Object_H
#define _H5Object_H
+#include "H5Location.h"
#include "H5Classes.h" // constains forward class declarations
// H5Object is a baseclass. It has these subclasses:
// Group, DataSet, and DataType.
// DataType, in turn, has several specific datatypes as subclasses.
+// Modification:
+// Sept 18, 2012: Added class H5Location in between IdComponent and
+// H5Object. An H5File now inherits from H5Location. All HDF5
+// wrappers in H5Object are moved up to H5Location. H5Object
+// is left mostly empty for future wrappers that are only for
+// group, dataset, and named datatype. Note that the reason for
+// adding H5Location instead of simply moving H5File to be under
+// H5Object is H5File is not an HDF5 object, and renaming H5Object
+// to H5Location will risk breaking user applications.
+// -BMR
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -31,13 +42,13 @@ namespace H5 {
class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate
// Define the operator function pointer for H5Aiterate().
-typedef void (*attr_operator_t)( H5Object& loc/*in*/,
+typedef void (*attr1_operator_t)( H5Object& loc/*in*/,
const H5std_string attr_name/*in*/,
void *operator_data/*in,out*/);
-class UserData4Aiterate { // user data for attribute iteration
+class UserData4Aiterate1 { // user data for attribute iteration
public:
- attr_operator_t op;
+ attr1_operator_t op;
void* opData;
H5Object* object;
};
@@ -45,53 +56,8 @@ class UserData4Aiterate { // user data for attribute iteration
// The above part is being moved into Iterator, but not completed
-class H5_DLLCPP H5Object : public IdComponent {
+class H5_DLLCPP H5Object : public H5Location {
public:
- // Creates an attribute for a group, dataset, or named datatype.
- // PropList is currently not used, so always be default.
- Attribute createAttribute( const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
- Attribute createAttribute( const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT ) const;
-
- // Opens an attribute given its name.
- Attribute openAttribute( const char* name ) const;
- Attribute openAttribute( const H5std_string& name ) const;
-
- // Opens an attribute given its index.
- Attribute openAttribute( const unsigned int idx ) const;
-
- // Flushes all buffers associated with this object to disk
- void flush( H5F_scope_t scope ) const;
-
- // Gets the name of the file, in which this HDF5 object belongs.
- H5std_string getFileName() const;
-
- // Determines the number of attributes attached to this object.
- int getNumAttrs() const;
-
- // Iterate user's function over the attributes of this object
- int iterateAttrs( attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL );
-
- // Removes the named attribute from this object.
- void removeAttr( const char* name ) const;
- void removeAttr( const H5std_string& name ) const;
-
- // Renames the attribute to a new name.
- 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 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);
@@ -106,23 +72,6 @@ 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;
-
- // 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;
-#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/Makefile.am b/c++/src/Makefile.am
index 6278fa0..ec942fd 100644
--- a/c++/src/Makefile.am
+++ b/c++/src/Makefile.am
@@ -40,12 +40,12 @@ bin_SCRIPTS=h5c++
# Source files for the library
libhdf5_cpp_la_SOURCES=H5Exception.cpp H5IdComponent.cpp H5Library.cpp \
- H5Attribute.cpp H5Object.cpp H5PropList.cpp H5FaccProp.cpp \
- H5FcreatProp.cpp H5DcreatProp.cpp H5DxferProp.cpp H5DataType.cpp \
- H5DataSpace.cpp H5AbstractDs.cpp H5AtomType.cpp H5PredType.cpp \
- H5EnumType.cpp H5IntType.cpp H5FloatType.cpp H5StrType.cpp \
- H5ArrayType.cpp H5VarLenType.cpp H5CompType.cpp H5DataSet.cpp \
- H5CommonFG.cpp H5Group.cpp H5File.cpp
+ H5Attribute.cpp H5Location.cpp H5Object.cpp H5PropList.cpp \
+ H5FaccProp.cpp H5FcreatProp.cpp H5DcreatProp.cpp H5DxferProp.cpp \
+ H5DataType.cpp H5DataSpace.cpp H5AbstractDs.cpp H5AtomType.cpp \
+ H5PredType.cpp H5EnumType.cpp H5IntType.cpp H5FloatType.cpp \
+ H5StrType.cpp H5ArrayType.cpp H5VarLenType.cpp H5CompType.cpp \
+ H5DataSet.cpp H5CommonFG.cpp H5Group.cpp H5File.cpp
# HDF5 C++ library depends on HDF5 Library.
libhdf5_cpp_la_LIBADD=$(LIBHDF5)
@@ -55,8 +55,9 @@ include_HEADERS=H5Cpp.h H5AbstractDs.h H5AtomType.h H5Attribute.h H5Classes.h \
H5CommonFG.h H5CompType.h H5DataSet.h H5DataSpace.h H5DataType.h \
H5DcreatProp.h H5DxferProp.h H5EnumType.h H5Exception.h H5FaccProp.h \
H5FcreatProp.h H5File.h H5FloatType.h H5Group.h H5IdComponent.h \
- H5Include.h H5IntType.h H5Library.h H5Object.h H5PredType.h \
- H5PropList.h H5StrType.h H5CppDoc.h H5ArrayType.h H5VarLenType.h
+ H5Include.h H5IntType.h H5Library.h H5Location.h H5Object.h \
+ H5PredType.h H5PropList.h H5StrType.h H5CppDoc.h H5ArrayType.h \
+ H5VarLenType.h
# h5c++ and libhdf5.settings are generated during configure. Remove only when
# distclean.
diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in
index 3dd5c58..9a085e7 100644
--- a/c++/src/Makefile.in
+++ b/c++/src/Makefile.in
@@ -120,12 +120,12 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
LTLIBRARIES = $(lib_LTLIBRARIES)
libhdf5_cpp_la_DEPENDENCIES = $(LIBHDF5)
am_libhdf5_cpp_la_OBJECTS = H5Exception.lo H5IdComponent.lo \
- H5Library.lo H5Attribute.lo H5Object.lo H5PropList.lo \
- H5FaccProp.lo H5FcreatProp.lo H5DcreatProp.lo H5DxferProp.lo \
- H5DataType.lo H5DataSpace.lo H5AbstractDs.lo H5AtomType.lo \
- H5PredType.lo H5EnumType.lo H5IntType.lo H5FloatType.lo \
- H5StrType.lo H5ArrayType.lo H5VarLenType.lo H5CompType.lo \
- H5DataSet.lo H5CommonFG.lo H5Group.lo H5File.lo
+ H5Library.lo H5Attribute.lo H5Location.lo H5Object.lo \
+ H5PropList.lo H5FaccProp.lo H5FcreatProp.lo H5DcreatProp.lo \
+ H5DxferProp.lo H5DataType.lo H5DataSpace.lo H5AbstractDs.lo \
+ H5AtomType.lo H5PredType.lo H5EnumType.lo H5IntType.lo \
+ H5FloatType.lo H5StrType.lo H5ArrayType.lo H5VarLenType.lo \
+ H5CompType.lo H5DataSet.lo H5CommonFG.lo H5Group.lo H5File.lo
libhdf5_cpp_la_OBJECTS = $(am_libhdf5_cpp_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -257,7 +257,6 @@ FILTERS = @FILTERS@
FSEARCH_DIRS = @FSEARCH_DIRS@
GPFS = @GPFS@
GREP = @GREP@
-H5BLD_STATIC = @H5BLD_STATIC@
H5_CFLAGS = @H5_CFLAGS@
H5_CPPFLAGS = @H5_CPPFLAGS@
H5_CXXFLAGS = @H5_CXXFLAGS@
@@ -272,7 +271,6 @@ HAVE_DMALLOC = @HAVE_DMALLOC@
HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@
HDF5_HL = @HDF5_HL@
HDF5_INTERFACES = @HDF5_INTERFACES@
-HDF5_USE_SHLIB = @HDF5_USE_SHLIB@
HDF_CXX = @HDF_CXX@
HDF_FORTRAN = @HDF_FORTRAN@
HDF_FORTRAN2003 = @HDF_FORTRAN2003@
@@ -469,7 +467,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog
# Add libtool shared library version numbers to the HDF5 library
# See libtool versioning documentation online.
LT_VERS_INTERFACE = 6
-LT_VERS_REVISION = 121
+LT_VERS_REVISION = 118
LT_VERS_AGE = 0
# Include src directory
@@ -484,12 +482,12 @@ bin_SCRIPTS = h5c++
# Source files for the library
libhdf5_cpp_la_SOURCES = H5Exception.cpp H5IdComponent.cpp H5Library.cpp \
- H5Attribute.cpp H5Object.cpp H5PropList.cpp H5FaccProp.cpp \
- H5FcreatProp.cpp H5DcreatProp.cpp H5DxferProp.cpp H5DataType.cpp \
- H5DataSpace.cpp H5AbstractDs.cpp H5AtomType.cpp H5PredType.cpp \
- H5EnumType.cpp H5IntType.cpp H5FloatType.cpp H5StrType.cpp \
- H5ArrayType.cpp H5VarLenType.cpp H5CompType.cpp H5DataSet.cpp \
- H5CommonFG.cpp H5Group.cpp H5File.cpp
+ H5Attribute.cpp H5Location.cpp H5Object.cpp H5PropList.cpp \
+ H5FaccProp.cpp H5FcreatProp.cpp H5DcreatProp.cpp H5DxferProp.cpp \
+ H5DataType.cpp H5DataSpace.cpp H5AbstractDs.cpp H5AtomType.cpp \
+ H5PredType.cpp H5EnumType.cpp H5IntType.cpp H5FloatType.cpp \
+ H5StrType.cpp H5ArrayType.cpp H5VarLenType.cpp H5CompType.cpp \
+ H5DataSet.cpp H5CommonFG.cpp H5Group.cpp H5File.cpp
# HDF5 C++ library depends on HDF5 Library.
@@ -500,8 +498,9 @@ include_HEADERS = H5Cpp.h H5AbstractDs.h H5AtomType.h H5Attribute.h H5Classes.h
H5CommonFG.h H5CompType.h H5DataSet.h H5DataSpace.h H5DataType.h \
H5DcreatProp.h H5DxferProp.h H5EnumType.h H5Exception.h H5FaccProp.h \
H5FcreatProp.h H5File.h H5FloatType.h H5Group.h H5IdComponent.h \
- H5Include.h H5IntType.h H5Library.h H5Object.h H5PredType.h \
- H5PropList.h H5StrType.h H5CppDoc.h H5ArrayType.h H5VarLenType.h
+ H5Include.h H5IntType.h H5Library.h H5Location.h H5Object.h \
+ H5PredType.h H5PropList.h H5StrType.h H5CppDoc.h H5ArrayType.h \
+ H5VarLenType.h
# h5c++ and libhdf5.settings are generated during configure. Remove only when
@@ -666,6 +665,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5IdComponent.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5IntType.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Library.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Location.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Object.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5PredType.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5PropList.Plo@am__quote@