diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2005-03-18 05:36:42 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2005-03-18 05:36:42 (GMT) |
commit | cde84a55f48f83e5e13ca6138f5224ede7b612a6 (patch) | |
tree | 29ea1e65c162bf892cf8e9f5652834339bebdb1c /c++ | |
parent | 1e85060177b43f4cdc8ee2c5381d636e85f2ae40 (diff) | |
download | hdf5-cde84a55f48f83e5e13ca6138f5224ede7b612a6.zip hdf5-cde84a55f48f83e5e13ca6138f5224ede7b612a6.tar.gz hdf5-cde84a55f48f83e5e13ca6138f5224ede7b612a6.tar.bz2 |
[svn-r10233] Purpose: Added more wrappers
Description:
Added the following to the C++ library
+ overloaded functions:
string CommonFG::getObjnameByIdx(hsize_t idx)
H5T_order_t AtomType::getOrder()
+ wrappers for H5*close
+ wrappers for H5Arename, H5Aget_storage_size, and H5Dget_storage_size
Platforms tested:
Linux 2.4 (heping)
AIX 5.1 (copper)
SunOS 5.8 64-bit (sol)
Diffstat (limited to 'c++')
-rw-r--r-- | c++/src/H5AbstractDs.h | 9 | ||||
-rw-r--r-- | c++/src/H5AtomType.cpp | 49 | ||||
-rw-r--r-- | c++/src/H5AtomType.h | 1 | ||||
-rw-r--r-- | c++/src/H5Attribute.cpp | 40 | ||||
-rw-r--r-- | c++/src/H5Attribute.h | 18 | ||||
-rw-r--r-- | c++/src/H5CommonFG.cpp | 34 | ||||
-rw-r--r-- | c++/src/H5CommonFG.h | 1 | ||||
-rw-r--r-- | c++/src/H5DataSet.cpp | 45 | ||||
-rw-r--r-- | c++/src/H5DataSet.h | 10 | ||||
-rw-r--r-- | c++/src/H5DataSpace.cpp | 36 | ||||
-rw-r--r-- | c++/src/H5DataSpace.h | 6 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 31 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 8 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 27 | ||||
-rw-r--r-- | c++/src/H5File.h | 8 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 23 | ||||
-rw-r--r-- | c++/src/H5Group.h | 8 | ||||
-rw-r--r-- | c++/src/H5IdComponent.h | 10 | ||||
-rw-r--r-- | c++/src/H5Object.cpp | 29 | ||||
-rw-r--r-- | c++/src/H5Object.h | 4 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 29 | ||||
-rw-r--r-- | c++/src/H5PropList.h | 8 |
22 files changed, 256 insertions, 178 deletions
diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 13c2309..764993c 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -47,6 +47,10 @@ class H5_DLLCPP AbstractDs : public H5Object { // dataset H5T_class_t getTypeClass() const; + // Returns the amount of storage size required for this abstract + // dataset - pure virtual. + virtual hsize_t getStorageSize() const = 0; + // Copy constructor AbstractDs( const AbstractDs& original ); @@ -60,11 +64,8 @@ class H5_DLLCPP AbstractDs : public H5Object { AbstractDs( const hid_t ds_id ); private: - // This member function is implemented by DataSet and Attribute + // This member function is implemented by DataSet and Attribute. virtual hid_t p_get_type() const = 0; - - // This member function is implemented by DataSet and Attribute - virtual void p_close() const = 0; }; #ifndef H5_NO_NAMESPACE } diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 902d07c..97a8692 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -71,17 +71,16 @@ void AtomType::setSize( size_t size ) const } //-------------------------------------------------------------------------- -// Function: AtomType::getOrder -///\brief Returns the byte order of an atomic datatype. -///\param order_string - OUT: Text description of the returned byte order -///\return Byte order, which can be: -/// \li \c H5T_ORDER_LE -/// \li \c H5T_ORDER_BE -/// \li \c H5T_ORDER_VAX -///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Function: AtomType::getOrder +///\brief Returns the byte order of an atomic datatype. +///\return Byte order, which can be: +/// \li \c H5T_ORDER_LE +/// \li \c H5T_ORDER_BE +/// \li \c H5T_ORDER_VAX +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- -H5T_order_t AtomType::getOrder( string& order_string ) const +H5T_order_t AtomType::getOrder() const { // Call C routine to get the byte ordering H5T_order_t type_order = H5Tget_order( id ); @@ -89,9 +88,35 @@ H5T_order_t AtomType::getOrder( string& order_string ) const // return a byte order constant if successful if( type_order == H5T_ORDER_ERROR ) { - throw DataTypeIException("AtomType::getOrder", - "H5Tget_order returns H5T_ORDER_ERROR"); + throw DataTypeIException("AtomType::getOrder", + "H5Tget_order returns H5T_ORDER_ERROR"); } + return( type_order ); +} + +//-------------------------------------------------------------------------- +// Function: AtomType::getOrder +///\brief This is an overloaded member function, provided for convenience. +/// It takes a reference to a \c std::string for the buffer that +/// provide the text description of the returned byte order. +/// The text description can be either of the following: +/// "Little endian byte ordering (0)"; +/// "Big endian byte ordering (1)"; +/// "VAX mixed byte ordering (2)"; +///\param order_string - OUT: Text description of the returned byte order +///\return Byte order, which can be: +/// \li \c H5T_ORDER_LE +/// \li \c H5T_ORDER_BE +/// \li \c H5T_ORDER_VAX +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +H5T_order_t AtomType::getOrder( string& order_string ) const +{ + // Call the overloaded to get the type order without text + H5T_order_t type_order = getOrder(); + + // Then provide the text and return the type order if( type_order == H5T_ORDER_LE ) order_string = "Little endian byte ordering (0)"; else if( type_order == H5T_ORDER_BE ) diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 4190b80..f9b43c4 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -28,6 +28,7 @@ class H5_DLLCPP AtomType : public DataType { public: // Returns the byte order of an atomic datatype. H5T_order_t getOrder( string& order_string ) const; + H5T_order_t getOrder() const; // Sets the byte ordering of an atomic datatype. void setOrder( H5T_order_t order ) const; diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index a5d4964..770a8d9 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -256,33 +256,45 @@ string Attribute::getName() const return( attr_name ); } -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: Attribute::p_close (private) -// Purpose: Closes this attribute. -// Exception H5::AttributeIException -// Description -// This function will be obsolete because its functionality -// is recently handled by the C library layer. - May, 2004 -// Programmer Binh-Minh Ribler - 2000 +// Function: Attribute::getStorageSize +///\brief Returns the amount of storage size required for this attribute. +///\return Size of the storage or 0, for no data +///\exception H5::AttributeIException +// Note: H5Dget_storage_size returns 0 when there is no data. This +// function should have no failure. (from SLU) +// Programmer Binh-Minh Ribler - Mar, 2005 +//-------------------------------------------------------------------------- +hsize_t Attribute::getStorageSize() const +{ + hsize_t storage_size = H5Aget_storage_size(id); + return (storage_size); +} + +//-------------------------------------------------------------------------- +// Function: Attribute::close +///\brief: Closes this attribute. +///\exception H5::AttributeIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Attribute::p_close() const +void Attribute::close() { - herr_t ret_value = H5Aclose( id ); + herr_t ret_value = H5Aclose(id); if( ret_value < 0 ) { - throw AttributeIException(0, "H5Aclose failed"); + throw AttributeIException("Attribute::close", "H5Aclose failed"); } + // reset the id because the attribute that it represents is now closed + id = 0; } -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: Attribute destructor ///\brief Properly terminates access to this attribute. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- Attribute::~Attribute() { diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index b18a6f0..87b2253 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -30,6 +30,9 @@ class H5_DLLCPP Attribute : public AbstractDs { // Gets a copy of the dataspace for this attribute. virtual DataSpace getSpace() const; + // Returns the amount of storage size required for this attribute. + virtual hsize_t getStorageSize() const; + // Reads data from this attribute. void read( const DataType& mem_type, void *buf ) const; void read( const DataType& mem_type, string& strg ) const; @@ -44,10 +47,11 @@ class H5_DLLCPP Attribute : public AbstractDs { // Copy constructor: makes a copy of an existing Attribute object. Attribute( const Attribute& original ); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Used by the API to appropriately close an attribute - virtual void p_close() const; -#endif // DOXYGEN_SHOULD_SKIP_THIS + // Default constructor + Attribute(); + + // Close this attribute. + virtual void close(); // Destructor: properly terminates access to this attribute. virtual ~Attribute(); @@ -59,11 +63,11 @@ class H5_DLLCPP Attribute : public AbstractDs { // sub-types virtual hid_t p_get_type() const; - // do not inherit iterateAttrs from H5Object + // do not inherit 'iterateAttrs' from H5Object int iterateAttrs() { return 0; } - // Default constructor - Attribute(); + // do not inherit 'rename' from H5Object + void rename() {} }; #ifndef H5_NO_NAMESPACE } diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 05da7bd..ba7cd9c 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -756,6 +756,40 @@ hsize_t CommonFG::getNumObjs() const //-------------------------------------------------------------------------- // Function: CommonFG::getObjnameByIdx +///\brief Returns the name of an object in this group, given the +/// object's index. +///\param idx - IN: Transient index of the object +///\return Object name +///\exception H5::FileIException or H5::GroupIException +///\par Description +/// The value of idx can be any nonnegative number less than the +/// total number of objects in the group, which is returned by +/// the function \c CommonFG::getNumObjs. Note that this is a +/// transient index; thus, an object may have a different index +/// each time the group is opened. +// Programmer Binh-Minh Ribler - Mar, 2005 +//-------------------------------------------------------------------------- +string CommonFG::getObjnameByIdx(hsize_t idx) const +{ + // call H5Gget_objname_by_idx with name as NULL to get its length + ssize_t name_len = H5Gget_objname_by_idx(getLocId(), idx, NULL, 0); + if(name_len < 0) + { + throwException("getObjnameByIdx", "H5Gget_objname_by_idx failed"); + } + + // now, allocate C buffer to get the name + char* name_C = new char[name_len]; + name_len = H5Gget_objname_by_idx(getLocId(), idx, name_C, name_len); + + // clean up and return the string + string name = string(name_C); + delete [] name_C; + return (name); +} + +//-------------------------------------------------------------------------- +// Function: CommonFG::getObjnameByIdx ///\brief Retrieves the name of an object in this group, given the /// object's index. ///\param idx - IN: Transient index of the object diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 1ede66b..075aca2 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -69,6 +69,7 @@ class H5_DLLCPP CommonFG { // Retrieves the name of an object in this group, given the // object's index. ssize_t getObjnameByIdx(hsize_t idx, string& name, size_t size) const; + string getObjnameByIdx(hsize_t idx) const; // Returns the type of an object in this group, given the // object's index. diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 2967183..a37a2a7 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -116,22 +116,18 @@ DSetCreatPropList DataSet::getCreatePlist() const } //-------------------------------------------------------------------------- -// Function: DataSet::getStorageSize -///\brief Returns the amount of storage required for a dataset. -///\return Amount of storage -///\exception H5::DataSetIException -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::getStorageSize +///\brief Returns the amount of storage required for a dataset. +///\return Size of the storage or 0, for no data +///\exception H5::DataSetIException +// Note: H5Dget_storage_size returns 0 when there is no data. This +// function should have no failure. (from SLU) +// Programmer Binh-Minh Ribler - Mar, 2005 //-------------------------------------------------------------------------- hsize_t DataSet::getStorageSize() const { - hsize_t storage_size = H5Dget_storage_size( id ); - - if( storage_size > 0 ) // checking with Quincey for failure value - BMR - return( storage_size ); - else - { - throw DataSetIException("DataSet::getStorageSize", "H5Dget_storage_size failed"); - } + hsize_t storage_size = H5Dget_storage_size(id); + return(storage_size); } //-------------------------------------------------------------------------- @@ -478,33 +474,30 @@ DataSpace DataSet::getRegion(void *ref, H5R_type_t ref_type) const return(dataspace); } -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataSet::p_close (private) -// Purpose: Closes this dataset. -// Exception H5::DataSetIException -// Description -// This function will be obsolete because its functionality -// is recently handled by the C library layer. - May, 2004 -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSet::close +///\brief Closes this dataset. +///\exception H5::DataSetIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSet::p_close() const +void DataSet::close() { herr_t ret_value = H5Dclose( id ); if( ret_value < 0 ) { - throw DataSetIException(0, "H5Dclose failed"); + throw DataSetIException("DataSet::close", "H5Dclose failed"); } + // reset the id because the group that it represents is now closed + id = 0; } -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataSet destructor ///\brief Properly terminates access to this dataset. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- DataSet::~DataSet() { diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index 03e6567..7255e17 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -44,8 +44,8 @@ class H5_DLLCPP DataSet : public AbstractDs { // Determines whether space has been allocated for a dataset. void getSpaceStatus(H5D_space_status_t& status) const; - // Gets the storage size of this dataset. - hsize_t getStorageSize() const; + // Returns the amount of storage size required for this dataset. + virtual hsize_t getStorageSize() const; // not yet implemented?? hsize_t getVlenBufSize( DataType& type, DataSpace& space ) const; @@ -82,10 +82,8 @@ class H5_DLLCPP DataSet : public AbstractDs { // Creates a copy of an existing DataSet using its id. DataSet(const hid_t existing_id); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Used by the API to appropriately close a dataset. - virtual void p_close() const; -#endif // DOXYGEN_SHOULD_SKIP_THIS + // Close this dataset. + virtual void close(); // Default constructor. DataSet(); diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index d13deed..74ea525 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -94,8 +94,8 @@ DataSpace::DataSpace( const DataSpace& original ) : IdComponent( original ) {} ///\exception H5::DataSpaceIException // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- void DataSpace::copy( const DataSpace& like_space ) { @@ -537,37 +537,35 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h } } -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataSpace::p_close (private) -// Purpose: Closes the dataspace if it is not a constant. -// Exception H5::DataSpaceIException -// Description -// This function will be obsolete because its functionality -// is recently handled by the C library layer. - May, 2004 -// Programmer Binh-Minh Ribler - 2000 +// Function: DataSpace::close +///\brief Closes this dataspace. +///\exception H5::DataSpaceIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataSpace::p_close() const +void DataSpace::close() { - hid_t space_id = id; - if( space_id != H5S_ALL ) // not a constant, should call H5Sclose + if( id != H5S_ALL ) // not a constant, should call H5Sclose { - herr_t ret_value = H5Sclose( space_id ); + herr_t ret_value = H5Sclose(id); if( ret_value < 0 ) { - throw DataSpaceIException(0, "H5Sclose failed"); + throw DataSpaceIException("DataSpace::close", "H5Sclose failed"); } + // reset the id because the dataspace that it represents is now closed + id = 0; } + else // cannot close a constant + throw DataSpaceIException("DataSpace::close", "Cannot close a constant"); } -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataSpace destructor ///\brief Properly terminates access to this dataspace. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- DataSpace::~DataSpace() { @@ -578,7 +576,7 @@ DataSpace::~DataSpace() decRefCount(); } catch (Exception close_error) { - throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); + cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; } } // if } diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index a07289b..201332f 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -105,10 +105,8 @@ class H5_DLLCPP DataSpace : public IdComponent { // Copy constructor: makes a copy of the original DataSpace object. DataSpace(const DataSpace& original); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Used by the API to close the dataspace - void p_close() const; -#endif // DOXYGEN_SHOULD_SKIP_THIS + // Close this dataspace. + virtual void close(); // Destructor: properly terminates access to this dataspace. virtual ~DataSpace(); diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 3a26990..a5c9a92 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -95,8 +95,8 @@ DataType::DataType(const DataType& original) : H5Object(original) ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- void DataType::copy( const DataType& like_type ) { @@ -615,37 +615,36 @@ DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const return(dataspace); } -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: DataType::p_close (private) -// Purpose: Closes the datatype if it is not a predefined type. -// Exception H5::DataTypeIException -// Description -// This function will be obsolete because its functionality -// is recently handled by the C library layer. - May, 2004 -// Programmer Binh-Minh Ribler - 2000 +// Function: DataType::close +///\brief Closes the datatype if it is not a predefined type. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void DataType::p_close() const +void DataType::close() { // If this datatype is not a predefined type, call H5Tclose on it. if( is_predtype == false ) { - herr_t ret_value = H5Tclose( id ); + herr_t ret_value = H5Tclose(id); if( ret_value < 0 ) { - throw DataTypeIException(0, "H5Tclose failed"); + throw DataTypeIException("DataType::close", "H5Tclose failed"); } + // reset the id because the datatype that it represents is now closed + id = 0; } + else // cannot close a predefined type + throw DataTypeIException("DataType::close", "Cannot close a predefined type"); } -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: DataType destructor ///\brief Properly terminates access to this datatype. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- DataType::~DataType() { diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index df3ca59..00a2bff 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -28,6 +28,9 @@ class H5_DLLCPP DataType : public H5Object { // Copy constructor: makes a copy of the original object DataType( const DataType& original ); + // Closes this datatype. + virtual void close(); + // Copies an existing datatype to this datatype object void copy( const DataType& like_type ); @@ -112,11 +115,6 @@ class H5_DLLCPP DataType : public H5Object { // Default constructor DataType(); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Used by the API to appropriately close a datatype - void p_close() const; -#endif // DOXYGEN_SHOULD_SKIP_THIS - // Destructor: properly terminates access to this datatype. virtual ~DataType(); diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 670bfbe..e3b752c 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -184,8 +184,8 @@ bool H5File::isHdf5(const string& name ) // Note: This wrapper doesn't seem right regarding the 'id' and should // be investigated. BMR - 2/20/2005 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- void H5File::reOpen() { @@ -531,25 +531,22 @@ hid_t H5File::getLocId() const return( getId() ); } -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5File::p_close (private) -// Purpose: Closes this HDF5 file. -// Exception H5::FileIException -// Description -// This function will be obsolete because its functionality -// is recently handled by the C library layer. - May, 2004 -// Programmer Binh-Minh Ribler - 2000 +// Function: H5File::close +///\brief Closes this HDF5 file. +///\exception H5::FileIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void H5File::p_close() const +void H5File::close() { herr_t ret_value = H5Fclose( id ); if( ret_value < 0 ) { - throw FileIException(0, "H5Fclose failed"); + throw FileIException("H5File::close", "H5Fclose failed"); } + // reset the id because the file that it represents is now closed + id = 0; } -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: H5File::throwException @@ -577,8 +574,8 @@ void H5File::throwException(const string func_name, const string msg) const ///\brief Properly terminates access to this file. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- H5File::~H5File() { diff --git a/c++/src/H5File.h b/c++/src/H5File.h index d272fa6..303c136 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -30,6 +30,9 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG { const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, const FileAccPropList& access_plist = FileAccPropList::DEFAULT ); + // Close this file. + virtual void close(); + // Gets the access property list of this file. FileAccPropList getAccessPlist() const; @@ -91,11 +94,6 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG { // Copy constructor: makes a copy of the original H5File object. H5File(const H5File& original); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Used by the API to appropriately close a file. - void p_close() const; -#endif // DOXYGEN_SHOULD_SKIP_THIS - // H5File destructor. virtual ~H5File(); diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 2774f13..97ecdec 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -141,25 +141,22 @@ DataSpace Group::getRegion(void *ref, H5R_type_t ref_type) const return(dataspace); } -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: Group::p_close (private) -// Purpose: Closes this group. -// Exception H5::GroupIException -// Description -// This function will be obsolete because its functionality -// is recently handled by the C library layer. - May, 2004 -// Programmer Binh-Minh Ribler - 2000 +// Function: Group::close +///\brief Closes this group. +///\exception H5::GroupIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void Group::p_close() const +void Group::close() { herr_t ret_value = H5Gclose( id ); if( ret_value < 0 ) { - throw GroupIException(0, "H5Gclose failed"); + throw GroupIException("Group::close", "H5Gclose failed"); } + // reset the id because the group that it represents is now closed + id = 0; } -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: Group::throwException @@ -187,8 +184,8 @@ void Group::throwException(const string func_name, const string msg) const ///\brief Properly terminates access to this group. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- Group::~Group() { diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 654af18..6778b20 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -22,6 +22,9 @@ namespace H5 { class H5_DLLCPP Group : public H5Object, public CommonFG { public: + // Close this group. + virtual void close(); + // Retrieves the type of object that an object reference points to. H5G_obj_t getObjType(void *ref, H5R_type_t ref_type) const; @@ -47,11 +50,6 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { // Copy constructor: makes a copy of the original object Group(const Group& original); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Used by the API to appropriately close a group - will be obsolete. - void p_close() const; -#endif // DOXYGEN_SHOULD_SKIP_THIS - // Destructor virtual ~Group(); diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 154da46..f5cc25e 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -41,8 +41,6 @@ class H5_DLLCPP IdComponent { // Assignment operator IdComponent& operator=( const IdComponent& rhs ); - void reset(); - // Sets the identifier of this object to a new value. void setId( hid_t new_id ); @@ -55,12 +53,10 @@ class H5_DLLCPP IdComponent { // Gets the value of IdComponent's data member. virtual hid_t getId () const; - // Pure virtual function so appropriate close function can - // be called by subclasses' for the corresponding object - // This function will be obsolete because its functionality - // is recently handled by the C library layer. #ifndef DOXYGEN_SHOULD_SKIP_THIS - virtual void p_close() const = 0; + // Pure virtual function for there are various H5*close for the + // subclasses. + virtual void close() = 0; #endif // DOXYGEN_SHOULD_SKIP_THIS // Destructor diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 9c8f5f4..a4c3071 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -269,6 +269,35 @@ void H5Object::removeAttr( const string& name ) const } //-------------------------------------------------------------------------- +// 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(id, oldname, newname); + if (ret_value < 0) + { + throw AttributeIException("H5Object::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 std::string for the names. +// Programmer Binh-Minh Ribler - Mar, 2005 +//-------------------------------------------------------------------------- +void H5Object::renameAttr(const string& oldname, const 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, diff --git a/c++/src/H5Object.h b/c++/src/H5Object.h index fdc6c76..6b0d0fd 100644 --- a/c++/src/H5Object.h +++ b/c++/src/H5Object.h @@ -76,6 +76,10 @@ class H5_DLLCPP H5Object : public IdComponent { void removeAttr( const char* name ) const; void removeAttr( const string& name ) const; + // Renames the attribute to a new name. + void renameAttr(const char* oldname, const char* newname) const; + void renameAttr(const string& oldname, const string& newname) const; + // Copy constructor: makes copy of an H5Object object. H5Object(const H5Object& original); diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 2564c3f..aabcf83 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -87,8 +87,8 @@ PropList::PropList( const hid_t plist_id ) : IdComponent(0) ///\exception H5::PropListIException // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- void PropList::copy( const PropList& like_plist ) { @@ -162,28 +162,27 @@ void PropList::copyProp( PropList& dest, PropList& src, const string& name ) con copyProp( dest, src, name.c_str()); } -#ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: PropList::p_close (private) -// Purpose: Closes the property list if it is not a default one. -// Exception H5::PropListIException -// Description -// This function will be obsolete because its functionality -// is recently handled by the C library layer. - May, 2004 -// Programmer Binh-Minh Ribler - 2000 +// Function: PropList::close +///\brief Closes the property list if it is not a default one. +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - Mar 9, 2005 //-------------------------------------------------------------------------- -void PropList::p_close() const +void PropList::close() { if( id != H5P_NO_CLASS ) // not a constant, should call H5Pclose { herr_t ret_value = H5Pclose( id ); if( ret_value < 0 ) { - throw PropListIException(0, "property list close failed" ); + throw PropListIException("PropList::close", "H5Pclose failed"); } + // reset the id because the property list that it represents is now closed + id = 0; } + else + throw PropListIException("PropList::close", "Cannot close a constant"); } -#endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // Function: PropList::getClass @@ -582,8 +581,8 @@ PropList PropList::getClassParent() const ///\brief Properly terminates access to this property list. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use new ID -// reference counting mechanisms by QAK, Feb 20, 2005 +// Replaced resetIdComponent with decRefCount to use C library +// ID reference counting mechanism - BMR, Feb 20, 2005 //-------------------------------------------------------------------------- PropList::~PropList() { diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index b8fa735..4727085 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -35,6 +35,9 @@ class H5_DLLCPP PropList : public IdComponent { // Compares this property list or class against the given list or class. bool operator==(const PropList& rhs) const; + // Close this property list. + virtual void close(); + // Close a property list class. void closeClass() const; @@ -92,11 +95,6 @@ class H5_DLLCPP PropList : public IdComponent { // Copy constructor: creates a copy of a PropList object. PropList(const PropList& original); -#ifndef DOXYGEN_SHOULD_SKIP_THIS - // Used by the API to close the property list. - void p_close() const; -#endif // DOXYGEN_SHOULD_SKIP_THIS - // Destructor: properly terminates access to this property list. virtual ~PropList(); }; |