diff options
Diffstat (limited to 'c++/src')
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 12 | ||||
-rw-r--r-- | c++/src/H5AbstractDs.h | 4 | ||||
-rw-r--r-- | c++/src/H5Attribute.h | 2 | ||||
-rw-r--r-- | c++/src/H5CppDoc.h | 8 | ||||
-rw-r--r-- | c++/src/H5DataSet.cpp | 26 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 7 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 3 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5DxferProp.h | 4 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 6 | ||||
-rw-r--r-- | c++/src/H5Exception.h | 4 | ||||
-rw-r--r-- | c++/src/H5FaccProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 84 | ||||
-rw-r--r-- | c++/src/H5FloatType.h | 8 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 36 | ||||
-rw-r--r-- | c++/src/H5IdComponent.h | 36 | ||||
-rw-r--r-- | c++/src/H5Library.cpp | 72 | ||||
-rw-r--r-- | c++/src/H5Library.h | 10 | ||||
-rw-r--r-- | c++/src/H5Location.h | 3 | ||||
-rw-r--r-- | c++/src/H5PropList.h | 3 |
20 files changed, 170 insertions, 164 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 5929444..06b3e22 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -52,18 +52,6 @@ AbstractDs::AbstractDs(){} AbstractDs::AbstractDs(const hid_t ds_id){} //-------------------------------------------------------------------------- -// Function: AbstractDs copy constructor -///\brief Copy constructor: makes a copy of the original AbstractDs object. -// Programmer Binh-Minh Ribler - 2000 -// *** Deprecation warning *** -// This constructor is no longer appropriate because the data member "id" had -// been moved to the sub-classes. It is removed from 1.8.15 because it is -// a noop and it can be generated by the compiler if needed. -//-------------------------------------------------------------------------- -//-------------------------------------------------------------------------- -// AbstractDs::AbstractDs(const AbstractDs& original){} - -//-------------------------------------------------------------------------- // Function: AbstractDs::getTypeClass ///\brief Returns the class of the datatype that is used by this /// object, which can be a dataset or an attribute. diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 810dc8b..ee2e45e 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -68,7 +68,7 @@ class H5_DLLCPP AbstractDs { ///\brief Returns the amount of storage size required - pure virtual. virtual hsize_t getStorageSize() const = 0; - ///\brief Returns this class name. + // Returns this class name - pure virtual. virtual H5std_string fromClass() const = 0; // Destructor @@ -91,7 +91,7 @@ class H5_DLLCPP AbstractDs { // AbstractDs( const AbstractDs& original ); private: - // This member function is implemented by DataSet and Attribute. + // This member function is implemented by DataSet and Attribute - pure virtual. virtual hid_t p_get_type() const = 0; }; #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index eced64e..f5ee4a9 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -86,8 +86,8 @@ class H5_DLLCPP Attribute : public AbstractDs, public IdComponent { // Destructor: properly terminates access to this attribute. virtual ~Attribute(); - protected: #ifndef DOXYGEN_SHOULD_SKIP_THIS + protected: // Sets the attribute id. virtual void p_setId(const hid_t new_id); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5CppDoc.h b/c++/src/H5CppDoc.h index 388fc25..2420586 100644 --- a/c++/src/H5CppDoc.h +++ b/c++/src/H5CppDoc.h @@ -29,10 +29,10 @@ * The C++ API provides C++ wrappers for the HDF5 C Library. * * It is assumed that the user has knowledge of the - * <a href="http://www.hdfgroup.org/HDF5/doc/H5.format.html"> + * <a href="https://www.hdfgroup.org/HDF5/doc/H5.format.html"> * HDF5 file format</a> and its components. * For more information on the HDF5 C Library, see the - * <a href="http://www.hdfgroup.org/HDF5/doc/index.html"> + * <a href="https://www.hdfgroup.org/HDF5/doc/index.html"> * HDF5 Software Documentation</a> page. * * Because the HDF5 C Library maps very well to @@ -57,8 +57,8 @@ * * The HDF5 C++ API is included with the HDF5 source code and can * be obtained from - * <a href="http://www.hdfgroup.org/HDF5/release/obtainsrc.html"> - * http://www.hdfgroup.org/HDF5/release/obtainsrc.html</a>. + * <a href="https://www.hdfgroup.org/HDF5/release/obtainsrc.html"> + * https://www.hdfgroup.org/HDF5/release/obtainsrc.html</a>. * * Please refer to the release_docs/INSTALL file under the top directory * of the HDF5 source code for information about installing, building, diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 0fc9105..059da85 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -60,6 +60,12 @@ DataSet::DataSet() : H5Object(), AbstractDs(), id(H5I_INVALID_HID) {} ///\brief Creates an DataSet object using the id of an existing dataset. ///\param existing_id - IN: Id of an existing dataset // Programmer Binh-Minh Ribler - 2000 +// Description +// incRefCount() is needed here to prevent the id from being closed +// prematurely. That is, when application uses the id of an +// existing DataSet object to create another DataSet object. So, +// when one of those objects is deleted, the id will be closed if +// the reference counter is only 1. //-------------------------------------------------------------------------- DataSet::DataSet(const hid_t existing_id) : H5Object(), AbstractDs() { @@ -172,8 +178,10 @@ DSetCreatPropList DataSet::getCreatePlist() const { throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed"); } + // create and return the DSetCreatPropList object - DSetCreatPropList create_plist(create_plist_id); // ok to use existing id const + DSetCreatPropList create_plist; + f_PropList_setId(&create_plist, create_plist_id); return(create_plist); } @@ -772,6 +780,22 @@ void DataSet::p_setId(const hid_t new_id) // reset object's id to the given id id = new_id; } + +//-------------------------------------------------------------------------- +// Function: f_PropList_setId - friend +// Purpose: This function is friend to class H5::PropList so that it +// can set PropList::id in order to work around a problem +// described in the JIRA issue HDFFV-7947. +// Applications shouldn't need to use it. +// param dset - IN/OUT: DataSet object to be changed +// param new_id - IN: New id to set +// Programmer Binh-Minh Ribler - 2015 +//-------------------------------------------------------------------------- +void f_PropList_setId(PropList* plist, hid_t new_id) +{ + plist->p_setId(new_id); +} + #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 88dff89..1bbabe3 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -144,10 +144,10 @@ DataType::DataType(const DataType& original) : H5Object() //-------------------------------------------------------------------------- // Function: DataType overloaded constructor -///\brief Creates a integer type using a predefined type +///\brief Creates a DataType instance using a predefined type ///\param pred_type - IN: Predefined datatype ///\exception H5::DataTypeIException -// Programmer Binh-Minh Ribler - 2000 +// Programmer Binh-Minh Ribler - 2015 // Description // Copying the type so that when a predefined type is passed in, // a copy of it is made, not just a duplicate of the HDF5 id. @@ -239,8 +239,7 @@ DataType& DataType::operator=( const DataType& rhs ) { if (this != &rhs) { - id = rhs.id; - incRefCount(); // increment number of references to this id + setId(rhs.id); } return(*this); } diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 6c8a312..5705b83 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class DataType inherits from H5Object and has several subclasses for +// specific HDF5 data types. + #ifndef __H5DataType_H #define __H5DataType_H diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index ebdadc4..792956a 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class DSetCreatPropList represents the HDF5 dataset creation property list +// and inherits from PropList. + #ifndef __H5DSCreatPropList_H #define __H5DSCreatPropList_H diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 85d2ec2..52a9a48 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class DSetMemXferPropList represents the HDF5 dataset transfer property list +// and inherits from PropList. + #ifndef __H5DSetMemXferPropList_H #define __H5DSetMemXferPropList_H @@ -132,4 +135,3 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { } #endif #endif // __H5DSetMemXferPropList_H - diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index fb1e42e..1ca059b 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -309,9 +309,9 @@ const char* Exception::getCFuncName() const //-------------------------------------------------------------------------- void Exception::printErrorStack(FILE* stream, hid_t err_stack) { - herr_t ret_value = H5Eprint2(err_stack, stream); - if( ret_value < 0 ) - throw Exception( "Printing error stack", "H5Eprint2 failed" ); + herr_t ret_value = H5Eprint2(err_stack, stream); + if( ret_value < 0 ) + throw Exception( "Printing error stack", "H5Eprint2 failed" ); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 639b633..d49c19a 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -86,8 +86,8 @@ class H5_DLLCPP Exception { virtual ~Exception() throw(); protected: - // Default value for detail_message - static const char DEFAULT_MSG[]; + // Default value for detail_message + static const char DEFAULT_MSG[]; private: H5std_string detail_message; diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 7d6529e..b214447 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -14,6 +14,9 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +// Class FileAccPropList represents the HDF5 file access property list and +// inherits from DataType. + #ifndef __H5FileAccPropList_H #define __H5FileAccPropList_H diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 44fc53c..b169472 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -133,28 +133,26 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro // create the file. if( flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)) { - hid_t create_plist_id = create_plist.getId(); - hid_t access_plist_id = access_plist.getId(); - id = H5Fcreate( name, flags, create_plist_id, access_plist_id ); - if( id < 0 ) // throw an exception when open/create fail - { - throw FileIException("H5File constructor", "H5Fcreate failed"); - } + hid_t create_plist_id = create_plist.getId(); + hid_t access_plist_id = access_plist.getId(); + id = H5Fcreate( name, flags, create_plist_id, access_plist_id ); + if( id < 0 ) // throw an exception when open/create fail + { + throw FileIException("H5File constructor", "H5Fcreate failed"); + } } // Open the file if none of the bits above are set. else { - hid_t access_plist_id = access_plist.getId(); - id = H5Fopen( name, flags, access_plist_id ); - if( id < 0 ) // throw an exception when open/create fail - { - throw FileIException("H5File constructor", "H5Fopen failed"); - } + hid_t access_plist_id = access_plist.getId(); + id = H5Fopen( name, flags, access_plist_id ); + if( id < 0 ) // throw an exception when open/create fail + { + throw FileIException("H5File constructor", "H5Fopen failed"); + } } } -#endif // DOXYGEN_SHOULD_SKIP_THIS - //-------------------------------------------------------------------------- // Function: H5File overloaded constructor ///\brief Creates an H5File object using an existing file id. @@ -174,6 +172,8 @@ H5File::H5File(hid_t existing_id) : H5Location(), CommonFG() incRefCount(); // increment number of references to this id } +#endif // DOXYGEN_SHOULD_SKIP_THIS + //-------------------------------------------------------------------------- // Function: H5File copy constructor ///\brief Copy constructor: makes a copy of the original @@ -523,16 +523,16 @@ hsize_t H5File::getFileSize() const } //-------------------------------------------------------------------------- -// Function: H5File::getId +// Function: H5File::getId ///\brief Get the id of this file ///\return File identifier // Modification: -// May 2008 - BMR -// Class hierarchy is revised to address bugzilla 1068. Class -// AbstractDS and Attribute are moved out of H5Object. In -// addition, member IdComponent::id is moved into subclasses, and -// IdComponent::getId now becomes pure virtual function. -// Programmer Binh-Minh Ribler - May, 2008 +// May 2008 - BMR +// Class hierarchy is revised to address bugzilla 1068. Class +// AbstractDS and Attribute are moved out of H5Object. In +// addition, member IdComponent::id is moved into subclasses, and +// IdComponent::getId now becomes pure virtual function. +// Programmer Binh-Minh Ribler - May, 2008 //-------------------------------------------------------------------------- hid_t H5File::getId() const { @@ -541,42 +541,42 @@ hid_t H5File::getId() const #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5File::getLocId -// Purpose: Get the id of this file +// Function: H5File::reopen +// Purpose: Reopens this file. +// Exception H5::FileIException // Description -// This function is a redefinition of CommonFG::getLocId. It -// is used by CommonFG member functions to get the file id. +// This function is replaced by the above function reOpen. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -hid_t H5File::getLocId() const +void H5File::reopen() { - return( getId() ); + H5File::reOpen(); } //-------------------------------------------------------------------------- -// Function: H5File::reopen -// Purpose: Reopens this file. -// Exception H5::FileIException +// Function: H5File::getLocId +// Purpose: Get the id of this file // Description -// This function is replaced by the above function reOpen. +// This function is a redefinition of CommonFG::getLocId. It +// is used by CommonFG member functions to get the file id. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void H5File::reopen() +hid_t H5File::getLocId() const { - H5File::reOpen(); + return( getId() ); } //-------------------------------------------------------------------------- -// Function: H5File::p_setId (protected) -///\brief Sets the identifier of this object to a new value. +// 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 -/// object fails +///\exception H5::IdComponentException when the attempt to close the HDF5 +/// object fails // Description: -// The underlaying reference counting in the C library ensures -// that the current valid id of this object is properly closed. -// Then the object's id is reset to the new id. -// Programmer Binh-Minh Ribler - 2000 +// The underlaying reference counting in the C library ensures +// that the current valid id of this object is properly closed. +// Then the object's id is reset to the new id. +// Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void H5File::p_setId(const hid_t new_id) { diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index 06a5450..e88093e 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -24,10 +24,10 @@ namespace H5 { //! Class FloatType operates on HDF5 floating point datatype. class H5_DLLCPP FloatType : public AtomType { public: - // Creates a floating-point type using a predefined type - FloatType( const PredType& pred_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. @@ -60,7 +60,7 @@ class H5_DLLCPP FloatType : public AtomType { // 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. diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 93ee4fd..60735f0 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -26,14 +26,19 @@ namespace H5 { #endif -// This flag controls whether H5Library::initH5cpp has been called to register -// terminating functions with atexit() +// This flag indicates whether H5Library::initH5cpp has been called to register +// the terminating functions with atexit() bool IdComponent::H5cppinit = false; + +// This flag is used to decide whether H5dont_atexit should be called. +// Subclasses that have global constants use it. This is a temporary +// work-around in 1.8.16. It will be removed after HDFFV-9540 is fixed. bool IdComponent::H5dontAtexit_called = false; //-------------------------------------------------------------------------- // Function: IdComponent overloaded constructor -// Purpose Creates an IdComponent object using the id of an existing object. +///\brief Creates an IdComponent object using the id of an existing +/// object. - Obsolete, will be removed in 1.8.17 // Param h5_id - IN: Id of an existing object // Exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 @@ -43,25 +48,10 @@ bool IdComponent::H5dontAtexit_called = false; // been moved to the sub-classes. It will be removed in 1.10 release. If its // removal does not raise any problems in 1.10, it will be removed from 1.8 in // subsequent releases. -// - Removed from documentation in 1.8.16 -BMR (October 2015) //-------------------------------------------------------------------------- IdComponent::IdComponent(const hid_t h5_id) {} //-------------------------------------------------------------------------- -// Function: IdComponent copy constructor -// Purpose: This noop copy constructor is removed as a result of the data -// member "id" being moved down to sub-classes. (Mar 2015) -// Parameters: original - IN: IdComponent instance to copy -// Programmer Binh-Minh Ribler - 2000 -// -// *** Deprecation warning *** -// This constructor is no longer appropriate because the data member "id" had -// been moved to the sub-classes. It is removed from 1.8.15 because it is -// a noop and it can be generated by the compiler if needed. -//-------------------------------------------------------------------------- -// IdComponent::IdComponent(const IdComponent& original) {} - -//-------------------------------------------------------------------------- // Function: IdComponent::incRefCount ///\brief Increment reference counter for a given id. // Programmer Binh-Minh Ribler - May 2005 @@ -227,7 +217,7 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs ) //-------------------------------------------------------------------------- // Function: IdComponent::setId ///\brief Sets the identifier of this object to a new value. -/// +///\param new_id - IN: New identifier to be set to ///\exception H5::IdComponentException when the attempt to close the HDF5 /// object fails // Description: @@ -242,8 +232,8 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs ) // C++ API object, which will be destroyed properly, and so // p_setId does not call incRefCount. On the other hand, the // public version setId is used by other applications, in which -// the id passed to setId already has a reference count, so setId -// must call incRefCount. +// the id passed to setId is that of another C++ API object, so +// setId must call incRefCount. //-------------------------------------------------------------------------- void IdComponent::setId(const hid_t new_id) { @@ -295,10 +285,10 @@ H5std_string IdComponent::inMemFunc(const char* func_name) const IdComponent::IdComponent() { // initH5cpp will register the terminating functions with atexit(). - // We only do this once. + // This should only be done once. if (!H5cppinit) { - H5Library::getInstance()->initH5cpp(); + H5Library::initH5cpp(); H5cppinit = true; } } diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 1c29f09..61c8bd6 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -17,6 +17,8 @@ #ifndef __IdComponent_H #define __IdComponent_H +// IdComponent represents an HDF5 object that has an identifier. + #ifndef H5_NO_NAMESPACE namespace H5 { #endif @@ -30,12 +32,7 @@ class DataSpace; rarely needs them. */ class H5_DLLCPP IdComponent { - public: - -#ifndef DOXYGEN_SHOULD_SKIP_THIS - static bool H5cppinit; - static bool H5dontAtexit_called; -#endif // DOXYGEN_SHOULD_SKIP_THIS + public: // Increment reference counter. void incRefCount(const hid_t obj_id) const; @@ -58,11 +55,6 @@ 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); @@ -76,10 +68,14 @@ class H5_DLLCPP IdComponent { // Creates an object to hold an HDF5 identifier. IdComponent( const hid_t h5_id ); +#ifndef DOXYGEN_SHOULD_SKIP_THIS + // Copy constructor: makes copy of the original IdComponent object. - // IdComponent( const IdComponent& original ); + // IdComponent( const IdComponent& original ); - removed from 1.8.15 + + // Gets the identifier of this object. + virtual hid_t getId () const = 0; -#ifndef DOXYGEN_SHOULD_SKIP_THIS // Pure virtual function for there are various H5*close for the // subclasses. virtual void close() = 0; @@ -96,11 +92,12 @@ class H5_DLLCPP IdComponent { // Destructor virtual ~IdComponent(); - protected: +#ifndef DOXYGEN_SHOULD_SKIP_THIS + + protected: // Default constructor. IdComponent(); -#ifndef DOXYGEN_SHOULD_SKIP_THIS // Gets the name of the file, in which an HDF5 object belongs. H5std_string p_get_file_name() const; @@ -110,7 +107,14 @@ class H5_DLLCPP IdComponent { // Sets the identifier of this object to a new value. - this one // doesn't increment reference count virtual void p_setId(const hid_t new_id) = 0; - //virtual void p_setId(const hid_t new_id); + + // This flag is used to decide whether H5dont_atexit should be called + static bool H5dontAtexit_called; + + private: + // This flag indicates whether H5Library::initH5cpp has been called + // to register various terminating functions with atexit() + static bool H5cppinit; #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index e7e9fb6..40c766a 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -38,11 +38,14 @@ namespace H5 { #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS -H5Library* H5Library::instance = 0; + +// This static variable is unused, will be removed in future releases. +bool H5Library::need_cleanup = false; + #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- -// Function: H5Library::open +// Function: H5Library::open (static) ///\brief Initializes the HDF5 library. /// ///\exception H5::LibraryIException @@ -58,7 +61,7 @@ void H5Library::open() } //-------------------------------------------------------------------------- -// Function: H5Library::close +// Function: H5Library::close (static) ///\brief Flushes all data to disk, closes files, and cleans up memory. /// ///\exception H5::LibraryIException @@ -74,7 +77,7 @@ void H5Library::close() } //-------------------------------------------------------------------------- -// Function: H5Library::dontAtExit +// Function: H5Library::dontAtExit (static) ///\brief Instructs library not to install the C \c atexit cleanup routine /// ///\exception H5::LibraryIException @@ -89,7 +92,7 @@ void H5Library::dontAtExit() } //-------------------------------------------------------------------------- -// Function: H5Library::getLibVersion +// Function: H5Library::getLibVersion (static) ///\brief Returns the HDF library release number. ///\param majnum - OUT: Major version of the library ///\param minnum - OUT: Minor version of the library @@ -107,7 +110,7 @@ void H5Library::getLibVersion( unsigned& majnum, unsigned& minnum, unsigned& rel } //-------------------------------------------------------------------------- -// Function: H5Library::checkVersion +// Function: H5Library::checkVersion (static) ///\brief Verifies that the arguments match the version numbers /// compiled into the library ///\param majnum - IN: Major version of the library @@ -130,7 +133,7 @@ void H5Library::checkVersion(unsigned majnum, unsigned minnum, unsigned relnum) } //-------------------------------------------------------------------------- -// Function: H5Library::garbageCollect +// Function: H5Library::garbageCollect (static) ///\brief Walks through all the garbage collection routines for the /// library, which are supposed to free any unused memory they /// have allocated. @@ -159,7 +162,7 @@ void H5Library::garbageCollect() } //-------------------------------------------------------------------------- -// Function: H5Library::initH5cpp +// Function: H5Library::initH5cpp (static) ///\brief Initializes C++ library and registers terminating functions at /// exit. Only for the library functions, not for user-defined /// functions. @@ -167,52 +170,56 @@ void H5Library::garbageCollect() // initH5cpp registers the following functions with std::atexit(): // termH5cpp() - calls H5close() after all cleanup in // the C++ library is done -// <classname>::deleteConstants - deletes all references for -// <classname> global constants +// <classname>::deleteConstants - deletes all references +// for <classname> global constants ///\exception H5::LibraryIException // // Programmer Binh-Minh Ribler - September, 2015 //-------------------------------------------------------------------------- void H5Library::initH5cpp() { - // Register terminating functions with atexit(); they will be invoked in the - // reversed order + // Register terminating functions with atexit(); they will be invoked in + // the reversed order int ret_value = 0; ret_value = std::atexit(termH5cpp); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of termH5cpp failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating termH5cpp failed"); ret_value = std::atexit(PredType::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of PredType::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating PredType::deleteConstants failed"); ret_value = std::atexit(PropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of PropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating PropList::deleteConstants failed"); ret_value = std::atexit(FileAccPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of FileAccPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating FileAccPropList::deleteConstants failed"); ret_value = std::atexit(FileCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of FileCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating FileCreatPropList::deleteConstants failed"); ret_value = std::atexit(DSetMemXferPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of DSetMemXferPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating DSetMemXferPropList::deleteConstants failed"); ret_value = std::atexit(DSetCreatPropList::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of DSetCreatPropList::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating DSetCreatPropList::deleteConstants failed"); + + ret_value = std::atexit(ObjCreatPropList::deleteConstants); + if (ret_value != 0) + throw LibraryIException("H5Library::initH5cpp", "Registrating ObjCreatPropList::deleteConstants failed"); ret_value = std::atexit(DataSpace::deleteConstants); if (ret_value != 0) - throw LibraryIException("H5Library::initH5cpp", "Registration of DataSpace::deleteConstants failed"); + throw LibraryIException("H5Library::initH5cpp", "Registrating DataSpace::deleteConstants failed"); } //-------------------------------------------------------------------------- -// Function: H5Library::termH5cpp +// Function: H5Library::termH5cpp (static) ///\brief Sends request for the C layer to terminate. ///\par Description /// If the C library fails to terminate, exit with a failure. @@ -227,24 +234,7 @@ void H5Library::termH5cpp() } //-------------------------------------------------------------------------- -// Function: H5Library::getInstance -///\brief Provides a way to instantiate the class. -///\par Description -/// getInstance ensures that only one instance of the H5Library -/// is created. -// Programmer Binh-Minh Ribler - September, 2015 -//-------------------------------------------------------------------------- -H5Library* H5Library::getInstance() -{ - if (H5Library::instance == 0) - { - instance = new H5Library(); - } - return(instance); -} - -//-------------------------------------------------------------------------- -// Function: H5Library::setFreeListLimits +// Function: H5Library::setFreeListLimits (static) ///\brief Sets limits on the different kinds of free lists. ///\param reg_global_lim - IN: Limit on all "regular" free list memory used ///\param reg_list_lim - IN: Limit on memory used in each "regular" free list @@ -271,10 +261,10 @@ void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim, } } -// Default constructor - no instance ever created by outsiders +// Default constructor - private H5Library::H5Library(){}; -// Destructor +// Destructor - private H5Library::~H5Library(){}; #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 68ab039..336f9c8 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -29,6 +29,11 @@ namespace H5 { */ class H5_DLLCPP H5Library { public: +#ifndef DOXYGEN_SHOULD_SKIP_THIS + static bool need_cleanup; // indicates if H5close should be called + // - unused, will be removed in future releases. +#endif // DOXYGEN_SHOULD_SKIP_THIS + // Initializes the HDF5 library. static void open(); @@ -60,15 +65,10 @@ class H5_DLLCPP H5Library { // Sends request for terminating the HDF5 library. static void termH5cpp(void); - static H5Library* getInstance(); - #ifndef DOXYGEN_SHOULD_SKIP_THIS private: - // private instance to be created by H5Library only - static H5Library* instance; - // Default constructor - no instance ever created from outsiders H5Library(); diff --git a/c++/src/H5Location.h b/c++/src/H5Location.h index 79a8d5c..9e4ec05 100644 --- a/c++/src/H5Location.h +++ b/c++/src/H5Location.h @@ -150,9 +150,6 @@ class H5_DLLCPP H5Location : public IdComponent { // 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; diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index be04451..7f6ee31 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -127,6 +127,9 @@ class H5_DLLCPP PropList : public IdComponent { // Dynamically allocates the PropList global constant static PropList* getConstant(); + // Friend function to set PropList id. For library use only. + friend void f_PropList_setId(PropList* plist, hid_t new_id); + #endif // DOXYGEN_SHOULD_SKIP_THIS }; |