diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2013-09-29 04:34:31 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2013-09-29 04:34:31 (GMT) |
commit | 5478de764594d5c30bf8cd53076892f0aa60543c (patch) | |
tree | 558d9e524e5f2e84026ebdfeb9960a5b8962c06d /c++/src | |
parent | 252ed47f9b0333a112a49a5b23a1cc4a5e108b1e (diff) | |
download | hdf5-5478de764594d5c30bf8cd53076892f0aa60543c.zip hdf5-5478de764594d5c30bf8cd53076892f0aa60543c.tar.gz hdf5-5478de764594d5c30bf8cd53076892f0aa60543c.tar.bz2 |
[svn-r24216] Purpose: Merged changes from trunk
Description from trunk, r22836
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
Description from trunk, r22845
Fixed miscellaneous inconsistencies and typos, which also took
care of the failure in Packet Table test on daily test today.
Description from trunk, r24143
Fixed comments, documentation, and mis-matched DOXYGEN_SHOULD_SKIP_THIS pairs.
Description from trunk, r24188
- The failure in daily test was caused by missing initialization of member
"id" in a few constructors. This is now fixed.
- Added two overloaded H5Location::setComment
- Improved some error reporting in H5Location
- Improved error reporting in tests
Description from trunk, r24189
Changed header guards from single underscore to double underscore.
Platforms tested:
SunOS 5.11 (emu)
Linux/32 2.6 (jam)
Linux/64 2.6 (koala)/PGI compilers
Diffstat (limited to 'c++/src')
45 files changed, 1272 insertions, 1443 deletions
diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index c5ffa36..e1e78e9 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -19,8 +19,8 @@ // Attribute and DataSet. It also inherits from H5Object and passes down // the services that H5Object provides. -#ifndef _AbstractDs_H -#define _AbstractDs_H +#ifndef __AbstractDs_H +#define __AbstractDs_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -51,18 +51,17 @@ class H5_DLLCPP AbstractDs { StrType getStrType() const; VarLenType getVarLenType() const; - // Gets the size in memory of this abstract dataset. + ///\brief Gets the size in memory of this abstract dataset. virtual size_t getInMemDataSize() const = 0; - // Gets the dataspace of this abstract dataset - pure virtual. + ///\brief Gets the dataspace of this abstract dataset - pure virtual. virtual DataSpace getSpace() const = 0; // Gets the class of the datatype that is used by this abstract // dataset. H5T_class_t getTypeClass() const; - // Returns the amount of storage size required for this abstract - // dataset - pure virtual. + ///\brief Returns the amount of storage size required - pure virtual. virtual hsize_t getStorageSize() const = 0; // Returns this class name - pure virtual. @@ -88,4 +87,4 @@ class H5_DLLCPP AbstractDs { #ifndef H5_NO_NAMESPACE } #endif -#endif // _AbstractDs_H +#endif // __AbstractDs_H diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index 0eb744c..d2e3c29 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -17,8 +17,8 @@ // Class ArrayType inherits from DataType and provides wrappers for the // HDF5 C's Array Datatypes. -#ifndef _H5ArrayType_H -#define _H5ArrayType_H +#ifndef __H5ArrayType_H +#define __H5ArrayType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -36,7 +36,7 @@ class H5_DLLCPP ArrayType : public DataType { // Returns the sizes of dimensions of this array datatype. int getArrayDims(hsize_t* dims); - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("ArrayType"); } // Copy constructor: makes copy of the original object. @@ -59,4 +59,4 @@ class H5_DLLCPP ArrayType : public DataType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5ArrayType_H diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 975cad6..09f762f 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -45,7 +45,6 @@ AtomType::AtomType() : DataType() {} // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- AtomType::AtomType( const hid_t existing_id ) : DataType( existing_id ) {} -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: AtomType copy constructor @@ -53,6 +52,7 @@ AtomType::AtomType( const hid_t existing_id ) : DataType( existing_id ) {} // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- AtomType::AtomType( const AtomType& original ) : DataType( original ) {} +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: AtomType::setSize @@ -285,12 +285,14 @@ void AtomType::setPad( H5T_pad_t lsb, H5T_pad_t msb ) const } } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: AtomType destructor ///\brief Noop destructor. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- AtomType::~AtomType() {} +#endif // DOXYGEN_SHOULD_SKIP_THIS #ifndef H5_NO_NAMESPACE } // end namespace diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 580b710..e8d6513 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -19,8 +19,8 @@ // subclasses. It also inherits from DataType and passes down the // services that are common to all the datatypes. -#ifndef _H5AtomType_H -#define _H5AtomType_H +#ifndef __H5AtomType_H +#define __H5AtomType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -57,14 +57,16 @@ class H5_DLLCPP AtomType : public DataType { // Sets the total size for an atomic datatype. void setSize( size_t size ) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("AtomType"); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Copy constructor - makes copy of the original object AtomType( const AtomType& original ); // Noop destructor virtual ~AtomType(); +#endif // DOXYGEN_SHOULD_SKIP_THIS protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -78,4 +80,4 @@ class H5_DLLCPP AtomType : public DataType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5AtomType_H diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 6c14269..34bf256 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -44,6 +44,7 @@ namespace H5 { #endif // H5_NO_STD #endif +class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate //-------------------------------------------------------------------------- // Function: Attribute default constructor ///\brief Default constructor: Creates a stub attribute @@ -411,7 +412,8 @@ void Attribute::flush(H5F_scope_t scope) const //-------------------------------------------------------------------------- // Function: Attribute::getId -// Purpose: Get the id of this attribute +///\brief Get the id of this attribute +///\return Attribute identifier // Description: // Class hierarchy is revised to address bugzilla 1068. Class // AbstractDS and Attribute are moved out of H5Object. In diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index cafc264..f9637fd 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5Attribute_H -#define _H5Attribute_H +#ifndef __H5Attribute_H +#define __H5Attribute_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -55,7 +55,7 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent { // attribute to disk. void flush( H5F_scope_t scope ) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("Attribute"); } // Creates a copy of an existing attribute using the attribute id @@ -99,4 +99,4 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5Attribute_H diff --git a/c++/src/H5Classes.h b/c++/src/H5Classes.h index f691548..de7cf4a 100644 --- a/c++/src/H5Classes.h +++ b/c++/src/H5Classes.h @@ -14,14 +14,15 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5Classes_H -#define _H5Classes_H +#ifndef __H5Classes_H +#define __H5Classes_H #ifndef H5_NO_NAMESPACE namespace H5 { #endif class Exception; class IdComponent; + class H5Location; class H5Object; class PropList; class FileCreatPropList; @@ -48,4 +49,4 @@ namespace H5 { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5Classes_H diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index b3889a0..3bf4b4f 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -460,135 +460,6 @@ H5std_string CommonFG::getLinkval( const H5std_string& name, size_t size ) const } //-------------------------------------------------------------------------- -// Function: CommonFG::setComment -///\brief Sets or resets the comment for an object specified by its name. -///\param name - IN: Name of the object -///\param comment - IN: New comment -///\exception H5::FileIException or H5::GroupIException -///\par Description -/// If \a comment is an empty string or a null pointer, the comment -/// message is removed from the object. -/// Comments should be relatively short, null-terminated, ASCII -/// strings. They can be attached to any object that has an -/// object header, e.g., data sets, groups, named data types, -/// and data spaces, but not symbolic links. -// Programmer Binh-Minh Ribler - 2000 -// Modification -// 2007: QAK modified to use H5O APIs; however the first parameter is -// no longer just file or group, this function should be moved -// to another class to accommodate attribute, dataset, and named -// datatype. - BMR -//-------------------------------------------------------------------------- -void CommonFG::setComment( const char* name, const char* comment ) const -{ - herr_t ret_value = H5Oset_comment_by_name( getLocId(), name, comment, H5P_DEFAULT ); - if( ret_value < 0 ) - throwException("setComment", "H5Oset_comment_by_name failed"); -} - -//-------------------------------------------------------------------------- -// Function: CommonFG::setComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name and \a comment. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -void CommonFG::setComment( const H5std_string& name, const H5std_string& comment ) const -{ - setComment( name.c_str(), comment.c_str() ); -} - -//-------------------------------------------------------------------------- -// Function: CommonFG::removeComment -///\brief Removes the comment from an object specified by its name. -///\param name - IN: Name of the object -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - May 2005 -// 2007: QAK modified to use H5O APIs; however the first parameter is -// no longer just file or group, this function should be moved -// to another class to accommodate attribute, dataset, and named -// datatype. - BMR -//-------------------------------------------------------------------------- -void CommonFG::removeComment(const char* name) const -{ - herr_t ret_value = H5Oset_comment_by_name(getLocId(), name, NULL, H5P_DEFAULT); - if( ret_value < 0 ) - throwException("removeComment", "H5Oset_comment_by_name failed"); -} - -//-------------------------------------------------------------------------- -// Function: CommonFG::removeComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - May 2005 -//-------------------------------------------------------------------------- -void CommonFG::removeComment(const H5std_string& name) const -{ - removeComment (name.c_str()); -} - -//-------------------------------------------------------------------------- -// Function: CommonFG::getComment -///\brief Retrieves comment for the specified object and its comment's -/// length. -///\param name - IN: Name of the object -///\param bufsize - IN: Length of the comment to retrieve -///\return Comment string -///\exception H5::FileIException or H5::GroupIException -// Programmer Binh-Minh Ribler - 2000 -// 2007: QAK modified to use H5O APIs; however the first parameter is -// no longer just file or group, this function should be moved -// to another class to accommodate attribute, dataset, and named -// datatype. - BMR -//-------------------------------------------------------------------------- -H5std_string CommonFG::getComment( const char* name, size_t bufsize ) const -{ - // bufsize is default to 256 - // temporary variable - hid_t loc_id = getLocId(); // temporary variable - - // temporary C-string for the object's comment; bufsize already including - // null character - char* comment_C = new char[bufsize]; - ssize_t ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, bufsize, H5P_DEFAULT); - - // if the actual length of the comment is longer than bufsize and bufsize - // was the default value, i.e., not given by the user, then call - // H5Oget_comment_by_name again with the correct value. - // If the call to H5Oget_comment_by_name returned an error, skip this block - // and throw an exception below. - if (ret_value >= 0 && (size_t)ret_value > bufsize && bufsize == 256) - { - size_t new_size = ret_value; - delete []comment_C; - comment_C = new char[new_size]; // new_size including null terminator - ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, new_size, H5P_DEFAULT); - } - - // if H5Oget_comment_by_name returns SUCCEED, return the string comment, - // otherwise, throw an exception - if( ret_value < 0 ) - throwException("getComment", "H5Oget_comment_by_name failed"); - - H5std_string comment = H5std_string(comment_C); - delete []comment_C; - return (comment); -} - -//-------------------------------------------------------------------------- -// Function: CommonFG::getComment -///\brief This is an overloaded member function, provided for convenience. -/// It differs from the above function in that it takes an -/// \c H5std_string for \a name. -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -H5std_string CommonFG::getComment( const H5std_string& name, size_t bufsize ) const -{ - return( getComment( name.c_str(), bufsize )); -} - -//-------------------------------------------------------------------------- // Function: CommonFG::mount ///\brief Mounts the file \a child onto this group. ///\param name - IN: Name of the group @@ -1136,6 +1007,7 @@ H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const } #endif /* H5_NO_DEPRECATED_SYMBOLS */ +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: CommonFG default constructor ///\brief Default constructor. @@ -1149,6 +1021,7 @@ CommonFG::CommonFG() {} // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- CommonFG::~CommonFG() {} +#endif // DOXYGEN_SHOULD_SKIP_THIS #ifndef H5_NO_NAMESPACE } diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 4f32d21..1748d1d 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -18,8 +18,8 @@ // common services that are provided by H5File and Group. The file or // group in the context of this class is referred to as 'location'. -#ifndef _CommonFG_H -#define _CommonFG_H +#ifndef __CommonFG_H +#define __CommonFG_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -49,18 +49,6 @@ class H5_DLLCPP CommonFG { DataSet openDataSet(const char* name) const; DataSet openDataSet(const H5std_string& name) const; - // Retrieves comment for the HDF5 object specified by its name. - H5std_string getComment(const char* name, size_t bufsize=256) const; - H5std_string getComment(const H5std_string& name, size_t bufsize=256) const; - - // Removes the comment for the HDF5 object specified by its name. - void removeComment(const char* name) const; - void removeComment(const H5std_string& name) const; - - // Sets the comment for an HDF5 object specified by its name. - void setComment(const char* name, const char* comment) const; - void setComment(const H5std_string& name, const H5std_string& comment) const; - // Returns the value of a symbolic link. H5std_string getLinkval(const char* link_name, size_t size=0) const; H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const; @@ -152,7 +140,6 @@ class H5_DLLCPP CommonFG { /// object id, i.e. file or group id. virtual hid_t getLocId() const = 0; -#endif // DOXYGEN_SHOULD_SKIP_THIS /// For subclasses, H5File and Group, to throw appropriate exception. virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const = 0; @@ -162,11 +149,12 @@ class H5_DLLCPP CommonFG { // Noop destructor. virtual ~CommonFG(); +#endif // DOXYGEN_SHOULD_SKIP_THIS }; // end of CommonFG declaration #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __CommonFG_H diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index 2336bd1..16ae839 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -17,8 +17,8 @@ // Class CompType inherits from DataType and provides accesses to a compound // datatype. -#ifndef _H5CompType_H -#define _H5CompType_H +#ifndef __H5CompType_H +#define __H5CompType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -97,7 +97,7 @@ class H5_DLLCPP CompType : public DataType { // Recursively removes padding from within this compound datatype. void pack() const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("CompType"); } // Noop destructor. @@ -111,4 +111,4 @@ class H5_DLLCPP CompType : public DataType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5CompType_H diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 75d82ba..044108b 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -14,14 +14,15 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5CPP_H -#define _H5CPP_H +#ifndef __H5Cpp_H +#define __H5Cpp_H #include "H5Include.h" #include "H5Exception.h" #include "H5IdComponent.h" #include "H5DataSpace.h" #include "H5PropList.h" +#include "H5Location.h" #include "H5Object.h" #include "H5AbstractDs.h" #include "H5Attribute.h" @@ -55,4 +56,4 @@ #define HOFFSET(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif -#endif +#endif // __H5Cpp_H diff --git a/c++/src/H5CppDoc.h b/c++/src/H5CppDoc.h index ab3fa79..baeca64 100644 --- a/c++/src/H5CppDoc.h +++ b/c++/src/H5CppDoc.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5CPPDOC_H -#define _H5CPPDOC_H +#ifndef __H5CppDoc_H +#define __H5CppDoc_H //------------------------------------------------------------------------- // The following section will be used to generate the 'Mainpage' @@ -88,4 +88,4 @@ /// This example shows how to work with groups. ///\example h5group.cpp -#endif +#endif // __H5CppDoc_H diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index f7aaa72..1a26045 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -79,57 +79,29 @@ DataSet::DataSet(const DataSet& original) : AbstractDs(original), H5Object(origi //-------------------------------------------------------------------------- // Function: DataSet overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 dataset, creates a +///\brief Given a reference, ref, to an hdf5 location, creates a /// DataSet object -///\param obj - IN: Dataset reference object is in or location of +///\param loc - 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 ///\par Description -/// \c obj can be DataSet, Group, H5File, or named DataType, that +/// \c loc 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() +DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object(), id(0) { - try { - id = p_dereference(obj.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("DataSet constructor - located by object", - deref_error.getDetailMsg()); - } + id = H5Location::p_dereference(loc.getId(), ref, ref_type, "constructor - by dereferenced"); } //-------------------------------------------------------------------------- // 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(H5File& h5file, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object() -{ - try { - id = p_dereference(h5file.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("DataSet constructor - located by HDF5 file", - deref_error.getDetailMsg()); - } -} - -//-------------------------------------------------------------------------- -// Function: DataSet overload constructor - dereference -///\brief Given a reference, ref, to an hdf5 dataset, creates a +///\brief Given a reference, ref, to an hdf5 attribute, creates a /// DataSet object ///\param attr - IN: Specifying location where the referenced object is in ///\param ref - IN: Reference pointer @@ -140,14 +112,9 @@ DataSet::DataSet(H5File& h5file, const void* ref, H5R_type_t ref_type) : Abstrac // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- -DataSet::DataSet(Attribute& attr, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object() +DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object(), id(0) { - try { - id = p_dereference(attr.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("DataSet constructor - located by attribute", - deref_error.getDetailMsg()); - } + id = H5Location::p_dereference(attr.getId(), ref, ref_type, "constructor - by dereference"); } //-------------------------------------------------------------------------- @@ -430,7 +397,7 @@ void DataSet::read( void* buf, const DataType& mem_type, const DataSpace& mem_sp // Function: DataSet::read ///\brief This is an overloaded member function, provided for convenience. /// It takes a reference to a \c H5std_string for the buffer. -///\param buf - IN: Buffer for read data +///\param strg - IN: Buffer for read data string ///\param mem_type - IN: Memory datatype ///\param mem_space - IN: Memory dataspace ///\param file_space - IN: Dataset's dataspace in the file @@ -644,57 +611,10 @@ 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. -///\param ref - IN: Reference to get region of -///\param ref_type - IN: Type of reference to get region of - default -/// to H5R_DATASET_REGION -///\return DataSpace instance -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - May, 2004 -//-------------------------------------------------------------------------- -DataSpace DataSet::getRegion(void *ref, H5R_type_t ref_type) const -{ - try { - DataSpace dataspace(p_get_region(ref, ref_type)); - return(dataspace); - } - catch (IdComponentException E) { - throw DataSetIException("DataSet::getRegion", E.getDetailMsg()); - } -} - //-------------------------------------------------------------------------- // Function: DataSet::getId ///\brief Get the id of this dataset. +///\return DataSet identifier // Description: // Class hierarchy is revised to address bugzilla 1068. Class // AbstractDs and Attribute are moved out of H5Object. In @@ -774,8 +694,9 @@ void DataSet::p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space HDfree(strg_C); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataSet::p_setId (private) +// Function: DataSet::p_setId (protected) ///\brief Sets the identifier of this dataset to a new value. /// ///\exception H5::IdComponentException when the attempt to close the HDF5 @@ -797,10 +718,8 @@ void DataSet::p_setId(const hid_t new_id) } // reset object's id to the given id id = new_id; - - // increment the reference counter of the new id - //incRefCount(); } +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataSet::close diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index 5c5f995..8fdc47e 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -16,8 +16,8 @@ // Class DataSet inherits from AbstractDs and provides accesses to a dataset. -#ifndef _H5DataSet_H -#define _H5DataSet_H +#ifndef __H5DataSet_H +#define __H5DataSet_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -76,21 +76,12 @@ 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; - - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DataSet"); } // Creates a dataset by way of dereference. - 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); + DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT); + DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT); // Default constructor. DataSet(); @@ -110,7 +101,6 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { private: hid_t id; // HDF5 dataset id -#ifndef DOXYGEN_SHOULD_SKIP_THIS // This function contains the common code that is used by // getTypeClass and various API functions getXxxType // defined in AbstractDs for generic datatype and specific @@ -122,6 +112,7 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { void p_read_variable_len(const hid_t mem_type_id, const hid_t mem_space_id, const hid_t file_space_id, const hid_t xfer_plist_id, H5std_string& strg) const; protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Sets the dataset id. virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -129,4 +120,4 @@ class H5_DLLCPP DataSet : public H5Object, public AbstractDs { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5DataSet_H diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 755ca5b..059c812 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -446,7 +446,7 @@ void DataSpace::getSelectBounds ( hsize_t* start, hsize_t* end ) const } //-------------------------------------------------------------------------- -// Function: DataSpace::H5Sselect_elements +// Function: DataSpace::selectElements ///\brief Selects array elements to be included in the selection for /// this dataspace. ///\param op - IN: Operator specifying how the new selection is to be @@ -556,7 +556,8 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h //-------------------------------------------------------------------------- // Function: DataSpace::getId -// Purpose: Get the id of this attribute +///\brief Get the id of this dataspace +///\return Dataspace identifier // Modification: // May 2008 - BMR // Class hierarchy is revised to address bugzilla 1068. Class @@ -570,6 +571,7 @@ hid_t DataSpace::getId() const return(id); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataSpace::p_setId ///\brief Sets the identifier of this object to a new value. @@ -594,6 +596,7 @@ void DataSpace::p_setId(const hid_t new_id) // reset object's id to the given id id = new_id; } +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataSpace::close diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 0d4ab68..1ea7188 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5DataSpace_H -#define _H5DataSpace_H +#ifndef __H5DataSpace_H +#define __H5DataSpace_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -103,7 +103,7 @@ class H5_DLLCPP DataSpace : public IdComponent { // Sets or resets the size of this dataspace. void setExtentSimple( int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL ) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DataSpace"); } // Creates a DataSpace object using an existing dataspace id. @@ -122,10 +122,13 @@ class H5_DLLCPP DataSpace : public IdComponent { hid_t id; // HDF5 dataspace id protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Sets the dataspace id. virtual void p_setId(const hid_t new_id); +#endif // DOXYGEN_SHOULD_SKIP_THIS + }; #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5DataSpace_H diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 3edb163..3d147c6 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -49,6 +49,13 @@ namespace H5 { #endif //-------------------------------------------------------------------------- +// Function: DataType default constructor +///\brief Default constructor: Creates a stub datatype +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DataType::DataType() : H5Object(), id(0) {} + +//-------------------------------------------------------------------------- // Function: DataType overloaded constructor ///\brief Creates a datatype using an existing datatype's id ///\param existing_id - IN: Id of the existing datatype @@ -88,32 +95,6 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object() // Function: DataType overload constructor - dereference ///\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 -///\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(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Object() -{ - try { - id = p_dereference(obj.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("DataType constructor - located by an H5Object", - deref_error.getDetailMsg()); - } -} - -//-------------------------------------------------------------------------- -// 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 @@ -123,14 +104,9 @@ DataType::DataType(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Obje // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- -DataType::DataType(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Object() +DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type) : H5Object(), id(0) { - try { - id = p_dereference(h5file.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("DataType constructor - located by an H5File", - deref_error.getDetailMsg()); - } + id = H5Location::p_dereference(loc.getId(), ref, ref_type, "constructor - by dereference"); } //-------------------------------------------------------------------------- @@ -146,24 +122,12 @@ DataType::DataType(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Obj // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- -DataType::DataType(Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object() +DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object(), id(0) { - try { - id = p_dereference(attr.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("DataType constructor - located by an Attribute", - deref_error.getDetailMsg()); - } + id = H5Location::p_dereference(attr.getId(), ref, ref_type, "constructor - by dereference"); } //-------------------------------------------------------------------------- -// Function: DataType default constructor -///\brief Default constructor: Creates a stub datatype -// Programmer Binh-Minh Ribler - 2000 -//-------------------------------------------------------------------------- -DataType::DataType() : H5Object(), id(0) {} - -//-------------------------------------------------------------------------- // Function: DataType copy constructor ///\brief Copy constructor: makes a copy of the original DataType object. // Programmer Binh-Minh Ribler - 2000 @@ -679,54 +643,10 @@ 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. -///\param ref - IN: Reference to get region of -///\param ref_type - IN: Type of reference to get region of - default -///\return DataSpace instance -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - May, 2004 -//-------------------------------------------------------------------------- -DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const -{ - try { - DataSpace dataspace(p_get_region(ref, ref_type)); - return(dataspace); - } - catch (IdComponentException E) { - throw DataTypeIException(inMemFunc("getRegion"), E.getDetailMsg()); - } -} - //-------------------------------------------------------------------------- // Function: DataType::getId -// Purpose: Get the id of this attribute +///\brief Get the id of this datatype +///\return Datatype identifier // Modification: // May 2008 - BMR // Class hierarchy is revised to address bugzilla 1068. Class @@ -740,6 +660,7 @@ hid_t DataType::getId() const return(id); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataType::p_setId ///\brief Sets the identifier of this object to a new value. @@ -764,6 +685,7 @@ void DataType::p_setId(const hid_t new_id) // reset object's id to the given id id = new_id; } +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataType::close diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 53709c7..4071a2c 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5DataType_H -#define _H5DataType_H +#ifndef __H5DataType_H +#define __H5DataType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -30,9 +30,8 @@ class H5_DLLCPP DataType : public H5Object { DataType( const DataType& original ); // Creates a datatype by way of dereference. - 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); + DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT); + DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT); // Closes this datatype. virtual void close(); @@ -101,15 +100,7 @@ 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; - - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DataType"); } // Creates a copy of an existing DataType using its id @@ -125,10 +116,12 @@ class H5_DLLCPP DataType : public H5Object { virtual ~DataType(); protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS hid_t id; // HDF5 datatype id // Sets the datatype id. virtual void p_setId(const hid_t new_id); +#endif // DOXYGEN_SHOULD_SKIP_THIS private: void p_commit(hid_t loc_id, const char* name); @@ -136,4 +129,4 @@ class H5_DLLCPP DataType : public H5Object { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5DataType_H diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 6eadfec..385bc61 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5DSCreatPropList_H -#define _H5DSCreatPropList_H +#ifndef __H5DSCreatPropList_H +#define __H5DSCreatPropList_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -107,7 +107,7 @@ class H5_DLLCPP DSetCreatPropList : public PropList { // Sets SZIP compression method. void setSzip(unsigned int options_mask, unsigned int pixels_per_block) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DSetCreatPropList"); } // Copy constructor: creates a copy of a DSetCreatPropList object. @@ -123,4 +123,4 @@ class H5_DLLCPP DSetCreatPropList : public PropList { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5DSCreatPropList_H diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 90fca0a..723603c 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5DSetMemXferPropList_H -#define _H5DSetMemXferPropList_H +#ifndef __H5DSetMemXferPropList_H +#define __H5DSetMemXferPropList_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -102,4 +102,4 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5DSetMemXferPropList_H diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index 4505c40..71e36c3 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5EnumType_H -#define _H5EnumType_H +#ifndef __H5EnumType_H +#define __H5EnumType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -57,7 +57,7 @@ class H5_DLLCPP EnumType : public DataType { void valueOf( const char* name, void *value ) const; void valueOf( const H5std_string& name, void *value ) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("EnumType"); } // Default constructor @@ -74,4 +74,4 @@ class H5_DLLCPP EnumType : public DataType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5EnumType_H diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index b4af2ba..8b12abc 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5Exception_H -#define _H5Exception_H +#ifndef __H5Exception_H +#define __H5Exception_H #include <string> @@ -161,4 +161,4 @@ class H5_DLLCPP IdComponentException : public Exception { } #endif -#endif // _H5Exception_H +#endif // __H5Exception_H diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 354eaf7..040b3e9 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5FileAccPropList_H -#define _H5FileAccPropList_H +#ifndef __H5FileAccPropList_H +#define __H5FileAccPropList_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -123,7 +123,7 @@ class H5_DLLCPP FileAccPropList : public PropList { // Returns garbage collecting references setting. unsigned getGcReferences() const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("FileAccPropList"); } // Copy constructor: creates a copy of a FileAccPropList object. @@ -139,4 +139,4 @@ class H5_DLLCPP FileAccPropList : public PropList { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5FileAccPropList_H diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index 2e2af70..de7d414 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5FileCreatPropList_H -#define _H5FileCreatPropList_H +#ifndef __H5FileCreatPropList_H +#define __H5FileCreatPropList_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -60,7 +60,7 @@ class H5_DLLCPP FileCreatPropList : public PropList { // indexing chunked datasets. void setIstorek( unsigned ik ) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("FileCreatPropList"); } // Copy constructor: creates a copy of a FileCreatPropList object. @@ -76,4 +76,4 @@ class H5_DLLCPP FileCreatPropList : public PropList { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5FileCreatPropList_H diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 6e85428..48c3513 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(), id(0) {} //-------------------------------------------------------------------------- // Function: H5File overloaded constructor @@ -82,7 +82,7 @@ H5File::H5File() : IdComponent(), id(0) {} // to catch then re-throw it. -BMR 2013/03/21 // 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(), id(0) { try { p_get_file(name, flags, create_plist, access_plist); @@ -107,7 +107,7 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c // to catch then re-throw it. -BMR 2013/03/21 // 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(), id(0) { try { p_get_file(name.c_str(), flags, create_plist, access_plist); @@ -116,6 +116,7 @@ H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPro } } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // This function is private and contains common code between the // constructors taking a string or a char* @@ -146,6 +147,7 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro } } } +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5File copy constructor @@ -154,34 +156,15 @@ 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 (static) -///\brief Determines whether a file in HDF5 format. +///\brief Determines whether a file in HDF5 format. (Static) ///\param name - IN: Name of the file ///\return true if the file is in HDF5 format, and false, otherwise ///\exception H5::FileIException @@ -205,7 +188,7 @@ bool H5File::isHdf5(const char* name) //-------------------------------------------------------------------------- // Function: H5File::isHdf5 (static) ///\brief This is an overloaded member function, provided for convenience. -/// It takes an \c H5std_string for \a name. +/// It takes an \c H5std_string for \a name. (Static) ///\param name - IN: Name of the file - \c H5std_string // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- @@ -283,8 +266,8 @@ void H5File::reOpen() throw FileIException("H5File::reOpen", close_error.getDetailMsg()); } - // call C routine to reopen the file - Note: not sure about this - // does id need to be closed later? which id to be the parameter? + // call C routine to reopen the file - Note: not sure about this, + // which id to be the parameter when closing? id = H5Freopen( id ); if( id < 0 ) // Raise exception when H5Freopen returns a neg value throw FileIException("H5File::reOpen", "H5Freopen failed"); @@ -292,12 +275,10 @@ void H5File::reOpen() //-------------------------------------------------------------------------- // Function: H5File::reopen -///\brief Reopens this file. -/// -///\exception H5::FileIException -///\par Description -/// This function will be replaced by the above function \c reOpen -/// in future releases. +// Purpose: Reopens this file. +// Exception H5::FileIException +// Description +// This function is replaced by the above function reOpen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5File::reopen() @@ -504,70 +485,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 -///\brief Retrieves a dataspace with the region pointed to selected. -///\param ref - IN: Reference to get region of -///\param ref_type - IN: Type of reference to get region of - default -///\return DataSpace instance -///\exception H5::FileIException -// Programmer Binh-Minh Ribler - May, 2004 -//-------------------------------------------------------------------------- -DataSpace H5File::getRegion(void *ref, H5R_type_t ref_type) const -{ - try { - DataSpace dataspace(p_get_region(ref, ref_type)); - return(dataspace); - } - catch (IdComponentException E) { - throw FileIException("H5File::getRegion", E.getDetailMsg()); - } -} - -//-------------------------------------------------------------------------- // Function: H5File::getFileSize ///\brief Returns the file size of the HDF5 file. ///\return File size @@ -589,134 +506,6 @@ hsize_t H5File::getFileSize() const } //-------------------------------------------------------------------------- -// Function: H5File::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 H5File::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: 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) -// 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 H5File::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); -} - -//-------------------------------------------------------------------------- // Function: H5File::getLocId // Purpose: Get the id of this file // Description @@ -731,7 +520,8 @@ hid_t H5File::getLocId() const //-------------------------------------------------------------------------- // Function: H5File::getId -// Purpose: Get the id of this attribute +///\brief Get the id of this file +///\return File identifier // Modification: // May 2008 - BMR // Class hierarchy is revised to address bugzilla 1068. Class @@ -745,8 +535,9 @@ hid_t H5File::getId() const return(id); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5File::p_setId +// Function: H5File::p_setId (protected) ///\brief Sets the identifier of this object to a new value. /// ///\exception H5::IdComponentException when the attempt to close the HDF5 @@ -769,6 +560,7 @@ void H5File::p_setId(const hid_t new_id) // reset object's id to the given id id = new_id; } +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5File::close diff --git a/c++/src/H5File.h b/c++/src/H5File.h index d87dc08..830dda0 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -14,14 +14,14 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5File_H -#define _H5File_H +#ifndef __H5File_H +#define __H5File_H #ifndef H5_NO_NAMESPACE 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,14 +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; - // Returns the pointer to the file handle of the low-level file driver. void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; void getVFDHandle(void **file_handle) const; @@ -87,14 +73,7 @@ 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; - - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("H5File"); } // Throw file exception. @@ -118,24 +97,12 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG { private: hid_t id; // HDF5 file id -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // This function is private and contains common code between the // constructors taking a string or a char* void p_get_file( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ); - // Creates a reference to an HDF5 object or a dataset region. - void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const; - -#ifndef H5_NO_DEPRECATED_SYMBOLS - // Retrieves the type of object that an object reference points to. - H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - // Retrieves a dataspace with the region pointed to selected. - hid_t p_get_region(void *ref, H5R_type_t ref_type) const; - protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Sets the HDF5 file id. virtual void p_setId(const hid_t new_id); @@ -145,4 +112,4 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5File_H diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index 08e5db1..13074ba 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5FloatType_H -#define _H5FloatType_H +#ifndef __H5FloatType_H +#define __H5FloatType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -23,10 +23,10 @@ namespace H5 { class H5_DLLCPP FloatType : public AtomType { public: - // Creates a floating-point type using a predefined type + // Creates a floating-point type using a predefined type. FloatType( const PredType& pred_type ); - // Gets the floating-point datatype of the specified dataset + // Gets the floating-point datatype of the specified dataset. FloatType( const DataSet& dataset ); // Retrieves the exponent bias of a floating-point type. @@ -53,13 +53,13 @@ class H5_DLLCPP FloatType : public AtomType { // Sets the mantissa normalization of a floating-point datatype. void setNorm( H5T_norm_t norm ) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("FloatType"); } // Default constructor FloatType(); - // Creates a floating-point datatype using an existing id + // Creates a floating-point datatype using an existing id. FloatType( const hid_t existing_id ); // Copy constructor: makes a copy of the original FloatType object. @@ -71,4 +71,4 @@ class H5_DLLCPP FloatType : public AtomType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5FloatType_H diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 6ec2dbb..d0231e3 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -99,33 +99,9 @@ Group::Group(const hid_t existing_id) : H5Object() /// is a datatype that has been named by DataType::commit. // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -Group::Group(H5Object& obj, const void* ref, H5R_type_t ref_type) : H5Object() +Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type) : H5Object(), id(0) { - try { - id = p_dereference(obj.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("Group constructor - located by an H5Object", - deref_error.getDetailMsg()); - } -} - -//-------------------------------------------------------------------------- -// 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() -{ - try { - id = p_dereference(h5file.getId(), ref, ref_type); - } catch (ReferenceException deref_error) { - throw ReferenceException("Group constructor - located by an H5File", - deref_error.getDetailMsg()); - } + id = H5Location::p_dereference(loc.getId(), ref, ref_type, "constructor - by dereference"); } //-------------------------------------------------------------------------- @@ -137,66 +113,15 @@ Group::Group(H5File& h5file, const void* ref, H5R_type_t ref_type) : H5Object() ///\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 -//-------------------------------------------------------------------------- -// 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. -///\param ref - IN: Reference to get region of -///\param ref_type - IN: Type of reference to get region of - default -///\return DataSpace instance -///\exception H5::GroupIException -// Programmer Binh-Minh Ribler - May, 2004 -//-------------------------------------------------------------------------- -DataSpace Group::getRegion(void *ref, H5R_type_t ref_type) const +Group::Group(const Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object(), id(0) { - try { - DataSpace dataspace(p_get_region(ref, ref_type)); - return(dataspace); - } - catch (IdComponentException E) { - throw GroupIException("Group::getRegion", E.getDetailMsg()); - } + id = H5Location::p_dereference(attr.getId(), ref, ref_type, "constructor - by dereference"); } //-------------------------------------------------------------------------- // Function: Group::getId -// Purpose: Get the id of this attribute +///\brief Get the id of this group +///\return Group identifier // Modification: // May 2008 - BMR // Class hierarchy is revised to address bugzilla 1068. Class @@ -210,6 +135,7 @@ hid_t Group::getId() const return(id); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: Group::p_setId ///\brief Sets the identifier of this object to a new value. @@ -234,6 +160,7 @@ void Group::p_setId(const hid_t new_id) // reset object's id to the given id id = new_id; } +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: Group::close diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 094b4a7..e3f1ddb 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5Group_H -#define _H5Group_H +#ifndef __H5Group_H +#define __H5Group_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -26,15 +26,7 @@ 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; - - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("Group"); } // Throw group exception. @@ -44,9 +36,8 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { virtual hid_t getLocId() const; // Creates a group by way of dereference. - 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); + Group(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT); + Group(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT); // default constructor Group(); @@ -67,10 +58,12 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { hid_t id; // HDF5 group id protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Sets the group id. virtual void p_setId(const hid_t new_id); +#endif // DOXYGEN_SHOULD_SKIP_THIS }; #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5Group_H diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 9f96277..c60d05c 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -144,6 +144,8 @@ int IdComponent::getCounter() const //-------------------------------------------------------------------------- H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) { + if (obj_id == 0) + return H5I_BADID; // invalid H5I_type_t id_type = H5Iget_type(obj_id); if (id_type <= H5I_BADID || id_type >= H5I_NTYPES) return H5I_BADID; // invalid @@ -269,7 +271,7 @@ IdComponent::IdComponent() {} // Description: // This function is protected so that the user applications can // only have access to its code via allowable classes, namely, -// H5File and H5Object subclasses. +// Attribute and H5Location subclasses. // Programmer Binh-Minh Ribler - Jul, 2004 //-------------------------------------------------------------------------- H5std_string IdComponent::p_get_file_name() const @@ -314,6 +316,9 @@ H5std_string IdComponent::p_get_file_name() const //-------------------------------------------------------------------------- bool IdComponent::p_valid_id(const hid_t obj_id) { + if (obj_id == 0) + return false; + H5I_type_t id_type = H5Iget_type(obj_id); if (id_type <= H5I_BADID || id_type >= H5I_NTYPES) return false; @@ -321,6 +326,14 @@ bool IdComponent::p_valid_id(const hid_t obj_id) return true; } +// Notes about IdComponent::id +// May 2008 - BMR +// Class hierarchy is revised to address bugzilla 1068... +// ...member IdComponent::id is moved into subclasses, and +// IdComponent::getId now becomes pure virtual function. +// (reasons: 1. encountered problems when adding H5Location; +// 2. Scott Meyers, item 33) + #endif // DOXYGEN_SHOULD_SKIP_THIS #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 7dc1da3..5a61947 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _IdComponent_H -#define _IdComponent_H +#ifndef __IdComponent_H +#define __IdComponent_H // IdComponent represents an HDF5 object that has an identifier. @@ -44,8 +44,10 @@ class H5_DLLCPP IdComponent { // Assignment operator. IdComponent& operator=( const IdComponent& rhs ); +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Gets the identifier of this object. virtual hid_t getId () const = 0; +#endif // DOXYGEN_SHOULD_SKIP_THIS // Sets the identifier of this object to a new value. void setId(const hid_t new_id); @@ -96,4 +98,4 @@ class H5_DLLCPP IdComponent { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __IdComponent_H diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index 3557c04..02efb64 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5IntType_H -#define _H5IntType_H +#ifndef __H5IntType_H +#define __H5IntType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -35,7 +35,7 @@ class H5_DLLCPP IntType : public AtomType { // Sets the sign proprety for an integer type. void setSign( H5T_sign_t sign ) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("IntType"); } // Default constructor @@ -53,4 +53,4 @@ class H5_DLLCPP IntType : public AtomType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5IntType_H diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index a3e1c99..c92a943 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5Library_H -#define _H5Library_H +#ifndef __H5Library_H +#define __H5Library_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -67,4 +67,4 @@ class H5_DLLCPP H5Library { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5Library_H diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp new file mode 100644 index 0000000..a527712 --- /dev/null +++ b/c++/src/H5Location.cpp @@ -0,0 +1,832 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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() {} + +//-------------------------------------------------------------------------- +// 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) {} + +//-------------------------------------------------------------------------- +// 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 ) {} + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +//-------------------------------------------------------------------------- +// 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::Exception +///\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 Exception(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::setComment +///\brief Sets or resets the comment for an object specified by its name. +///\param name - IN: Name of the object +///\param comment - IN: New comment +///\exception H5::Exception +///\par Description +/// If \a comment is an empty string or a null pointer, the comment +/// message is removed from the object. +/// Comments should be relatively short, null-terminated, ASCII +/// strings. They can be attached to any object that has an +/// object header, e.g., data sets, groups, named data types, +/// and data spaces, but not symbolic links. +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) +// Modification +// 2007: QAK modified to use H5O APIs; however the first parameter is +// no longer just file or group, this function should be moved +// to another class to accommodate attribute, dataset, and named +// datatype. - BMR +//-------------------------------------------------------------------------- +void H5Location::setComment(const char* name, const char* comment) const +{ + herr_t ret_value = H5Oset_comment_by_name(getId(), name, comment, H5P_DEFAULT); + if( ret_value < 0 ) + throw Exception(inMemFunc("setComment"), "H5Oset_comment_by_name failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::setComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name and \a comment. +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) +//-------------------------------------------------------------------------- +void H5Location::setComment(const H5std_string& name, const H5std_string& comment) const +{ + setComment(name.c_str(), comment.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::setComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it doesn't take +/// an object name. +// Programmer Binh-Minh Ribler - Sep 2013 +// Modification +//-------------------------------------------------------------------------- +void H5Location::setComment(const char* comment) const +{ + herr_t ret_value = H5Oset_comment_by_name(getId(), ".", comment, H5P_DEFAULT); + if( ret_value < 0 ) + throw Exception(inMemFunc("setComment"), "H5Oset_comment_by_name failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::setComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a comment. +// Programmer Binh-Minh Ribler - Sep 2013 +//-------------------------------------------------------------------------- +void H5Location::setComment(const H5std_string& comment) const +{ + setComment(comment.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::removeComment +///\brief Removes the comment from an object specified by its name. +///\param name - IN: Name of the object +///\exception H5::Exception +// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) +// 2007: QAK modified to use H5O APIs; however the first parameter is +// no longer just file or group, this function should be moved +// to another class to accommodate attribute, dataset, and named +// datatype. - BMR +//-------------------------------------------------------------------------- +void H5Location::removeComment(const char* name) const +{ + herr_t ret_value = H5Oset_comment_by_name(getId(), name, NULL, H5P_DEFAULT); + if( ret_value < 0 ) + throw Exception(inMemFunc("removeComment"), "H5Oset_comment_by_name failed"); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::removeComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - May 2005 (moved from CommonFG, Sep 2013) +//-------------------------------------------------------------------------- +void H5Location::removeComment(const H5std_string& name) const +{ + removeComment (name.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getComment +///\brief Retrieves comment for the specified object and its comment's +/// length. +///\param name - IN: Name of the object +///\param bufsize - IN: Length of the comment to retrieve +///\return Comment string +///\exception H5::Exception +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) +// 2007: QAK modified to use H5O APIs; however the first parameter is +// no longer just file or group, this function should be moved +// to another class to accommodate attribute, dataset, and named +// datatype. - BMR +//-------------------------------------------------------------------------- +H5std_string H5Location::getComment(const char* name, size_t bufsize) const +{ + // bufsize is default to 256 + // temporary variable + hid_t loc_id = getId(); // temporary variable + + // temporary C-string for the object's comment; bufsize already including + // null character + char* comment_C = new char[bufsize]; + ssize_t ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, bufsize, H5P_DEFAULT); + + // if the actual length of the comment is longer than bufsize and bufsize + // was the default value, i.e., not given by the user, then call + // H5Oget_comment_by_name again with the correct value. + // If the call to H5Oget_comment_by_name returned an error, skip this block + // and throw an exception below. + if (ret_value >= 0 && (size_t)ret_value > bufsize && bufsize == 256) + { + size_t new_size = ret_value; + delete []comment_C; + comment_C = new char[new_size]; // new_size including null terminator + ret_value = H5Oget_comment_by_name(loc_id, name, comment_C, new_size, H5P_DEFAULT); + } + + // if H5Oget_comment_by_name returns SUCCEED, return the string comment, + // otherwise, throw an exception + if (ret_value < 0) { + delete []comment_C; + throw Exception(inMemFunc("getComment"), "H5Oget_comment_by_name failed"); + } + + H5std_string comment = H5std_string(comment_C); + delete []comment_C; + return (comment); +} + +//-------------------------------------------------------------------------- +// Function: H5Location::getComment +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +// Programmer Binh-Minh Ribler - 2000 (moved from CommonFG, Sep 2013) +//-------------------------------------------------------------------------- +H5std_string H5Location::getComment(const H5std_string& name, size_t bufsize) const +{ + return(getComment(name.c_str(), bufsize)); +} +#ifndef DOXYGEN_SHOULD_SKIP_THIS + +//-------------------------------------------------------------------------- +// 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(inMemFunc("reference"), "H5Rcreate failed"); + } +} + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +//-------------------------------------------------------------------------- +// 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. (default) +///\exception H5::ReferenceException +///\notes This method is more suitable for a dataset region reference. +// 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(inMemFunc("reference"), E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: H5Location::reference +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function in that it takes an +/// \c H5std_string for \a name. +///\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. (default) +///\exception H5::ReferenceException +///\notes This method is more suitable for a dataset region reference. +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& dataspace, H5R_type_t ref_type) const +{ + try { + p_reference(ref, name.c_str(), dataspace.getId(), ref_type); + } + catch (ReferenceException E) { + throw ReferenceException(inMemFunc("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 does not take +/// a DataSpace object and the reference type must be specified. +///\param ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference (default) +/// \li \c H5R_DATASET_REGION - Reference is a dataset region +///\exception H5::ReferenceException +///\notes This method is more suitable for an object reference. +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) const +{ + try { + p_reference(ref, name, -1, ref_type); + } + catch (ReferenceException E) { + throw ReferenceException(inMemFunc("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 +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT - Reference is an object reference (default) +/// \li \c H5R_DATASET_REGION - Reference is a dataset region +///\notes This method is more suitable for an object reference. +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void H5Location::reference(void* ref, const H5std_string& name, H5R_type_t ref_type) const +{ + reference(ref, name.c_str(), ref_type); +} + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +//-------------------------------------------------------------------------- +// 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, const char* from_func) +{ + hid_t temp_id = H5Rdereference(loc_id, ref_type, ref); + if (temp_id < 0) + { + throw ReferenceException(inMemFunc(from_func), "H5Rdereference failed"); + } + + return(temp_id); +} +#endif // DOXYGEN_SHOULD_SKIP_THIS + +//-------------------------------------------------------------------------- +// 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(const H5Location& loc, const void* ref, H5R_type_t ref_type) +{ + p_setId(p_dereference(loc.getId(), ref, ref_type, "dereference")); +} + +//-------------------------------------------------------------------------- +// 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(const Attribute& attr, const void* ref, H5R_type_t ref_type) +{ + p_setId(p_dereference(attr.getId(), ref, ref_type, "dereference")); +} + +#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 - 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_UNKNOWN - A failure occurs. (-1) +/// \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 +/// \li \c H5G_LINK - Object is a symbolic link. +/// \li \c H5G_UDLINK - Object 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(inMemFunc("getObjType"), E.getDetailMsg()); + } +} + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +//-------------------------------------------------------------------------- +// 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(inMemFunc("getObjType"), "H5Rget_obj_type1 failed"); + } + return(obj_type); +} +#endif // DOXYGEN_SHOULD_SKIP_THIS +#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(inMemFunc("getRefObjType"), E.getDetailMsg()); + } +} + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +//-------------------------------------------------------------------------- +// 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(inMemFunc("getRefObjType"), "H5Rget_obj_type2 failed"); + } + return(obj_type); +} + + +//-------------------------------------------------------------------------- +// Function: H5Location::getRegion +///\brief Retrieves a dataspace with the region pointed to selected. +///\param ref - IN: Reference to get region of +///\param ref_type - IN: Type of reference to get region of - default +// to H5R_DATASET_REGION +///\return DataSpace object +///\exception H5::ReferenceException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const +{ + hid_t space_id = H5Rget_region(getId(), ref_type, ref); + if (space_id < 0) + { + throw ReferenceException(inMemFunc("getRegion"), "H5Rget_region failed"); + } + try { + DataSpace dataspace(space_id); + return(dataspace); + } + catch (DataSpaceIException E) { + throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); + } +} + + +//-------------------------------------------------------------------------- +// Function: H5Location destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +H5Location::~H5Location() {} + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +#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..3aadd50 --- /dev/null +++ b/c++/src/H5Location.h @@ -0,0 +1,167 @@ +// 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, or committed datatype. + +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); + + // Checks whether the named attribute exists at this location. + bool attrExists(const char* name) const; + bool attrExists(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; + + // Removes the named attribute from this location. + void removeAttr(const char* name) const; + void removeAttr(const H5std_string& name) const; + + // Sets the comment for an HDF5 object specified by its name. + void setComment(const char* name, const char* comment) const; + void setComment(const H5std_string& name, const H5std_string& comment) const; + void setComment(const char* comment) const; + void setComment(const H5std_string& comment) const; + + // Retrieves comment for the HDF5 object specified by its name. + H5std_string getComment(const char* name, size_t bufsize=256) const; + H5std_string getComment(const H5std_string& name, size_t bufsize=256) const; + + // Removes the comment for the HDF5 object specified by its name. + void removeComment(const char* name) const; + void removeComment(const H5std_string& name) const; + + // Creates a reference to a named object or to a dataset region + // in this object. + void reference(void* ref, const char* name, + H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void* ref, const H5std_string& name, + H5R_type_t ref_type = H5R_OBJECT) const; + void reference(void* ref, const char* name, const DataSpace& dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + void reference(void* ref, const H5std_string& name, const DataSpace& dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Open a referenced object whose location is specified by either + // a file, an HDF5 object, or an attribute. + void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT); + void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT); + + // Retrieves a dataspace with the region pointed to selected. + DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; + + ///\brief Returns an identifier. (pure virtual) + 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, const char* from_func); + +#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; + + // Noop destructor. + virtual ~H5Location(); + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +}; /* end class H5Location */ + +#ifndef H5_NO_NAMESPACE +} +#endif +#endif // __H5Location_H diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 225975b..1d96f2e 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -37,30 +37,11 @@ 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->object, s_attr_name, myData->opData ); - return 0; -} - //-------------------------------------------------------------------------- // Function: H5Object default constructor (protected) -// Description -// The id is set by IdComponent() but subclass constructor will -// set it to a valid HDF5 id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5Object::H5Object() : IdComponent(0) {} +H5Object::H5Object() : H5Location() {} //-------------------------------------------------------------------------- // Function: H5Object overloaded constructor (protected) @@ -69,9 +50,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 ) {} - -#endif // DOXYGEN_SHOULD_SKIP_THIS +H5Object::H5Object( const hid_t object_id ) : H5Location( object_id ) {} //-------------------------------------------------------------------------- // Function: H5Object copy constructor @@ -80,496 +59,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 = 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); -} - -//-------------------------------------------------------------------------- -// 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 @@ -577,6 +67,7 @@ hid_t H5Object::p_get_region(void *ref, H5R_type_t ref_type) const // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- H5Object::~H5Object() {} +#endif // DOXYGEN_SHOULD_SKIP_THIS #ifndef H5_NO_NAMESPACE } // end namespace diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index 4ac417b..3f9c343 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -14,84 +14,33 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5Object_H -#define _H5Object_H +#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 { #endif -#ifndef DOXYGEN_SHOULD_SKIP_THIS -class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate - -// Define the operator function pointer for H5Aiterate(). -typedef void (*attr_operator_t)( H5Object& 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; - H5Object* object; -}; -#endif // DOXYGEN_SHOULD_SKIP_THIS - -// 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); - +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Copy constructor: makes copy of an H5Object object. H5Object(const H5Object& original); @@ -99,30 +48,12 @@ class H5_DLLCPP H5Object : public IdComponent { virtual ~H5Object(); protected: -#ifndef DOXYGEN_SHOULD_SKIP_THIS // Default constructor H5Object(); // 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 */ @@ -130,4 +61,4 @@ class H5_DLLCPP H5Object : public IdComponent { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5Object_H diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 9dfc760..27cfd3a 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -56,6 +56,7 @@ PredType::PredType( const hid_t predtype_id ) : AtomType( predtype_id ) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- PredType::PredType() : AtomType() {} +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: PredType copy constructor @@ -65,6 +66,7 @@ PredType::PredType() : AtomType() {} //-------------------------------------------------------------------------- PredType::PredType( const PredType& original ) : AtomType( original ) {} +#ifndef DOXYGEN_SHOULD_SKIP_THIS // Flag to terminate HDF5 library in DataType::~DataType const PredType PredType::AtExit(H5CPP_EXITED); diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 9cb1c65..65e1c07 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -19,8 +19,8 @@ // closed by H5Tclose. They are treated as constants. ///////////////////////////////////////////////////////////////////// -#ifndef _H5PredType_H -#define _H5PredType_H +#ifndef __H5PredType_H +#define __H5PredType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -32,11 +32,13 @@ namespace H5 { before the other PredType objects are created. At exit, when this special PredType object is to be destructed, no HDF5 library function will be called and the library will be terminated. -BMR, Mar 30, 2012 */ +#ifndef DOXYGEN_SHOULD_SKIP_THIS #define H5CPP_EXITED -3 // -3 is less likely to be used elsewhere +#endif // DOXYGEN_SHOULD_SKIP_THIS class H5_DLLCPP PredType : public AtomType { public: - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("PredType"); } // Makes a copy of the predefined type and stores the new @@ -256,4 +258,4 @@ class H5_DLLCPP PredType : public AtomType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5PredType_H diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index ceea15f..9476d46 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -39,7 +39,7 @@ namespace H5 { //-------------------------------------------------------------------------- ///\brief Constant for default property. //-------------------------------------------------------------------------- -const PropList PropList::DEFAULT( H5P_DEFAULT ); +const PropList PropList::DEFAULT; //-------------------------------------------------------------------------- // Function Default constructor @@ -74,6 +74,9 @@ PropList::PropList(const PropList& original) : IdComponent(original) //-------------------------------------------------------------------------- PropList::PropList( const hid_t plist_id ) : IdComponent() { + if (plist_id == 0) + id = H5P_DEFAULT; + H5I_type_t id_type = H5Iget_type(plist_id); switch (id_type) { case H5I_GENPROP_CLS: @@ -216,7 +219,8 @@ void PropList::copyProp( PropList& dest, PropList& src, const H5std_string& name //-------------------------------------------------------------------------- // Function: PropList::getId -// Purpose: Get the id of this attribute +///\brief Get the id of this property list +///\return Property list identifier // Description: // Class hierarchy is revised to address bugzilla 1068. Class // AbstractDS and Attribute are moved out of H5Object. In @@ -229,6 +233,7 @@ hid_t PropList::getId() const return(id); } +#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: PropList::p_setId ///\brief Sets the identifier of this object to a new value. @@ -253,6 +258,7 @@ void PropList::p_setId(const hid_t new_id) // reset object's id to the given id id = new_id; } +#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: PropList::close diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index 2c079f9..b2c50d4 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5PropList_H -#define _H5PropList_H +#ifndef __H5PropList_H +#define __H5PropList_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -94,7 +94,7 @@ class H5_DLLCPP PropList : public IdComponent { void removeProp(const char *name) const; void removeProp(const H5std_string& name) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("PropList"); } // Default constructor: creates a stub PropList object. @@ -110,13 +110,15 @@ class H5_DLLCPP PropList : public IdComponent { virtual ~PropList(); protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS hid_t id; // HDF5 property list id // Sets the property list id. virtual void p_setId(const hid_t new_id); +#endif // DOXYGEN_SHOULD_SKIP_THIS }; #ifndef H5_NO_NAMESPACE } #endif -#endif // _H5PropList_H +#endif // __H5PropList_H diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index 8e79712..251b0b8 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -14,8 +14,8 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#ifndef _H5StrType_H -#define _H5StrType_H +#ifndef __H5StrType_H +#define __H5StrType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -47,7 +47,7 @@ class H5_DLLCPP StrType : public AtomType { // Defines the storage mechanism for character strings. void setStrpad(H5T_str_t strpad) const; - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("StrType"); } // default constructor @@ -65,4 +65,4 @@ class H5_DLLCPP StrType : public AtomType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5StrType_H diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index 688b2cc..caa347a 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -17,8 +17,8 @@ // Class VarLenType inherits from DataType and provides wrappers for // the HDF5 C's Variable-length Datatypes. -#ifndef _H5VarLenType_H -#define _H5VarLenType_H +#ifndef __H5VarLenType_H +#define __H5VarLenType_H #ifndef H5_NO_NAMESPACE namespace H5 { @@ -30,7 +30,7 @@ class H5_DLLCPP VarLenType : public DataType { // on the specified base type. VarLenType(const DataType* base_type); - ///\brief Returns this class name + ///\brief Returns this class name. virtual H5std_string fromClass () const { return("VarLenType"); } // Copy constructor: makes copy of the original object. @@ -49,4 +49,4 @@ class H5_DLLCPP VarLenType : public DataType { #ifndef H5_NO_NAMESPACE } #endif -#endif +#endif // __H5VarLenType_H 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 d9fa6e3..3ef45c6 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@) @@ -482,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. @@ -498,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 @@ -664,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@ |