summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2015-10-04 05:05:51 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2015-10-04 05:05:51 (GMT)
commit888a002cddaa4e1d9a165ea01dfe62f399df9eb9 (patch)
tree986735636f94271dff411304d420f95eb92752ed
parent0ef29b550bc30d5798001ac144d1b1228d663919 (diff)
downloadhdf5-888a002cddaa4e1d9a165ea01dfe62f399df9eb9.zip
hdf5-888a002cddaa4e1d9a165ea01dfe62f399df9eb9.tar.gz
hdf5-888a002cddaa4e1d9a165ea01dfe62f399df9eb9.tar.bz2
[svn-r27945] Purpose: Fix HDFFV-9529
Description: Merged from hdf5_CppAPI_Constants r27942: ------ Description: - Added H5dont_atexit() to getPredType and all the getConstant's to prevent the C library from terminating before the C++ library cleanup. - More cleanup and added more comments r27923: ------ - Updated more comments and moved some things around for consistency - Removed check for "new" failure, exceptions would be thrown r27922: ------ Description: Added function headers and more comments for clarity. r27917: ------ Description: The C++ library has several types of global constants from different classes, such as PropList, PredType, DataSpace, etc... Previously, these global constants were declared statically and the C++ library used a constant, called PredType::AtExit, to detect when all the global contants are destroyed then close the C library (H5close). This method relied on the order of the constants being created and destroyed and that PredType constants be the last to be destroyed. In September 2015, it was recognized that the order in which the global constants were created and destroyed was actually undefined, thus can be different between different compilers. This resulted in failure when compilers destroy PredType constants before others because when PredType::AtExit was destroyed, the C library was closed, so when the constants of other classes such as PropList or DataSpace were being deleted, the C library would not be available. Solution: The static approach is changed to dynamic. In order to avoid an impact on existing applications, the static global constants are changed to constant references to the dynamically allocated objects. A detailed explanation of the new method and a description of the changes are in a Design Notes at the end of the file H5PredType.cpp. New functions added to support the new methods are listed below. class H5Library: // Returns a singleton H5Library to initialize the global // constants, invoked in IdComponent default constructor static H5Library* getInstance(); // public // Registers cleanup and terminating functions with atexit(), // called in IdComponent default constructor static void initH5cpp(void); // public // Calls H5close to terminate the library, registered with // atexit(), as the last thing to be done. static void termH5cpp(void); // public class PredType: // Creates the constants static void makePredTypes(); // private // Calls makePredTypes to create the constants and returns // the dummy constant PREDTYPE_CONST; static PredType* getPredTypes(); // private class DataSpace: // Creates the constant static DataSpace* getConstant(); // private class PropList: // Creates the constant static PropList* getConstant(); // private class DSetCreatPropList: // Creates the constant static DSetCreatPropList* getConstant(); // private class DSetMemXferPropList: // Creates the constant static DSetMemXferPropList* getConstant(); // private class FileCreatPropList: // Creates the constant static FileCreatPropList* getConstant(); // private class FileAccPropList: // Creates the constant static FileAccPropList* getConstant(); // private This function is added to PredType, DataSpace, PropList, and the four subclasses of PropList: // Deletes the constant static void deleteConstants(); // public Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
-rw-r--r--c++/src/H5Attribute.cpp1
-rw-r--r--c++/src/H5CommonFG.cpp1
-rw-r--r--c++/src/H5DataSpace.cpp54
-rw-r--r--c++/src/H5DataSpace.h20
-rw-r--r--c++/src/H5DataType.cpp18
-rw-r--r--c++/src/H5DcreatProp.cpp57
-rw-r--r--c++/src/H5DcreatProp.h17
-rw-r--r--c++/src/H5DxferProp.cpp65
-rw-r--r--c++/src/H5DxferProp.h16
-rw-r--r--c++/src/H5FaccProp.cpp57
-rw-r--r--c++/src/H5FaccProp.h17
-rw-r--r--c++/src/H5FcreatProp.cpp55
-rw-r--r--c++/src/H5FcreatProp.h18
-rw-r--r--c++/src/H5IdComponent.cpp33
-rw-r--r--c++/src/H5IdComponent.h6
-rw-r--r--c++/src/H5Library.cpp118
-rw-r--r--c++/src/H5Library.h35
-rw-r--r--c++/src/H5Location.cpp3
-rw-r--r--c++/src/H5PredType.cpp1159
-rw-r--r--c++/src/H5PredType.h505
-rw-r--r--c++/src/H5PropList.cpp54
-rw-r--r--c++/src/H5PropList.h17
22 files changed, 1896 insertions, 430 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 0bfdff8..cb09980 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -45,6 +45,7 @@ namespace H5 {
#endif
class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate
+
//--------------------------------------------------------------------------
// Function: Attribute default constructor
///\brief Default constructor: Creates a stub attribute
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 8ab04f0..5f43533 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -14,7 +14,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string>
-#include <iostream>
#include "H5Include.h"
#include "H5Exception.h"
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index d9c262d..311180f 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -33,10 +33,60 @@ namespace H5 {
#endif // H5_NO_STD
#endif
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
+// the order of creation and deletion of the global constants. See Design Notes
+// in "H5PredType.cpp" for information.
+
+// Initialize a pointer for the constant
+DataSpace* DataSpace::ALL_ = 0;
+
//--------------------------------------------------------------------------
-///\brief Constant for default dataspace.
+// Function: DataSpace::getConstant
+// Creates a DataSpace object representing the HDF5 constant
+// H5S_ALL, pointed to by DataSpace::ALL_
+// Exception H5::DataSpaceIException
+// Description
+// If DataSpace::ALL_ already points to an allocated object, throw
+// a DataSpaceIException. This scenario should not happen.
+// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-const DataSpace DataSpace::ALL( H5S_ALL );
+DataSpace* DataSpace::getConstant()
+{
+ // Tell the C library not to clean up, H5Library::termH5cpp will call
+ // H5close - more dependency if use H5Library::dontAtExit()
+ if (!IdComponent::H5dontAtexit_called)
+ {
+ (void) H5dont_atexit();
+ IdComponent::H5dontAtexit_called = true;
+ }
+
+ // If the constant pointer is not allocated, allocate it. Otherwise,
+ // throw because it shouldn't be.
+ if (ALL_ == 0)
+ ALL_ = new DataSpace(H5S_ALL);
+ else
+ throw DataSpaceIException("DataSpace::getConstant", "DataSpace::getConstant is being invoked on an allocated ALL_");
+ return(ALL_);
+}
+
+//--------------------------------------------------------------------------
+// Function: DataSpace::deleteConstants
+// Purpose: Deletes the constant object that DataSpace::ALL_ points to
+// Programmer Binh-Minh Ribler - 2015
+//--------------------------------------------------------------------------
+void DataSpace::deleteConstants()
+{
+ if (ALL_ != 0)
+ delete ALL_;
+}
+
+//--------------------------------------------------------------------------
+// Purpose Constant for default dataspace.
+//--------------------------------------------------------------------------
+const DataSpace& DataSpace::ALL = *getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: DataSpace constructor
diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h
index a43cecd..4cbe62c 100644
--- a/c++/src/H5DataSpace.h
+++ b/c++/src/H5DataSpace.h
@@ -24,8 +24,8 @@ namespace H5 {
//! Class DataSpace operates on HDF5 dataspaces.
class H5_DLLCPP DataSpace : public IdComponent {
public:
- // Default DataSpace objects
- static const DataSpace ALL;
+ ///\brief Default DataSpace objects
+ static const DataSpace& ALL;
// Creates a dataspace object given the space type
DataSpace(H5S_class_t type = H5S_SCALAR);
@@ -118,20 +118,34 @@ class H5_DLLCPP DataSpace : public IdComponent {
// Gets the dataspace id.
virtual hid_t getId() const;
+ // Deletes the global constant
+ static void deleteConstants();
+
// Destructor: properly terminates access to this dataspace.
virtual ~DataSpace();
- protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ protected:
// Sets the dataspace id.
virtual void p_setId(const hid_t new_id);
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
private:
hid_t id; // HDF5 dataspace id
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ static DataSpace* ALL_;
+
+ // Creates the global constant
+ static DataSpace* getConstant();
+
// Friend function to set DataSpace id. For library use only.
friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id);
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index cdcd1e6..02d3eda 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -760,23 +760,17 @@ void DataType::close()
// - Added the use of H5CPP_EXITED to terminate the HDF5 library
// and elimiate previous memory leaks. See comments in the
// header file "H5PredType.h" for details. - BMR, Mar 30, 2012
+// - Major re-implementation of the global constants was done
+// to avoid relying on the order of the creation and deletion
+// of the global constants. Hence, H5CPP_EXITED was removed.
+// See Design Notes in "H5PredType.cpp" for details.
+// - BMR, Sep 30, 2015
//--------------------------------------------------------------------------
DataType::~DataType()
{
try
{
- /* If this is the object AtExit, terminate the HDF5 library. This is
- to eliminate memory leaks due to the library being re-initiated
- (after the program has ended) and not re-terminated. */
- if (id == H5CPP_EXITED)
- {
- herr_t ret_value = H5close();
- if (ret_value == FAIL)
- throw DataTypeIException(inMemFunc("~DataType - "), "H5close failed");
- }
- // Close the HDF5 datatype
- else
- close();
+ close();
}
catch (Exception close_error) {
cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl;
diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp
index 2b124ee..5ee212a 100644
--- a/c++/src/H5DcreatProp.cpp
+++ b/c++/src/H5DcreatProp.cpp
@@ -28,10 +28,63 @@
namespace H5 {
#endif
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
+// the order of creation and deletion of the global constants. See Design Notes
+// in "H5PredType.cpp" for information.
+
+// Initialize a pointer for the constant
+DSetCreatPropList* DSetCreatPropList::DEFAULT_ = 0;
+
+//--------------------------------------------------------------------------
+// Function: DSetCreatPropList::getConstant
+// Purpose: Creates a DSetCreatPropList object representing the HDF5
+// constant H5P_DATASET_CREATE, pointed to by
+// DSetCreatPropList::DEFAULT_
+// exception H5::PropListIException
+// Description
+// If DSetCreatPropList::DEFAULT_ already points to an allocated
+// object, throw a PropListIException. This scenario should
+// not happen.
+// Programmer Binh-Minh Ribler - 2015
+//--------------------------------------------------------------------------
+DSetCreatPropList* DSetCreatPropList::getConstant()
+{
+ // Tell the C library not to clean up, H5Library::termH5cpp will call
+ // H5close - more dependency if use H5Library::dontAtExit()
+ if (!IdComponent::H5dontAtexit_called)
+ {
+ (void) H5dont_atexit();
+ IdComponent::H5dontAtexit_called = true;
+ }
+
+ // If the constant pointer is not allocated, allocate it. Otherwise,
+ // throw because it shouldn't be.
+ if (DEFAULT_ == 0)
+ DEFAULT_ = new DSetCreatPropList(H5P_DATASET_CREATE);
+ else
+ throw PropListIException("DSetCreatPropList::getConstant", "DSetCreatPropList::getConstant is being invoked on an allocated DEFAULT_");
+ return(DEFAULT_);
+}
+
//--------------------------------------------------------------------------
-///\brief Constant for dataset creation default property
+// Function: DSetCreatPropList::deleteConstants
+// Purpose: Deletes the constant object that DSetCreatPropList::DEFAULT_
+// points to.
+// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-const DSetCreatPropList DSetCreatPropList::DEFAULT;
+void DSetCreatPropList::deleteConstants()
+{
+ if (DEFAULT_ != 0)
+ delete DEFAULT_;
+}
+
+//--------------------------------------------------------------------------
+// Purpose Constant for dataset creation default property
+//--------------------------------------------------------------------------
+const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: DSetCreatPropList default constructor
diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h
index 7434b9b..0bb1459 100644
--- a/c++/src/H5DcreatProp.h
+++ b/c++/src/H5DcreatProp.h
@@ -27,8 +27,8 @@ namespace H5 {
*/
class H5_DLLCPP DSetCreatPropList : public PropList {
public:
- // Default dataset creation property list.
- static const DSetCreatPropList DEFAULT;
+ ///\brief Default dataset creation property list.
+ static const DSetCreatPropList& DEFAULT;
// Creates a dataset creation property list.
DSetCreatPropList();
@@ -123,6 +123,19 @@ class H5_DLLCPP DSetCreatPropList : public PropList {
// Noop destructor.
virtual ~DSetCreatPropList();
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ // Deletes the global constant, should only be used by the library
+ static void deleteConstants();
+
+ private:
+ static DSetCreatPropList* DEFAULT_;
+
+ // Creates the global constant, should only be used by the library
+ static DSetCreatPropList* getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp
index 1f4a638..49bbfe6 100644
--- a/c++/src/H5DxferProp.cpp
+++ b/c++/src/H5DxferProp.cpp
@@ -22,24 +22,67 @@
#include "H5DxferProp.h"
#include "H5private.h" // for HDmemset
-#include <iostream>
-
#ifndef H5_NO_NAMESPACE
-#ifndef H5_NO_STD
- using std::cerr;
- using std::endl;
-#endif // H5_NO_STD
+namespace H5 {
#endif
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
+// the order of creation and deletion of the global constants. See Design Notes
+// in "H5PredType.cpp" for information.
-#ifndef H5_NO_NAMESPACE
-namespace H5 {
-#endif
+// Initialize a pointer for the constant
+DSetMemXferPropList* DSetMemXferPropList::DEFAULT_ = 0;
//--------------------------------------------------------------------------
-///\brief Constant for default dataset memory and transfer property list.
+// Function: DSetMemXferPropList::getConstant
+// Creates a DSetMemXferPropList object representing the HDF5
+// constant H5P_DATASET_XFER, pointed to by
+// DSetMemXferPropList::DEFAULT_
+// exception H5::PropListIException
+// Description
+// If DSetMemXferPropList::DEFAULT_ already points to an allocated
+// object, throw a PropListIException. This scenario should not
+// happen.
+// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-const DSetMemXferPropList DSetMemXferPropList::DEFAULT;
+DSetMemXferPropList* DSetMemXferPropList::getConstant()
+{
+ // Tell the C library not to clean up, H5Library::termH5cpp will call
+ // H5close - more dependency if use H5Library::dontAtExit()
+ if (!IdComponent::H5dontAtexit_called)
+ {
+ (void) H5dont_atexit();
+ IdComponent::H5dontAtexit_called = true;
+ }
+
+ // If the constant pointer is not allocated, allocate it. Otherwise,
+ // throw because it shouldn't be.
+ if (DEFAULT_ == 0)
+ DEFAULT_ = new DSetMemXferPropList(H5P_DATASET_XFER);
+ else
+ throw PropListIException("DSetMemXferPropList::getConstant", "DSetMemXferPropList::getConstant is being invoked on an allocated DEFAULT_");
+ return(DEFAULT_);
+}
+
+//--------------------------------------------------------------------------
+// Function: DSetMemXferPropList::deleteConstants
+// Purpose: Deletes the constant object that DSetMemXferPropList::DEFAULT_
+// points to.
+// Programmer Binh-Minh Ribler - 2015
+//--------------------------------------------------------------------------
+void DSetMemXferPropList::deleteConstants()
+{
+ if (DEFAULT_ != 0)
+ delete DEFAULT_;
+}
+
+//--------------------------------------------------------------------------
+// Purpose Constant for default dataset memory and transfer property list.
+//--------------------------------------------------------------------------
+const DSetMemXferPropList& DSetMemXferPropList::DEFAULT = *getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function DSetMemXferPropList default constructor
diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h
index f93676e..85d2ec2 100644
--- a/c++/src/H5DxferProp.h
+++ b/c++/src/H5DxferProp.h
@@ -27,7 +27,8 @@ namespace H5 {
*/
class H5_DLLCPP DSetMemXferPropList : public PropList {
public:
- static const DSetMemXferPropList DEFAULT;
+ ///\brief Default dataset memory and transfer property list.
+ static const DSetMemXferPropList& DEFAULT;
// Creates a dataset memory and transfer property list.
DSetMemXferPropList();
@@ -113,6 +114,19 @@ class H5_DLLCPP DSetMemXferPropList : public PropList {
// Noop destructor
virtual ~DSetMemXferPropList();
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ // Deletes the global constant, should only be used by the library
+ static void deleteConstants();
+
+ private:
+ static DSetMemXferPropList* DEFAULT_;
+
+ // Creates the global constant, should only be used by the library
+ static DSetMemXferPropList* getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp
index 5ce9d8e..d3d7811 100644
--- a/c++/src/H5FaccProp.cpp
+++ b/c++/src/H5FaccProp.cpp
@@ -25,10 +25,63 @@
namespace H5 {
#endif
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
+// the order of creation and deletion of the global constants. See Design Notes
+// in "H5PredType.cpp" for information.
+
+// Initialize a pointer for the constant
+FileAccPropList* FileAccPropList::DEFAULT_ = 0;
+
+//--------------------------------------------------------------------------
+// Function: FileAccPropList::getConstant
+// Creates a FileAccPropList object representing the HDF5 constant
+// H5P_FILE_ACCESS, pointed to by FileAccPropList::DEFAULT_
+// exception H5::PropListIException
+// Description
+// If FileAccPropList::DEFAULT_ already points to an allocated
+// object, throw a PropListIException. This scenario should not
+// happen.
+// Programmer Binh-Minh Ribler - 2015
+//--------------------------------------------------------------------------
+FileAccPropList* FileAccPropList::getConstant()
+{
+ // Tell the C library not to clean up, H5Library::termH5cpp will call
+ // H5close - more dependency if use H5Library::dontAtExit()
+ if (!IdComponent::H5dontAtexit_called)
+ {
+ (void) H5dont_atexit();
+ IdComponent::H5dontAtexit_called = true;
+ }
+
+ // If the constant pointer is not allocated, allocate it. Otherwise,
+ // throw because it shouldn't be.
+ if (DEFAULT_ == 0)
+ DEFAULT_ = new FileAccPropList(H5P_FILE_ACCESS);
+ else
+ throw PropListIException("FileAccPropList::getConstant", "FileAccPropList::getConstant is being invoked on an allocated DEFAULT_");
+ return(DEFAULT_);
+}
+
//--------------------------------------------------------------------------
-///\brief Constant for default property
+// Function: FileAccPropList::deleteConstants
+// Purpose: Deletes the constant object that FileAccPropList::DEFAULT_
+// points to.
+// exception H5::PropListIException
+// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-const FileAccPropList FileAccPropList::DEFAULT;
+void FileAccPropList::deleteConstants()
+{
+ if (DEFAULT_ != 0)
+ delete DEFAULT_;
+}
+
+//--------------------------------------------------------------------------
+// Purpose: Constant for default property
+//--------------------------------------------------------------------------
+const FileAccPropList& FileAccPropList::DEFAULT = *getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: Default Constructor
diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h
index fddc446..7d6529e 100644
--- a/c++/src/H5FaccProp.h
+++ b/c++/src/H5FaccProp.h
@@ -24,7 +24,8 @@ namespace H5 {
//! Class FileAccPropList represents the HDF5 file access property list.
class H5_DLLCPP FileAccPropList : public PropList {
public:
- static const FileAccPropList DEFAULT;
+ ///\brief Default file access property list.
+ static const FileAccPropList& DEFAULT;
// Creates a file access property list.
FileAccPropList();
@@ -145,6 +146,20 @@ class H5_DLLCPP FileAccPropList : public PropList {
// Noop destructor
virtual ~FileAccPropList();
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ // Deletes the global constant, should only be used by the library
+ static void deleteConstants();
+
+ private:
+ static FileAccPropList* DEFAULT_;
+
+ // Creates the global constant, should only be used by the library
+ static FileAccPropList* getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp
index 8d9965e..af51677 100644
--- a/c++/src/H5FcreatProp.cpp
+++ b/c++/src/H5FcreatProp.cpp
@@ -25,10 +25,61 @@
namespace H5 {
#endif
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
+// the order of creation and deletion of the global constants. See Design Notes
+// in "H5PredType.cpp" for information.
+
+// Initialize a pointer for the constant
+FileCreatPropList* FileCreatPropList::DEFAULT_ = 0;
+
+//--------------------------------------------------------------------------
+// Function: FileCreatPropList::getConstant
+// Purpose: Creates a FileCreatPropList object representing the HDF5
+// constant H5P_FILE_ACCESS, pointed to by FileCreatPropList::DEFAULT_
+// exception H5::PropListIException
+// Description
+// If FileCreatPropList::DEFAULT_ already points to an allocated
+// object, throw a PropListIException. This scenario should not happen.
+// Programmer Binh-Minh Ribler - 2015
+//--------------------------------------------------------------------------
+FileCreatPropList* FileCreatPropList::getConstant()
+{
+ // Tell the C library not to clean up, H5Library::termH5cpp will call
+ // H5close - more dependency if use H5Library::dontAtExit()
+ if (!IdComponent::H5dontAtexit_called)
+ {
+ (void) H5dont_atexit();
+ IdComponent::H5dontAtexit_called = true;
+ }
+
+ // If the constant pointer is not allocated, allocate it. Otherwise,
+ // throw because it shouldn't be.
+ if (DEFAULT_ == 0)
+ DEFAULT_ = new FileCreatPropList(H5P_FILE_CREATE);
+ else
+ throw PropListIException("FileCreatPropList::getConstant", "FileCreatPropList::getConstant is being invoked on an allocated DEFAULT_");
+ return(DEFAULT_);
+}
+
//--------------------------------------------------------------------------
-///\brief Constant for default property
+// Function: FileCreatPropList::deleteConstants
+// Purpose: Deletes the constant object that FileCreatPropList::DEFAULT_
+// points to.
+// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-const FileCreatPropList FileCreatPropList::DEFAULT;
+void FileCreatPropList::deleteConstants()
+{
+ if (DEFAULT_ != 0)
+ delete DEFAULT_;
+}
+
+//--------------------------------------------------------------------------
+// Purpose Constant for default property
+//--------------------------------------------------------------------------
+const FileCreatPropList& FileCreatPropList::DEFAULT = *getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: FileCreatPropList default constructor
diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h
index 4fe51a9..5d81078 100644
--- a/c++/src/H5FcreatProp.h
+++ b/c++/src/H5FcreatProp.h
@@ -24,8 +24,8 @@ namespace H5 {
//! Class FileCreatPropList represents the HDF5 file create property list.
class H5_DLLCPP FileCreatPropList : public PropList {
public:
- // Default file creation property list.
- static const FileCreatPropList DEFAULT;
+ ///\brief Default file creation property list.
+ static const FileCreatPropList& DEFAULT;
// Creates a file create property list.
FileCreatPropList();
@@ -74,6 +74,20 @@ class H5_DLLCPP FileCreatPropList : public PropList {
// Noop destructor
virtual ~FileCreatPropList();
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ // Deletes the global constant, should only be used by the library
+ static void deleteConstants();
+
+ private:
+ static FileCreatPropList* DEFAULT_;
+
+ // Creates the global constant, should only be used by the library
+ static FileCreatPropList* getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index bcd69c4..93ee4fd 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -13,11 +13,6 @@
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-#ifdef OLD_HEADER_FILENAME
-#include <iostream.h>
-#else
-#include <iostream>
-#endif
#include <string>
#include "H5Include.h"
@@ -31,11 +26,16 @@
namespace H5 {
#endif
+// This flag controls whether H5Library::initH5cpp has been called to register
+// terminating functions with atexit()
+bool IdComponent::H5cppinit = false;
+bool IdComponent::H5dontAtexit_called = false;
+
//--------------------------------------------------------------------------
// Function: IdComponent overloaded constructor
-///\brief Creates an IdComponent object using the id of an existing object.
-///\param h5_id - IN: Id of an existing object
-///\exception H5::DataTypeIException
+// Purpose Creates an IdComponent object using the id of an existing object.
+// Param h5_id - IN: Id of an existing object
+// Exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//
// *** Deprecation warning ***
@@ -43,14 +43,10 @@ namespace H5 {
// 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) {}
-//void IdComponent::p_setId(const hid_t new_id)
-//{
- //p_setId(new_id);
-//}
-
//--------------------------------------------------------------------------
// Function: IdComponent copy constructor
// Purpose: This noop copy constructor is removed as a result of the data
@@ -296,7 +292,16 @@ H5std_string IdComponent::inMemFunc(const char* func_name) const
///\brief Default constructor.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-IdComponent::IdComponent() {}
+IdComponent::IdComponent()
+{
+ // initH5cpp will register the terminating functions with atexit().
+ // We only do this once.
+ if (!H5cppinit)
+ {
+ H5Library::getInstance()->initH5cpp();
+ H5cppinit = true;
+ }
+}
//--------------------------------------------------------------------------
// Function: IdComponent::p_get_file_name (protected)
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index 068fb74..1c29f09 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -31,6 +31,12 @@ class DataSpace;
*/
class H5_DLLCPP IdComponent {
public:
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ static bool H5cppinit;
+ static bool H5dontAtexit_called;
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
// Increment reference counter.
void incRefCount(const hid_t obj_id) const;
void incRefCount() const;
diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp
index ecc5141..31856ec 100644
--- a/c++/src/H5Library.cpp
+++ b/c++/src/H5Library.cpp
@@ -14,10 +14,22 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string>
+#include <cstdlib>
-#include "H5CppDoc.h" // included only for Doxygen to generate part of RM
+#include "H5CppDoc.h" // included only for Doxygen to generate part of RM
#include "H5Include.h"
#include "H5Exception.h"
+#include "H5IdComponent.h"
+#include "H5PropList.h"
+#include "H5FaccProp.h"
+#include "H5FcreatProp.h"
+#include "H5DxferProp.h"
+#include "H5Object.h"
+#include "H5DataType.h"
+#include "H5DcreatProp.h"
+#include "H5AtomType.h"
+#include "H5PredType.h"
+#include "H5DataSpace.h"
#include "H5Library.h"
#ifndef H5_NO_NAMESPACE
@@ -25,8 +37,7 @@ namespace H5 {
#endif
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-// This static variable will be set to true when dontAtExit is called
-bool H5Library::need_cleanup = false;
+H5Library* H5Library::instance = 0;
#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
@@ -63,18 +74,17 @@ void H5Library::close()
//--------------------------------------------------------------------------
// Function: H5Library::dontAtExit
-///\brief Instructs library not to install \c atexit cleanup routine
+///\brief Instructs library not to install the C \c atexit cleanup routine
///
///\exception H5::LibraryIException
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// Removed the check for failure returned from H5dont_atexit.
+// will be fixed to not fail (HDFFV-9540)
//--------------------------------------------------------------------------
void H5Library::dontAtExit()
{
herr_t ret_value = H5dont_atexit();
- if( ret_value < 0 )
- {
- throw LibraryIException("H5Library::dontAtExit", "H5dont_atexit failed");
- }
}
//--------------------------------------------------------------------------
@@ -148,6 +158,91 @@ void H5Library::garbageCollect()
}
//--------------------------------------------------------------------------
+// Function: H5Library::initH5cpp
+///\brief Initializes C++ library and registers terminating functions at
+/// exit. Only for the library functions, not for user-defined
+/// functions.
+// Description
+// 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
+///\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
+ int ret_value = 0;
+ ret_value = std::atexit(termH5cpp);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of termH5cpp failed");
+
+ ret_value = std::atexit(PredType::deleteConstants);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of PredType::deleteConstants failed");
+
+ ret_value = std::atexit(PropList::deleteConstants);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of PropList::deleteConstants failed");
+
+ ret_value = std::atexit(FileAccPropList::deleteConstants);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of FileAccPropList::deleteConstants failed");
+
+ ret_value = std::atexit(FileCreatPropList::deleteConstants);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of FileCreatPropList::deleteConstants failed");
+
+ ret_value = std::atexit(DSetMemXferPropList::deleteConstants);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of DSetMemXferPropList::deleteConstants failed");
+
+ ret_value = std::atexit(DSetCreatPropList::deleteConstants);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of DSetCreatPropList::deleteConstants failed");
+
+ ret_value = std::atexit(DataSpace::deleteConstants);
+ if (ret_value != 0)
+ throw LibraryIException("H5Library::initH5cpp", "Registration of DataSpace::deleteConstants failed");
+}
+
+//--------------------------------------------------------------------------
+// Function: H5Library::termH5cpp
+///\brief Sends request for the C layer to terminate.
+///\par Description
+/// If the C library fails to terminate, exit with a failure.
+// Programmer Binh-Minh Ribler - September, 2015
+//--------------------------------------------------------------------------
+void H5Library::termH5cpp()
+{
+ // Close the C library
+ herr_t ret_value = H5close();
+ if (ret_value == -1)
+ exit(-1);
+}
+
+//--------------------------------------------------------------------------
+// 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
///\brief Sets limits on the different kinds of free lists.
///\param reg_global_lim - IN: Limit on all "regular" free list memory used
@@ -174,6 +269,13 @@ void H5Library::setFreeListLimits(int reg_global_lim, int reg_list_lim,
throw LibraryIException("H5Library::setFreeListLimits", "H5set_free_list_limits failed");
}
}
+
+// Default constructor - no instance ever created by outsiders
+H5Library::H5Library(){};
+
+// Destructor
+H5Library::~H5Library(){};
+
#ifndef H5_NO_NAMESPACE
} // end namespace
#endif
diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h
index e5365f9..68ab039 100644
--- a/c++/src/H5Library.h
+++ b/c++/src/H5Library.h
@@ -21,14 +21,6 @@
namespace H5 {
#endif
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-#define NOTATEXIT (-10) // just in case the HDF5 library use more
- // negative constants. Note: the solution used for the atexit/global
- // destructors is not reliable, and desperately needs improvement
- // It is not even working, inifiteloop message still printed when
- // calling H5close
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
/*! \class H5Library
\brief Class H5Library operates the HDF5 library globably.
@@ -37,10 +29,6 @@ namespace H5 {
*/
class H5_DLLCPP H5Library {
public:
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
- static bool need_cleanup; // indicates if H5close should be called
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
// Initializes the HDF5 library.
static void open();
@@ -65,9 +53,28 @@ class H5_DLLCPP H5Library {
static void setFreeListLimits(int reg_global_lim, int reg_list_lim, int
arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim);
+ // Initializes C++ library and registers terminating functions at exit.
+ // Only for the library functions, not for user-defined functions.
+ static void initH5cpp(void);
+
+ // Sends request for terminating the HDF5 library.
+ static void termH5cpp(void);
+
+ static H5Library* getInstance();
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
private:
- // Default constructor - no instance ever created
- H5Library() {};
+
+ // private instance to be created by H5Library only
+ static H5Library* instance;
+
+ // Default constructor - no instance ever created from outsiders
+ H5Library();
+
+ // Destructor
+ ~H5Library();
+#endif // DOXYGEN_SHOULD_SKIP_THIS
};
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 42f2a13..a9d3e6d 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -33,9 +33,6 @@
#include "H5DataSet.h"
#include "H5Attribute.h"
#include "H5private.h" // for HDmemset
-#include <iostream>
-using namespace std;
-
#ifndef H5_NO_NAMESPACE
namespace H5 {
diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp
index 6dbee98..fb29f1e 100644
--- a/c++/src/H5PredType.cpp
+++ b/c++/src/H5PredType.cpp
@@ -20,11 +20,8 @@
#include "H5IdComponent.h"
#include "H5PropList.h"
#include "H5Object.h"
-#include "H5DcreatProp.h"
-#include "H5CommonFG.h"
#include "H5DataType.h"
#include "H5AtomType.h"
-#include "H5Library.h"
#include "H5PredType.h"
#ifndef H5_NO_NAMESPACE
@@ -42,12 +39,9 @@ namespace H5 {
// the provided HDF5 predefined datatype.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PredType::PredType( const hid_t predtype_id ) : AtomType( predtype_id )
+PredType::PredType(const hid_t predtype_id) : AtomType(predtype_id)
{
- if (predtype_id == H5CPP_EXITED)
- id = predtype_id;
- else
- id = H5Tcopy(predtype_id);
+ id = H5Tcopy(predtype_id);
}
//--------------------------------------------------------------------------
@@ -64,238 +58,1039 @@ PredType::PredType() : AtomType() {}
///\param original - IN: PredType instance to copy
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PredType::PredType( const PredType& original ) : AtomType( original ) {}
+PredType::PredType(const PredType& original) : AtomType(original) {}
+
+//--------------------------------------------------------------------------
+// Function: PredType::operator=
+///\brief Assignment operator.
+///\param rhs - IN: Reference to the predefined datatype
+///\return Reference to PredType instance
+///\exception H5::DataTypeIException
+// Description
+// Makes a copy of the type on the right hand side and stores
+// the new id in the left hand side object.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+PredType& PredType::operator=( const PredType& rhs )
+{
+ if (this != &rhs)
+ copy(rhs);
+ return(*this);
+}
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-// Flag to terminate HDF5 library in DataType::~DataType
-const PredType PredType::AtExit(H5CPP_EXITED);
-
-// Definition of pre-defined types
-const PredType PredType::C_S1( H5T_C_S1 );
-const PredType PredType::FORTRAN_S1( H5T_FORTRAN_S1 );
-
-const PredType PredType::STD_I8BE( H5T_STD_I8BE );
-const PredType PredType::STD_I8LE( H5T_STD_I8LE );
-const PredType PredType::STD_I16BE( H5T_STD_I16BE );
-const PredType PredType::STD_I16LE( H5T_STD_I16LE );
-const PredType PredType::STD_I32BE( H5T_STD_I32BE );
-const PredType PredType::STD_I32LE( H5T_STD_I32LE );
-const PredType PredType::STD_I64BE( H5T_STD_I64BE );
-const PredType PredType::STD_I64LE( H5T_STD_I64LE );
-const PredType PredType::STD_U8BE( H5T_STD_U8BE );
-const PredType PredType::STD_U8LE( H5T_STD_U8LE );
-const PredType PredType::STD_U16BE( H5T_STD_U16BE );
-const PredType PredType::STD_U16LE( H5T_STD_U16LE );
-const PredType PredType::STD_U32BE( H5T_STD_U32BE );
-const PredType PredType::STD_U32LE( H5T_STD_U32LE );
-const PredType PredType::STD_U64BE( H5T_STD_U64BE );
-const PredType PredType::STD_U64LE( H5T_STD_U64LE );
-const PredType PredType::STD_B8BE( H5T_STD_B8BE );
-const PredType PredType::STD_B8LE( H5T_STD_B8LE );
-
-const PredType PredType::STD_B16BE( H5T_STD_B16BE );
-const PredType PredType::STD_B16LE( H5T_STD_B16LE );
-const PredType PredType::STD_B32BE( H5T_STD_B32BE );
-const PredType PredType::STD_B32LE( H5T_STD_B32LE );
-const PredType PredType::STD_B64BE( H5T_STD_B64BE );
-const PredType PredType::STD_B64LE( H5T_STD_B64LE );
-const PredType PredType::STD_REF_OBJ( H5T_STD_REF_OBJ );
-const PredType PredType::STD_REF_DSETREG( H5T_STD_REF_DSETREG );
-
-const PredType PredType::IEEE_F32BE( H5T_IEEE_F32BE );
-const PredType PredType::IEEE_F32LE( H5T_IEEE_F32LE );
-const PredType PredType::IEEE_F64BE( H5T_IEEE_F64BE );
-const PredType PredType::IEEE_F64LE( H5T_IEEE_F64LE );
-
-const PredType PredType::UNIX_D32BE( H5T_UNIX_D32BE );
-const PredType PredType::UNIX_D32LE( H5T_UNIX_D32LE );
-const PredType PredType::UNIX_D64BE( H5T_UNIX_D64BE );
-const PredType PredType::UNIX_D64LE( H5T_UNIX_D64LE );
-
-const PredType PredType::INTEL_I8( H5T_INTEL_I8 );
-const PredType PredType::INTEL_I16( H5T_INTEL_I16 );
-const PredType PredType::INTEL_I32( H5T_INTEL_I32 );
-const PredType PredType::INTEL_I64( H5T_INTEL_I64 );
-const PredType PredType::INTEL_U8( H5T_INTEL_U8 );
-const PredType PredType::INTEL_U16( H5T_INTEL_U16 );
-const PredType PredType::INTEL_U32( H5T_INTEL_U32 );
-const PredType PredType::INTEL_U64( H5T_INTEL_U64 );
-const PredType PredType::INTEL_B8( H5T_INTEL_B8 );
-const PredType PredType::INTEL_B16( H5T_INTEL_B16 );
-const PredType PredType::INTEL_B32( H5T_INTEL_B32 );
-const PredType PredType::INTEL_B64( H5T_INTEL_B64 );
-const PredType PredType::INTEL_F32( H5T_INTEL_F32 );
-const PredType PredType::INTEL_F64( H5T_INTEL_F64 );
-
-const PredType PredType::ALPHA_I8( H5T_ALPHA_I8 );
-const PredType PredType::ALPHA_I16( H5T_ALPHA_I16 );
-const PredType PredType::ALPHA_I32( H5T_ALPHA_I32 );
-const PredType PredType::ALPHA_I64( H5T_ALPHA_I64 );
-const PredType PredType::ALPHA_U8( H5T_ALPHA_U8 );
-const PredType PredType::ALPHA_U16( H5T_ALPHA_U16 );
-const PredType PredType::ALPHA_U32( H5T_ALPHA_U32 );
-const PredType PredType::ALPHA_U64( H5T_ALPHA_U64 );
-const PredType PredType::ALPHA_B8( H5T_ALPHA_B8 );
-const PredType PredType::ALPHA_B16( H5T_ALPHA_B16 );
-const PredType PredType::ALPHA_B32( H5T_ALPHA_B32 );
-const PredType PredType::ALPHA_B64( H5T_ALPHA_B64 );
-const PredType PredType::ALPHA_F32( H5T_ALPHA_F32 );
-const PredType PredType::ALPHA_F64( H5T_ALPHA_F64 );
-
-const PredType PredType::MIPS_I8( H5T_MIPS_I8 );
-const PredType PredType::MIPS_I16( H5T_MIPS_I16 );
-const PredType PredType::MIPS_I32( H5T_MIPS_I32 );
-const PredType PredType::MIPS_I64( H5T_MIPS_I64 );
-const PredType PredType::MIPS_U8( H5T_MIPS_U8 );
-const PredType PredType::MIPS_U16( H5T_MIPS_U16 );
-const PredType PredType::MIPS_U32( H5T_MIPS_U32 );
-const PredType PredType::MIPS_U64( H5T_MIPS_U64 );
-const PredType PredType::MIPS_B8( H5T_MIPS_B8 );
-const PredType PredType::MIPS_B16( H5T_MIPS_B16 );
-const PredType PredType::MIPS_B32( H5T_MIPS_B32 );
-const PredType PredType::MIPS_B64( H5T_MIPS_B64 );
-const PredType PredType::MIPS_F32( H5T_MIPS_F32 );
-const PredType PredType::MIPS_F64( H5T_MIPS_F64 );
-
-const PredType PredType::NATIVE_CHAR( H5T_NATIVE_CHAR );
-const PredType PredType::NATIVE_INT( H5T_NATIVE_INT );
-const PredType PredType::NATIVE_FLOAT( H5T_NATIVE_FLOAT );
-const PredType PredType::NATIVE_SCHAR( H5T_NATIVE_SCHAR );
-const PredType PredType::NATIVE_UCHAR( H5T_NATIVE_UCHAR );
-const PredType PredType::NATIVE_SHORT( H5T_NATIVE_SHORT );
-const PredType PredType::NATIVE_USHORT( H5T_NATIVE_USHORT );
-const PredType PredType::NATIVE_UINT( H5T_NATIVE_UINT );
-const PredType PredType::NATIVE_LONG( H5T_NATIVE_LONG );
-const PredType PredType::NATIVE_ULONG( H5T_NATIVE_ULONG );
-const PredType PredType::NATIVE_LLONG( H5T_NATIVE_LLONG );
-const PredType PredType::NATIVE_ULLONG( H5T_NATIVE_ULLONG );
-const PredType PredType::NATIVE_DOUBLE( H5T_NATIVE_DOUBLE );
-#if H5_SIZEOF_LONG_DOUBLE !=0
-const PredType PredType::NATIVE_LDOUBLE( H5T_NATIVE_LDOUBLE );
-#endif
-const PredType PredType::NATIVE_B8( H5T_NATIVE_B8 );
-const PredType PredType::NATIVE_B16( H5T_NATIVE_B16 );
-const PredType PredType::NATIVE_B32( H5T_NATIVE_B32 );
-const PredType PredType::NATIVE_B64( H5T_NATIVE_B64 );
-const PredType PredType::NATIVE_OPAQUE( H5T_NATIVE_OPAQUE );
-const PredType PredType::NATIVE_HSIZE( H5T_NATIVE_HSIZE );
-const PredType PredType::NATIVE_HSSIZE( H5T_NATIVE_HSSIZE );
-const PredType PredType::NATIVE_HERR( H5T_NATIVE_HERR );
-const PredType PredType::NATIVE_HBOOL( H5T_NATIVE_HBOOL );
-
-const PredType PredType::NATIVE_INT8( H5T_NATIVE_INT8 );
-const PredType PredType::NATIVE_UINT8( H5T_NATIVE_UINT8 );
-const PredType PredType::NATIVE_INT16( H5T_NATIVE_INT16 );
-const PredType PredType::NATIVE_UINT16( H5T_NATIVE_UINT16 );
-const PredType PredType::NATIVE_INT32( H5T_NATIVE_INT32 );
-const PredType PredType::NATIVE_UINT32( H5T_NATIVE_UINT32 );
-const PredType PredType::NATIVE_INT64( H5T_NATIVE_INT64 );
-const PredType PredType::NATIVE_UINT64( H5T_NATIVE_UINT64 );
+// These dummy functions do not inherit from DataType - they'll
+// throw an DataTypeIException if invoked.
+void PredType::commit(H5Location& loc, const char* name )
+{
+ throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!" );
+}
+
+void PredType::commit(H5Location& loc, const H5std_string& name )
+{
+ commit( loc, name.c_str());
+}
+
+bool PredType::committed()
+{
+ throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype." );
+}
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+// Default destructor
+//--------------------------------------------------------------------------
+// Function: PredType destructor
+///\brief Noop destructor.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+PredType::~PredType() {}
+
+/*****************************************************************************
+ The following section is regarding the global constants PredType,
+ DataSpace, and PropList.
+
+ *****************************************************************************/
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// Definition pointers for the constants
+PredType* PredType::PREDTYPE_CONST_ = 0; //dummy
+PredType* PredType::STD_I8BE_;
+PredType* PredType::STD_I8LE_;
+PredType* PredType::STD_I16BE_;
+PredType* PredType::STD_I16LE_;
+PredType* PredType::STD_I32BE_;
+PredType* PredType::STD_I32LE_;
+PredType* PredType::STD_I64BE_;
+PredType* PredType::STD_I64LE_;
+PredType* PredType::STD_U8BE_;
+PredType* PredType::STD_U8LE_;
+PredType* PredType::STD_U16BE_;
+PredType* PredType::STD_U16LE_;
+PredType* PredType::STD_U32BE_;
+PredType* PredType::STD_U32LE_;
+PredType* PredType::STD_U64BE_;
+PredType* PredType::STD_U64LE_;
+PredType* PredType::STD_B8BE_;
+PredType* PredType::STD_B8LE_;
+PredType* PredType::STD_B16BE_;
+PredType* PredType::STD_B16LE_;
+PredType* PredType::STD_B32BE_;
+PredType* PredType::STD_B32LE_;
+PredType* PredType::STD_B64BE_;
+PredType* PredType::STD_B64LE_;
+PredType* PredType::STD_REF_OBJ_;
+PredType* PredType::STD_REF_DSETREG_;
+
+PredType* PredType::C_S1_;
+PredType* PredType::FORTRAN_S1_;
+
+PredType* PredType::IEEE_F32BE_;
+PredType* PredType::IEEE_F32LE_;
+PredType* PredType::IEEE_F64BE_;
+PredType* PredType::IEEE_F64LE_;
+
+PredType* PredType::UNIX_D32BE_;
+PredType* PredType::UNIX_D32LE_;
+PredType* PredType::UNIX_D64BE_;
+PredType* PredType::UNIX_D64LE_;
+
+PredType* PredType::INTEL_I8_;
+PredType* PredType::INTEL_I16_;
+PredType* PredType::INTEL_I32_;
+PredType* PredType::INTEL_I64_;
+PredType* PredType::INTEL_U8_;
+PredType* PredType::INTEL_U16_;
+PredType* PredType::INTEL_U32_;
+PredType* PredType::INTEL_U64_;
+PredType* PredType::INTEL_B8_;
+PredType* PredType::INTEL_B16_;
+PredType* PredType::INTEL_B32_;
+PredType* PredType::INTEL_B64_;
+PredType* PredType::INTEL_F32_;
+PredType* PredType::INTEL_F64_;
+
+PredType* PredType::ALPHA_I8_;
+PredType* PredType::ALPHA_I16_;
+PredType* PredType::ALPHA_I32_;
+PredType* PredType::ALPHA_I64_;
+PredType* PredType::ALPHA_U8_;
+PredType* PredType::ALPHA_U16_;
+PredType* PredType::ALPHA_U32_;
+PredType* PredType::ALPHA_U64_;
+PredType* PredType::ALPHA_B8_;
+PredType* PredType::ALPHA_B16_;
+PredType* PredType::ALPHA_B32_;
+PredType* PredType::ALPHA_B64_;
+PredType* PredType::ALPHA_F32_;
+PredType* PredType::ALPHA_F64_;
+
+PredType* PredType::MIPS_I8_;
+PredType* PredType::MIPS_I16_;
+PredType* PredType::MIPS_I32_;
+PredType* PredType::MIPS_I64_;
+PredType* PredType::MIPS_U8_;
+PredType* PredType::MIPS_U16_;
+PredType* PredType::MIPS_U32_;
+PredType* PredType::MIPS_U64_;
+PredType* PredType::MIPS_B8_;
+PredType* PredType::MIPS_B16_;
+PredType* PredType::MIPS_B32_;
+PredType* PredType::MIPS_B64_;
+PredType* PredType::MIPS_F32_;
+PredType* PredType::MIPS_F64_;
+
+PredType* PredType::NATIVE_CHAR_;
+PredType* PredType::NATIVE_SCHAR_;
+PredType* PredType::NATIVE_UCHAR_;
+PredType* PredType::NATIVE_SHORT_;
+PredType* PredType::NATIVE_USHORT_;
+PredType* PredType::NATIVE_INT_;
+PredType* PredType::NATIVE_UINT_;
+PredType* PredType::NATIVE_LONG_;
+PredType* PredType::NATIVE_ULONG_;
+PredType* PredType::NATIVE_LLONG_;
+PredType* PredType::NATIVE_ULLONG_;
+PredType* PredType::NATIVE_FLOAT_;
+PredType* PredType::NATIVE_DOUBLE_;
+PredType* PredType::NATIVE_LDOUBLE_;
+PredType* PredType::NATIVE_B8_;
+PredType* PredType::NATIVE_B16_;
+PredType* PredType::NATIVE_B32_;
+PredType* PredType::NATIVE_B64_;
+PredType* PredType::NATIVE_OPAQUE_;
+PredType* PredType::NATIVE_HSIZE_;
+PredType* PredType::NATIVE_HSSIZE_;
+PredType* PredType::NATIVE_HERR_;
+PredType* PredType::NATIVE_HBOOL_;
+
+PredType* PredType::NATIVE_INT8_;
+PredType* PredType::NATIVE_UINT8_;
+PredType* PredType::NATIVE_INT16_;
+PredType* PredType::NATIVE_UINT16_;
+PredType* PredType::NATIVE_INT32_;
+PredType* PredType::NATIVE_UINT32_;
+PredType* PredType::NATIVE_INT64_;
+PredType* PredType::NATIVE_UINT64_;
// LEAST types
#if H5_SIZEOF_INT_LEAST8_T != 0
-const PredType PredType::NATIVE_INT_LEAST8( H5T_NATIVE_INT_LEAST8 );
+PredType* PredType::NATIVE_INT_LEAST8_;
#endif /* H5_SIZEOF_INT_LEAST8_T */
#if H5_SIZEOF_UINT_LEAST8_T != 0
-const PredType PredType::NATIVE_UINT_LEAST8( H5T_NATIVE_UINT_LEAST8 );
+PredType* PredType::NATIVE_UINT_LEAST8_;
#endif /* H5_SIZEOF_UINT_LEAST8_T */
#if H5_SIZEOF_INT_LEAST16_T != 0
-const PredType PredType::NATIVE_INT_LEAST16( H5T_NATIVE_INT_LEAST16 );
+PredType* PredType::NATIVE_INT_LEAST16_;
#endif /* H5_SIZEOF_INT_LEAST16_T */
#if H5_SIZEOF_UINT_LEAST16_T != 0
-const PredType PredType::NATIVE_UINT_LEAST16( H5T_NATIVE_UINT_LEAST16 );
+PredType* PredType::NATIVE_UINT_LEAST16_;
#endif /* H5_SIZEOF_UINT_LEAST16_T */
#if H5_SIZEOF_INT_LEAST32_T != 0
-const PredType PredType::NATIVE_INT_LEAST32( H5T_NATIVE_INT_LEAST32 );
+PredType* PredType::NATIVE_INT_LEAST32_;
#endif /* H5_SIZEOF_INT_LEAST32_T */
#if H5_SIZEOF_UINT_LEAST32_T != 0
-const PredType PredType::NATIVE_UINT_LEAST32( H5T_NATIVE_UINT_LEAST32 );
+PredType* PredType::NATIVE_UINT_LEAST32_;
#endif /* H5_SIZEOF_UINT_LEAST32_T */
#if H5_SIZEOF_INT_LEAST64_T != 0
-const PredType PredType::NATIVE_INT_LEAST64( H5T_NATIVE_INT_LEAST64 );
+PredType* PredType::NATIVE_INT_LEAST64_;
#endif /* H5_SIZEOF_INT_LEAST64_T */
#if H5_SIZEOF_UINT_LEAST64_T != 0
-const PredType PredType::NATIVE_UINT_LEAST64( H5T_NATIVE_UINT_LEAST64 );
+PredType* PredType::NATIVE_UINT_LEAST64_;
#endif /* H5_SIZEOF_UINT_LEAST64_T */
// FAST types
#if H5_SIZEOF_INT_FAST8_T != 0
-const PredType PredType::NATIVE_INT_FAST8( H5T_NATIVE_INT_FAST8 );
+PredType* PredType::NATIVE_INT_FAST8_;
#endif /* H5_SIZEOF_INT_FAST8_T */
#if H5_SIZEOF_UINT_FAST8_T != 0
-const PredType PredType::NATIVE_UINT_FAST8( H5T_NATIVE_UINT_FAST8 );
+PredType* PredType::NATIVE_UINT_FAST8_;
#endif /* H5_SIZEOF_UINT_FAST8_T */
#if H5_SIZEOF_INT_FAST16_T != 0
-const PredType PredType::NATIVE_INT_FAST16( H5T_NATIVE_INT_FAST16 );
+PredType* PredType::NATIVE_INT_FAST16_;
#endif /* H5_SIZEOF_INT_FAST16_T */
#if H5_SIZEOF_UINT_FAST16_T != 0
-const PredType PredType::NATIVE_UINT_FAST16( H5T_NATIVE_UINT_FAST16 );
+PredType* PredType::NATIVE_UINT_FAST16_;
#endif /* H5_SIZEOF_UINT_FAST16_T */
#if H5_SIZEOF_INT_FAST32_T != 0
-const PredType PredType::NATIVE_INT_FAST32( H5T_NATIVE_INT_FAST32 );
+PredType* PredType::NATIVE_INT_FAST32_;
#endif /* H5_SIZEOF_INT_FAST32_T */
#if H5_SIZEOF_UINT_FAST32_T != 0
-const PredType PredType::NATIVE_UINT_FAST32( H5T_NATIVE_UINT_FAST32 );
+PredType* PredType::NATIVE_UINT_FAST32_;
#endif /* H5_SIZEOF_UINT_FAST32_T */
#if H5_SIZEOF_INT_FAST64_T != 0
-const PredType PredType::NATIVE_INT_FAST64( H5T_NATIVE_INT_FAST64 );
+PredType* PredType::NATIVE_INT_FAST64_;
#endif /* H5_SIZEOF_INT_FAST64_T */
#if H5_SIZEOF_UINT_FAST64_T != 0
-const PredType PredType::NATIVE_UINT_FAST64( H5T_NATIVE_UINT_FAST64 );
+PredType* PredType::NATIVE_UINT_FAST64_;
#endif /* H5_SIZEOF_UINT_FAST64_T */
-#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
-// Function: PredType::operator=
-///\brief Assignment operator.
-///\param rhs - IN: Reference to the predefined datatype
-///\return Reference to PredType instance
-///\exception H5::DataTypeIException
+// Function: PredType::getPredTypes
+// Purpose: Returns the dummy PredType constant object pointer
+// Return: PredType object pointer
// Description
-// Makes a copy of the type on the right hand side and stores
-// the new id in the left hand side object.
-// Programmer Binh-Minh Ribler - 2000
+// If the dummy constant PREDTYPE_CONST_ is not allocated yet,
+// call makePredTypes() to allocate all of the PredType constants.
+// Otherwise, just simply return the object pointer PREDTYPE_CONST_.
+//
+// Note that, there is a similar function to getPredTypes() in
+// other classes, that have global constants, is called getConstant().
+//
+// Programmer Binh-Minh Ribler - September 2015
//--------------------------------------------------------------------------
-PredType& PredType::operator=( const PredType& rhs )
+PredType* PredType::getPredTypes()
{
- if (this != &rhs)
- copy(rhs);
- return(*this);
-}
+ // Tell the C library not to clean up, H5Library::termH5cpp will call
+ // H5close - more dependency if use H5Library::dontAtExit()
+ if (!IdComponent::H5dontAtexit_called)
+ {
+ (void) H5dont_atexit();
+ IdComponent::H5dontAtexit_called = true;
+ }
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-// These dummy functions do not inherit from DataType - they'll
-// throw an DataTypeIException if invoked.
-void PredType::commit(H5Location& loc, const char* name )
-{
- throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype. Invalid operation!" );
+ // If the dummy constant pointer is not allocated, allocate all PredType
+ // constant pointers. Otherwise, throw because it shouldn't be.
+ if (PREDTYPE_CONST_ == 0)
+ makePredTypes();
+ else
+ throw H5::DataTypeIException("PredType::getPredTypes", "PredType::getPredTypes is being invoked on an allocated PREDTYPE_CONST_");
+ return PREDTYPE_CONST_;
}
-void PredType::commit(H5Location& loc, const H5std_string& name )
+//--------------------------------------------------------------------------
+// Function: PredType::makePredTypes
+// Purpose: Allocate all PredType constants.
+// Programmer Binh-Minh Ribler - September 2015
+//--------------------------------------------------------------------------
+void PredType::makePredTypes()
{
- commit( loc, name.c_str());
-}
+ PREDTYPE_CONST_ = new PredType;
+ C_S1_ = new PredType(H5T_C_S1);
+ FORTRAN_S1_ = new PredType(H5T_FORTRAN_S1);
+
+ STD_I8BE_ = new PredType(H5T_STD_I8BE);
+ STD_I8LE_ = new PredType(H5T_STD_I8LE);
+ STD_I16BE_ = new PredType(H5T_STD_I16BE);
+ STD_I16LE_ = new PredType(H5T_STD_I16LE);
+ STD_I32BE_ = new PredType(H5T_STD_I32BE);
+ STD_I32LE_ = new PredType(H5T_STD_I32LE);
+ STD_I64BE_ = new PredType(H5T_STD_I64BE);
+ STD_I64LE_ = new PredType(H5T_STD_I64LE);
+ STD_U8BE_ = new PredType(H5T_STD_U8BE);
+ STD_U8LE_ = new PredType(H5T_STD_U8LE);
+ STD_U16BE_ = new PredType(H5T_STD_U16BE);
+ STD_U16LE_ = new PredType(H5T_STD_U16LE);
+ STD_U32BE_ = new PredType(H5T_STD_U32BE);
+ STD_U32LE_ = new PredType(H5T_STD_U32LE);
+ STD_U64BE_ = new PredType(H5T_STD_U64BE);
+ STD_U64LE_ = new PredType(H5T_STD_U64LE);
+ STD_B8BE_ = new PredType(H5T_STD_B8BE);
+ STD_B8LE_ = new PredType(H5T_STD_B8LE);
+
+ STD_B16BE_ = new PredType(H5T_STD_B16BE);
+ STD_B16LE_ = new PredType(H5T_STD_B16LE);
+ STD_B32BE_ = new PredType(H5T_STD_B32BE);
+ STD_B32LE_ = new PredType(H5T_STD_B32LE);
+ STD_B64BE_ = new PredType(H5T_STD_B64BE);
+ STD_B64LE_ = new PredType(H5T_STD_B64LE);
+ STD_REF_OBJ_ = new PredType(H5T_STD_REF_OBJ);
+ STD_REF_DSETREG_ = new PredType(H5T_STD_REF_DSETREG);
+
+ IEEE_F32BE_ = new PredType(H5T_IEEE_F32BE);
+ IEEE_F32LE_ = new PredType(H5T_IEEE_F32LE);
+ IEEE_F64BE_ = new PredType(H5T_IEEE_F64BE);
+ IEEE_F64LE_ = new PredType(H5T_IEEE_F64LE);
+
+ UNIX_D32BE_ = new PredType(H5T_UNIX_D32BE);
+ UNIX_D32LE_ = new PredType(H5T_UNIX_D32LE);
+ UNIX_D64BE_ = new PredType(H5T_UNIX_D64BE);
+ UNIX_D64LE_ = new PredType(H5T_UNIX_D64LE);
+
+ INTEL_I8_ = new PredType(H5T_INTEL_I8);
+ INTEL_I16_ = new PredType(H5T_INTEL_I16);
+ INTEL_I32_ = new PredType(H5T_INTEL_I32);
+ INTEL_I64_ = new PredType(H5T_INTEL_I64);
+ INTEL_U8_ = new PredType(H5T_INTEL_U8);
+ INTEL_U16_ = new PredType(H5T_INTEL_U16);
+ INTEL_U32_ = new PredType(H5T_INTEL_U32);
+ INTEL_U64_ = new PredType(H5T_INTEL_U64);
+ INTEL_B8_ = new PredType(H5T_INTEL_B8);
+ INTEL_B16_ = new PredType(H5T_INTEL_B16);
+ INTEL_B32_ = new PredType(H5T_INTEL_B32);
+ INTEL_B64_ = new PredType(H5T_INTEL_B64);
+ INTEL_F32_ = new PredType(H5T_INTEL_F32);
+ INTEL_F64_ = new PredType(H5T_INTEL_F64);
+
+ ALPHA_I8_ = new PredType(H5T_ALPHA_I8);
+ ALPHA_I16_ = new PredType(H5T_ALPHA_I16);
+ ALPHA_I32_ = new PredType(H5T_ALPHA_I32);
+ ALPHA_I64_ = new PredType(H5T_ALPHA_I64);
+ ALPHA_U8_ = new PredType(H5T_ALPHA_U8);
+ ALPHA_U16_ = new PredType(H5T_ALPHA_U16);
+ ALPHA_U32_ = new PredType(H5T_ALPHA_U32);
+ ALPHA_U64_ = new PredType(H5T_ALPHA_U64);
+ ALPHA_B8_ = new PredType(H5T_ALPHA_B8);
+ ALPHA_B16_ = new PredType(H5T_ALPHA_B16);
+ ALPHA_B32_ = new PredType(H5T_ALPHA_B32);
+ ALPHA_B64_ = new PredType(H5T_ALPHA_B64);
+ ALPHA_F32_ = new PredType(H5T_ALPHA_F32);
+ ALPHA_F64_ = new PredType(H5T_ALPHA_F64);
+
+ MIPS_I8_ = new PredType(H5T_MIPS_I8);
+ MIPS_I16_ = new PredType(H5T_MIPS_I16);
+ MIPS_I32_ = new PredType(H5T_MIPS_I32);
+ MIPS_I64_ = new PredType(H5T_MIPS_I64);
+ MIPS_U8_ = new PredType(H5T_MIPS_U8);
+ MIPS_U16_ = new PredType(H5T_MIPS_U16);
+ MIPS_U32_ = new PredType(H5T_MIPS_U32);
+ MIPS_U64_ = new PredType(H5T_MIPS_U64);
+ MIPS_B8_ = new PredType(H5T_MIPS_B8);
+ MIPS_B16_ = new PredType(H5T_MIPS_B16);
+ MIPS_B32_ = new PredType(H5T_MIPS_B32);
+ MIPS_B64_ = new PredType(H5T_MIPS_B64);
+ MIPS_F32_ = new PredType(H5T_MIPS_F32);
+ MIPS_F64_ = new PredType(H5T_MIPS_F64);
+
+ NATIVE_CHAR_ = new PredType(H5T_NATIVE_CHAR);
+ NATIVE_INT_ = new PredType(H5T_NATIVE_INT);
+ NATIVE_FLOAT_ = new PredType(H5T_NATIVE_FLOAT);
+ NATIVE_SCHAR_ = new PredType(H5T_NATIVE_SCHAR);
+ NATIVE_UCHAR_ = new PredType(H5T_NATIVE_UCHAR);
+ NATIVE_SHORT_ = new PredType(H5T_NATIVE_SHORT);
+ NATIVE_USHORT_ = new PredType(H5T_NATIVE_USHORT);
+ NATIVE_UINT_ = new PredType(H5T_NATIVE_UINT);
+ NATIVE_LONG_ = new PredType(H5T_NATIVE_LONG);
+ NATIVE_ULONG_ = new PredType(H5T_NATIVE_ULONG);
+ NATIVE_LLONG_ = new PredType(H5T_NATIVE_LLONG);
+ NATIVE_ULLONG_ = new PredType(H5T_NATIVE_ULLONG);
+ NATIVE_DOUBLE_ = new PredType(H5T_NATIVE_DOUBLE);
+#if H5_SIZEOF_LONG_DOUBLE !=0
+ NATIVE_LDOUBLE_ = new PredType(H5T_NATIVE_LDOUBLE);
+#endif
+ NATIVE_B8_ = new PredType(H5T_NATIVE_B8);
+ NATIVE_B16_ = new PredType(H5T_NATIVE_B16);
+ NATIVE_B32_ = new PredType(H5T_NATIVE_B32);
+ NATIVE_B64_ = new PredType(H5T_NATIVE_B64);
+ NATIVE_OPAQUE_ = new PredType(H5T_NATIVE_OPAQUE);
+ NATIVE_HSIZE_ = new PredType(H5T_NATIVE_HSIZE);
+ NATIVE_HSSIZE_ = new PredType(H5T_NATIVE_HSSIZE);
+ NATIVE_HERR_ = new PredType(H5T_NATIVE_HERR);
+ NATIVE_HBOOL_ = new PredType(H5T_NATIVE_HBOOL);
+
+ NATIVE_INT8_ = new PredType(H5T_NATIVE_INT8);
+ NATIVE_UINT8_ = new PredType(H5T_NATIVE_UINT8);
+ NATIVE_INT16_ = new PredType(H5T_NATIVE_INT16);
+ NATIVE_UINT16_ = new PredType(H5T_NATIVE_UINT16);
+ NATIVE_INT32_ = new PredType(H5T_NATIVE_INT32);
+ NATIVE_UINT32_ = new PredType(H5T_NATIVE_UINT32);
+ NATIVE_INT64_ = new PredType(H5T_NATIVE_INT64);
+ NATIVE_UINT64_ = new PredType(H5T_NATIVE_UINT64);
+
+// LEAST types
+#if H5_SIZEOF_INT_LEAST8_T != 0
+ NATIVE_INT_LEAST8_ = new PredType(H5T_NATIVE_INT_LEAST8);
+#endif /* H5_SIZEOF_INT_LEAST8_T */
+#if H5_SIZEOF_UINT_LEAST8_T != 0
+ NATIVE_UINT_LEAST8_ = new PredType(H5T_NATIVE_UINT_LEAST8);
+#endif /* H5_SIZEOF_UINT_LEAST8_T */
+
+#if H5_SIZEOF_INT_LEAST16_T != 0
+ NATIVE_INT_LEAST16_ = new PredType(H5T_NATIVE_INT_LEAST16);
+#endif /* H5_SIZEOF_INT_LEAST16_T */
+#if H5_SIZEOF_UINT_LEAST16_T != 0
+ NATIVE_UINT_LEAST16_ = new PredType(H5T_NATIVE_UINT_LEAST16);
+#endif /* H5_SIZEOF_UINT_LEAST16_T */
+
+#if H5_SIZEOF_INT_LEAST32_T != 0
+ NATIVE_INT_LEAST32_ = new PredType(H5T_NATIVE_INT_LEAST32);
+#endif /* H5_SIZEOF_INT_LEAST32_T */
+#if H5_SIZEOF_UINT_LEAST32_T != 0
+ NATIVE_UINT_LEAST32_ = new PredType(H5T_NATIVE_UINT_LEAST32);
+#endif /* H5_SIZEOF_UINT_LEAST32_T */
+
+#if H5_SIZEOF_INT_LEAST64_T != 0
+ NATIVE_INT_LEAST64_ = new PredType(H5T_NATIVE_INT_LEAST64);
+#endif /* H5_SIZEOF_INT_LEAST64_T */
+#if H5_SIZEOF_UINT_LEAST64_T != 0
+ NATIVE_UINT_LEAST64_ = new PredType(H5T_NATIVE_UINT_LEAST64);
+#endif /* H5_SIZEOF_UINT_LEAST64_T */
+
+// FAST types
+#if H5_SIZEOF_INT_FAST8_T != 0
+ NATIVE_INT_FAST8_ = new PredType(H5T_NATIVE_INT_FAST8);
+#endif /* H5_SIZEOF_INT_FAST8_T */
+#if H5_SIZEOF_UINT_FAST8_T != 0
+ NATIVE_UINT_FAST8_ = new PredType(H5T_NATIVE_UINT_FAST8);
+#endif /* H5_SIZEOF_UINT_FAST8_T */
+
+#if H5_SIZEOF_INT_FAST16_T != 0
+ NATIVE_INT_FAST16_ = new PredType(H5T_NATIVE_INT_FAST16);
+#endif /* H5_SIZEOF_INT_FAST16_T */
+#if H5_SIZEOF_UINT_FAST16_T != 0
+ NATIVE_UINT_FAST16_ = new PredType(H5T_NATIVE_UINT_FAST16);
+#endif /* H5_SIZEOF_UINT_FAST16_T */
+
+#if H5_SIZEOF_INT_FAST32_T != 0
+ NATIVE_INT_FAST32_ = new PredType(H5T_NATIVE_INT_FAST32);
+#endif /* H5_SIZEOF_INT_FAST32_T */
+#if H5_SIZEOF_UINT_FAST32_T != 0
+ NATIVE_UINT_FAST32_ = new PredType(H5T_NATIVE_UINT_FAST32);
+#endif /* H5_SIZEOF_UINT_FAST32_T */
+
+#if H5_SIZEOF_INT_FAST64_T != 0
+ NATIVE_INT_FAST64_ = new PredType(H5T_NATIVE_INT_FAST64);
+#endif /* H5_SIZEOF_INT_FAST64_T */
+#if H5_SIZEOF_UINT_FAST64_T != 0
+ NATIVE_UINT_FAST64_ = new PredType(H5T_NATIVE_UINT_FAST64);
+#endif /* H5_SIZEOF_UINT_FAST64_T */
+
+} // makePredTypes
-bool PredType::committed()
-{
- throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype." );
-}
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-// Default destructor
//--------------------------------------------------------------------------
-// Function: PredType destructor
-///\brief Noop destructor.
-// Programmer Binh-Minh Ribler - 2000
+// Function: PredType::deleteConstants
+// Purpose: Deletes all PredType constant pointers.
+// Programmer Binh-Minh Ribler - September 2015
//--------------------------------------------------------------------------
-PredType::~PredType() {}
+void PredType::deleteConstants()
+{
+ delete STD_I8BE_;
+ delete STD_I8LE_;
+ delete STD_I16BE_;
+ delete STD_I16LE_;
+ delete STD_I32BE_;
+ delete STD_I32LE_;
+ delete STD_I64BE_;
+ delete STD_I64LE_;
+ delete STD_U8BE_;
+ delete STD_U8LE_;
+ delete STD_U16BE_;
+ delete STD_U16LE_;
+ delete STD_U32BE_;
+ delete STD_U32LE_;
+ delete STD_U64BE_;
+ delete STD_U64LE_;
+ delete STD_B8BE_;
+ delete STD_B8LE_;
+ delete STD_B16BE_;
+ delete STD_B16LE_;
+ delete STD_B32BE_;
+ delete STD_B32LE_;
+ delete STD_B64BE_;
+ delete STD_B64LE_;
+ delete STD_REF_OBJ_;
+ delete STD_REF_DSETREG_;
+
+ delete C_S1_;
+ delete FORTRAN_S1_;
+
+ delete IEEE_F32BE_;
+ delete IEEE_F32LE_;
+ delete IEEE_F64BE_;
+ delete IEEE_F64LE_;
+
+ delete UNIX_D32BE_;
+ delete UNIX_D32LE_;
+ delete UNIX_D64BE_;
+ delete UNIX_D64LE_;
+
+ delete INTEL_I8_;
+ delete INTEL_I16_;
+ delete INTEL_I32_;
+ delete INTEL_I64_;
+ delete INTEL_U8_;
+ delete INTEL_U16_;
+ delete INTEL_U32_;
+ delete INTEL_U64_;
+ delete INTEL_B8_;
+ delete INTEL_B16_;
+ delete INTEL_B32_;
+ delete INTEL_B64_;
+ delete INTEL_F32_;
+ delete INTEL_F64_;
+
+ delete ALPHA_I8_;
+ delete ALPHA_I16_;
+ delete ALPHA_I32_;
+ delete ALPHA_I64_;
+ delete ALPHA_U8_;
+ delete ALPHA_U16_;
+ delete ALPHA_U32_;
+ delete ALPHA_U64_;
+ delete ALPHA_B8_;
+ delete ALPHA_B16_;
+ delete ALPHA_B32_;
+ delete ALPHA_B64_;
+ delete ALPHA_F32_;
+ delete ALPHA_F64_;
+
+ delete MIPS_I8_;
+ delete MIPS_I16_;
+ delete MIPS_I32_;
+ delete MIPS_I64_;
+ delete MIPS_U8_;
+ delete MIPS_U16_;
+ delete MIPS_U32_;
+ delete MIPS_U64_;
+ delete MIPS_B8_;
+ delete MIPS_B16_;
+ delete MIPS_B32_;
+ delete MIPS_B64_;
+ delete MIPS_F32_;
+ delete MIPS_F64_;
+
+ delete NATIVE_CHAR_;
+ delete NATIVE_SCHAR_;
+ delete NATIVE_UCHAR_;
+ delete NATIVE_SHORT_;
+ delete NATIVE_USHORT_;
+ delete NATIVE_INT_;
+ delete NATIVE_UINT_;
+ delete NATIVE_LONG_;
+ delete NATIVE_ULONG_;
+ delete NATIVE_LLONG_;
+ delete NATIVE_ULLONG_;
+ delete NATIVE_FLOAT_;
+ delete NATIVE_DOUBLE_;
+ delete NATIVE_LDOUBLE_;
+ delete NATIVE_B8_;
+ delete NATIVE_B16_;
+ delete NATIVE_B32_;
+ delete NATIVE_B64_;
+ delete NATIVE_OPAQUE_;
+ delete NATIVE_HSIZE_;
+ delete NATIVE_HSSIZE_;
+ delete NATIVE_HERR_;
+ delete NATIVE_HBOOL_;
+
+ delete NATIVE_INT8_;
+ delete NATIVE_UINT8_;
+ delete NATIVE_INT16_;
+ delete NATIVE_UINT16_;
+ delete NATIVE_INT32_;
+ delete NATIVE_UINT32_;
+ delete NATIVE_INT64_;
+ delete NATIVE_UINT64_;
+
+// LEAST types
+#if H5_SIZEOF_INT_LEAST8_T != 0
+ delete NATIVE_INT_LEAST8_;
+#endif /* H5_SIZEOF_INT_LEAST8_T */
+#if H5_SIZEOF_UINT_LEAST8_T != 0
+ delete NATIVE_UINT_LEAST8_;
+#endif /* H5_SIZEOF_UINT_LEAST8_T */
+
+#if H5_SIZEOF_INT_LEAST16_T != 0
+ delete NATIVE_INT_LEAST16_;
+#endif /* H5_SIZEOF_INT_LEAST16_T */
+#if H5_SIZEOF_UINT_LEAST16_T != 0
+ delete NATIVE_UINT_LEAST16_;
+#endif /* H5_SIZEOF_UINT_LEAST16_T */
+
+#if H5_SIZEOF_INT_LEAST32_T != 0
+ delete NATIVE_INT_LEAST32_;
+#endif /* H5_SIZEOF_INT_LEAST32_T */
+#if H5_SIZEOF_UINT_LEAST32_T != 0
+ delete NATIVE_UINT_LEAST32_;
+#endif /* H5_SIZEOF_UINT_LEAST32_T */
+
+#if H5_SIZEOF_INT_LEAST64_T != 0
+ delete NATIVE_INT_LEAST64_;
+#endif /* H5_SIZEOF_INT_LEAST64_T */
+#if H5_SIZEOF_UINT_LEAST64_T != 0
+ delete NATIVE_UINT_LEAST64_;
+#endif /* H5_SIZEOF_UINT_LEAST64_T */
+
+// FAST types
+#if H5_SIZEOF_INT_FAST8_T != 0
+ delete NATIVE_INT_FAST8_;
+#endif /* H5_SIZEOF_INT_FAST8_T */
+#if H5_SIZEOF_UINT_FAST8_T != 0
+ delete NATIVE_UINT_FAST8_;
+#endif /* H5_SIZEOF_UINT_FAST8_T */
+
+#if H5_SIZEOF_INT_FAST16_T != 0
+ delete NATIVE_INT_FAST16_;
+#endif /* H5_SIZEOF_INT_FAST16_T */
+#if H5_SIZEOF_UINT_FAST16_T != 0
+ delete NATIVE_UINT_FAST16_;
+#endif /* H5_SIZEOF_UINT_FAST16_T */
+
+#if H5_SIZEOF_INT_FAST32_T != 0
+ delete NATIVE_INT_FAST32_;
+#endif /* H5_SIZEOF_INT_FAST32_T */
+#if H5_SIZEOF_UINT_FAST32_T != 0
+ delete NATIVE_UINT_FAST32_;
+#endif /* H5_SIZEOF_UINT_FAST32_T */
+
+#if H5_SIZEOF_INT_FAST64_T != 0
+ delete NATIVE_INT_FAST64_;
+#endif /* H5_SIZEOF_INT_FAST64_T */
+#if H5_SIZEOF_UINT_FAST64_T != 0
+ delete NATIVE_UINT_FAST64_;
+#endif /* H5_SIZEOF_UINT_FAST64_T */
+
+ delete PREDTYPE_CONST_;
+ PREDTYPE_CONST_ = 0;
+} // deleteConstants
+
+// Assigning the constant references to the dynamically allocated constants
+// after using PREDTYPE_CONST to activate the creation of those constants.
+
+// PREDTYPE_CONST will be the first static constant declared in the file.
+// getPredTypes() will call makePredTypes() to allocate memory for all the
+// PredType constants. Note that, there is a similar function to getPredTypes()
+// in other classes, that have global constants, is called getConstant().
+
+const PredType& PredType::PREDTYPE_CONST = *PredType::getPredTypes();
+const PredType& PredType::STD_I8BE = *STD_I8BE_;
+const PredType& PredType::STD_I8LE = *STD_I8LE_;
+const PredType& PredType::STD_I16BE = *STD_I16BE_;
+const PredType& PredType::STD_I16LE = *STD_I16LE_;
+const PredType& PredType::STD_I32BE = *STD_I32BE_;
+const PredType& PredType::STD_I32LE = *STD_I32LE_;
+const PredType& PredType::STD_I64BE = *STD_I64BE_;
+const PredType& PredType::STD_I64LE = *STD_I64LE_;
+const PredType& PredType::STD_U8BE = *STD_U8BE_;
+const PredType& PredType::STD_U8LE = *STD_U8LE_;
+const PredType& PredType::STD_U16BE = *STD_U16BE_;
+const PredType& PredType::STD_U16LE = *STD_U16LE_;
+const PredType& PredType::STD_U32BE = *STD_U32BE_;
+const PredType& PredType::STD_U32LE = *STD_U32LE_;
+const PredType& PredType::STD_U64BE = *STD_U64BE_;
+const PredType& PredType::STD_U64LE = *STD_U64LE_;
+const PredType& PredType::STD_B8BE = *STD_B8BE_;
+const PredType& PredType::STD_B8LE = *STD_B8LE_;
+const PredType& PredType::STD_B16BE = *STD_B16BE_;
+const PredType& PredType::STD_B16LE = *STD_B16LE_;
+const PredType& PredType::STD_B32BE = *STD_B32BE_;
+const PredType& PredType::STD_B32LE = *STD_B32LE_;
+const PredType& PredType::STD_B64BE = *STD_B64BE_;
+const PredType& PredType::STD_B64LE = *STD_B64LE_;
+const PredType& PredType::STD_REF_OBJ = *STD_REF_OBJ_;
+const PredType& PredType::STD_REF_DSETREG = *STD_REF_DSETREG_;
+
+const PredType& PredType::C_S1 = *C_S1_;
+const PredType& PredType::FORTRAN_S1 = *FORTRAN_S1_;
+
+const PredType& PredType::IEEE_F32BE = *IEEE_F32BE_;
+const PredType& PredType::IEEE_F32LE = *IEEE_F32LE_;
+const PredType& PredType::IEEE_F64BE = *IEEE_F64BE_;
+const PredType& PredType::IEEE_F64LE = *IEEE_F64LE_;
+
+const PredType& PredType::UNIX_D32BE = *UNIX_D32BE_;
+const PredType& PredType::UNIX_D32LE = *UNIX_D32LE_;
+const PredType& PredType::UNIX_D64BE = *UNIX_D64BE_;
+const PredType& PredType::UNIX_D64LE = *UNIX_D64LE_;
+
+const PredType& PredType::INTEL_I8 = *INTEL_I8_;
+const PredType& PredType::INTEL_I16 = *INTEL_I16_;
+const PredType& PredType::INTEL_I32 = *INTEL_I32_;
+const PredType& PredType::INTEL_I64 = *INTEL_I64_;
+const PredType& PredType::INTEL_U8 = *INTEL_U8_;
+const PredType& PredType::INTEL_U16 = *INTEL_U16_;
+const PredType& PredType::INTEL_U32 = *INTEL_U32_;
+const PredType& PredType::INTEL_U64 = *INTEL_U64_;
+const PredType& PredType::INTEL_B8 = *INTEL_B8_;
+const PredType& PredType::INTEL_B16 = *INTEL_B16_;
+const PredType& PredType::INTEL_B32 = *INTEL_B32_;
+const PredType& PredType::INTEL_B64 = *INTEL_B64_;
+const PredType& PredType::INTEL_F32 = *INTEL_F32_;
+const PredType& PredType::INTEL_F64 = *INTEL_F64_;
+
+const PredType& PredType::ALPHA_I8 = *ALPHA_I8_;
+const PredType& PredType::ALPHA_I16 = *ALPHA_I16_;
+const PredType& PredType::ALPHA_I32 = *ALPHA_I32_;
+const PredType& PredType::ALPHA_I64 = *ALPHA_I64_;
+const PredType& PredType::ALPHA_U8 = *ALPHA_U8_;
+const PredType& PredType::ALPHA_U16 = *ALPHA_U16_;
+const PredType& PredType::ALPHA_U32 = *ALPHA_U32_;
+const PredType& PredType::ALPHA_U64 = *ALPHA_U64_;
+const PredType& PredType::ALPHA_B8 = *ALPHA_B8_;
+const PredType& PredType::ALPHA_B16 = *ALPHA_B16_;
+const PredType& PredType::ALPHA_B32 = *ALPHA_B32_;
+const PredType& PredType::ALPHA_B64 = *ALPHA_B64_;
+const PredType& PredType::ALPHA_F32 = *ALPHA_F32_;
+const PredType& PredType::ALPHA_F64 = *ALPHA_F64_;
+
+const PredType& PredType::MIPS_I8 = *MIPS_I8_;
+const PredType& PredType::MIPS_I16 = *MIPS_I16_;
+const PredType& PredType::MIPS_I32 = *MIPS_I32_;
+const PredType& PredType::MIPS_I64 = *MIPS_I64_;
+const PredType& PredType::MIPS_U8 = *MIPS_U8_;
+const PredType& PredType::MIPS_U16 = *MIPS_U16_;
+const PredType& PredType::MIPS_U32 = *MIPS_U32_;
+const PredType& PredType::MIPS_U64 = *MIPS_U64_;
+const PredType& PredType::MIPS_B8 = *MIPS_B8_;
+const PredType& PredType::MIPS_B16 = *MIPS_B16_;
+const PredType& PredType::MIPS_B32 = *MIPS_B32_;
+const PredType& PredType::MIPS_B64 = *MIPS_B64_;
+const PredType& PredType::MIPS_F32 = *MIPS_F32_;
+const PredType& PredType::MIPS_F64 = *MIPS_F64_;
+
+const PredType& PredType::NATIVE_CHAR = *NATIVE_CHAR_;
+const PredType& PredType::NATIVE_SCHAR = *NATIVE_SCHAR_;
+const PredType& PredType::NATIVE_UCHAR = *NATIVE_UCHAR_;
+const PredType& PredType::NATIVE_SHORT = *NATIVE_SHORT_;
+const PredType& PredType::NATIVE_USHORT = *NATIVE_USHORT_;
+const PredType& PredType::NATIVE_INT = *NATIVE_INT_;
+const PredType& PredType::NATIVE_UINT = *NATIVE_UINT_;
+const PredType& PredType::NATIVE_LONG = *NATIVE_LONG_;
+const PredType& PredType::NATIVE_ULONG = *NATIVE_ULONG_;
+const PredType& PredType::NATIVE_LLONG = *NATIVE_LLONG_;
+const PredType& PredType::NATIVE_ULLONG = *NATIVE_ULLONG_;
+const PredType& PredType::NATIVE_FLOAT = *NATIVE_FLOAT_;
+const PredType& PredType::NATIVE_DOUBLE = *NATIVE_DOUBLE_;
+const PredType& PredType::NATIVE_LDOUBLE = *NATIVE_LDOUBLE_;
+const PredType& PredType::NATIVE_B8 = *NATIVE_B8_;
+const PredType& PredType::NATIVE_B16 = *NATIVE_B16_;
+const PredType& PredType::NATIVE_B32 = *NATIVE_B32_;
+const PredType& PredType::NATIVE_B64 = *NATIVE_B64_;
+const PredType& PredType::NATIVE_OPAQUE = *NATIVE_OPAQUE_;
+const PredType& PredType::NATIVE_HSIZE = *NATIVE_HSIZE_;
+const PredType& PredType::NATIVE_HSSIZE = *NATIVE_HSSIZE_;
+const PredType& PredType::NATIVE_HERR = *NATIVE_HERR_;
+const PredType& PredType::NATIVE_HBOOL = *NATIVE_HBOOL_;
+
+const PredType& PredType::NATIVE_INT8 = *NATIVE_INT8_;
+const PredType& PredType::NATIVE_UINT8 = *NATIVE_UINT8_;
+const PredType& PredType::NATIVE_INT16 = *NATIVE_INT16_;
+const PredType& PredType::NATIVE_UINT16 = *NATIVE_UINT16_;
+const PredType& PredType::NATIVE_INT32 = *NATIVE_INT32_;
+const PredType& PredType::NATIVE_UINT32 = *NATIVE_UINT32_;
+const PredType& PredType::NATIVE_INT64 = *NATIVE_INT64_;
+const PredType& PredType::NATIVE_UINT64 = *NATIVE_UINT64_;
+
+// LEAST types
+#if H5_SIZEOF_INT_LEAST8_T != 0
+const PredType& PredType::NATIVE_INT_LEAST8 = *NATIVE_INT_LEAST8_;
+#endif /* H5_SIZEOF_INT_LEAST8_T */
+#if H5_SIZEOF_UINT_LEAST8_T != 0
+const PredType& PredType::NATIVE_UINT_LEAST8 = *NATIVE_UINT_LEAST8_;
+#endif /* H5_SIZEOF_UINT_LEAST8_T */
+
+#if H5_SIZEOF_INT_LEAST16_T != 0
+const PredType& PredType::NATIVE_INT_LEAST16 = *NATIVE_INT_LEAST16_;
+#endif /* H5_SIZEOF_INT_LEAST16_T */
+#if H5_SIZEOF_UINT_LEAST16_T != 0
+const PredType& PredType::NATIVE_UINT_LEAST16 = *NATIVE_UINT_LEAST16_;
+#endif /* H5_SIZEOF_UINT_LEAST16_T */
+
+#if H5_SIZEOF_INT_LEAST32_T != 0
+const PredType& PredType::NATIVE_INT_LEAST32 = *NATIVE_INT_LEAST32_;
+#endif /* H5_SIZEOF_INT_LEAST32_T */
+#if H5_SIZEOF_UINT_LEAST32_T != 0
+const PredType& PredType::NATIVE_UINT_LEAST32 = *NATIVE_UINT_LEAST32_;
+#endif /* H5_SIZEOF_UINT_LEAST32_T */
+
+#if H5_SIZEOF_INT_LEAST64_T != 0
+const PredType& PredType::NATIVE_INT_LEAST64 = *NATIVE_INT_LEAST64_;
+#endif /* H5_SIZEOF_INT_LEAST64_T */
+#if H5_SIZEOF_UINT_LEAST64_T != 0
+const PredType& PredType::NATIVE_UINT_LEAST64 = *NATIVE_UINT_LEAST64_;
+#endif /* H5_SIZEOF_UINT_LEAST64_T */
+
+// FAST types
+#if H5_SIZEOF_INT_FAST8_T != 0
+const PredType& PredType::NATIVE_INT_FAST8 = *NATIVE_INT_FAST8_;
+#endif /* H5_SIZEOF_INT_FAST8_T */
+#if H5_SIZEOF_UINT_FAST8_T != 0
+const PredType& PredType::NATIVE_UINT_FAST8 = *NATIVE_UINT_FAST8_;
+#endif /* H5_SIZEOF_UINT_FAST8_T */
+
+#if H5_SIZEOF_INT_FAST16_T != 0
+const PredType& PredType::NATIVE_INT_FAST16 = *NATIVE_INT_FAST16_;
+#endif /* H5_SIZEOF_INT_FAST16_T */
+#if H5_SIZEOF_UINT_FAST16_T != 0
+const PredType& PredType::NATIVE_UINT_FAST16 = *NATIVE_UINT_FAST16_;
+#endif /* H5_SIZEOF_UINT_FAST16_T */
+
+#if H5_SIZEOF_INT_FAST32_T != 0
+const PredType& PredType::NATIVE_INT_FAST32 = *NATIVE_INT_FAST32_;
+#endif /* H5_SIZEOF_INT_FAST32_T */
+#if H5_SIZEOF_UINT_FAST32_T != 0
+const PredType& PredType::NATIVE_UINT_FAST32 = *NATIVE_UINT_FAST32_;
+#endif /* H5_SIZEOF_UINT_FAST32_T */
+
+#if H5_SIZEOF_INT_FAST64_T != 0
+const PredType& PredType::NATIVE_INT_FAST64 = *NATIVE_INT_FAST64_;
+#endif /* H5_SIZEOF_INT_FAST64_T */
+#if H5_SIZEOF_UINT_FAST64_T != 0
+const PredType& PredType::NATIVE_UINT_FAST64 = *NATIVE_UINT_FAST64_;
+#endif /* H5_SIZEOF_UINT_FAST64_T */
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
#ifndef H5_NO_NAMESPACE
} // end namespace
#endif
+
+/***************************************************************************
+ Design Note
+ ===========
+
+September 2015:
+
+ The C++ library has several types of global constants from different
+ classes, such as PropList, PredType, DataSpace, etc... Previously,
+ these global constants were declared statically and the C++ library used
+ a constant, called PredType::AtExit, to detect when all the global
+ contants are destroyed then close the C library (H5close). This method
+ relied on the order of the constants being created and destroyed and
+ that PredType constants be the last to be destroyed. In September
+ 2015, it was recognized that the order in which the global constants were
+ created and destroyed was actually undefined, thus can be different
+ between different compilers. This resulted in failure when compilers
+ destroy PredType constants before others because when PredType::AtExit
+ was destroyed, the C library was closed, so when the constants of other
+ classes such as PropList or DataSpace were being deleted, the C library
+ would not be available.
+
+ These are the classes that have global constants:
+ + PredType
+ + DataSpace
+ + PropList (and its subclasses below)
+ + FileAccPropList
+ + FileCreatPropList
+ + DSetMemXferPropList
+ + DSetCreatPropList
+
+
+ The new method includes these main points:
+
+ - The C++ library uses dynamically allocated constants to have the
+ control in which order the global constants are created/destroyed.
+
+ - The previous static constants are changed to be the references to
+ the dynamically allocated constants to avoid impact on applications.
+
+ - The first time an IdComponent default constructor is invoked, it
+ will call the function H5Library::initH5cpp which registers the
+ terminating functions from each class that has the global constants
+ so that these functions can destroy those constants at the exit of the
+ application. IdComponent is a baseclass of any object class that has
+ an identifier, such as Group, DataSet, DataType,... The classes which
+ have the global constants are all derived from IdComponent.
+
+ - At the normal termination of the application, each registered function
+ for each constant type will delete all the allocated constants in
+ that type class, then a different terminating function, which was also
+ registered with atexit() by initH5cpp, will call H5close to close the
+ C library.
+
+ The following list presents the differences between the old and new
+ methods and the changes implemented for the new method.
+
+ 1. The following items are added to class H5Library:
+ // Private instance to be created by H5Library only
+ static H5Library* instance;
+
+ // Returns a singleton H5Library to initialize the global
+ // constants, invoked in IdComponent default constructor
+ static H5Library* getInstance(); // public
+
+ // Registers cleanup and terminating functions with atexit(),
+ // called in IdComponent default constructor
+ static void initH5cpp(void); // public
+
+ // Calls H5close to terminate the library, registered with
+ // atexit(), as the last thing to be done.
+ static void termH5cpp(void); // public
+
+ 2. The following shows the differences between the old and new methods
+ for allocating the PredType constants. There are more than 100
+ constants, but only one is shown here for examples.
+
+ Old Method:
+ ----------
+ // Declaration of the constant - in "H5PredType.h"
+ static const PredType NATIVE_INT;
+
+ // Definition of the constant - in "H5PredType.cpp"
+ const PredType PredType::NATIVE_INT(H5T_NATIVE_INT);
+
+ New Method:
+ ----------
+ // Declare pointer for a constant - in "H5PredType.h"
+ static PredType* NATIVE_INT_; // "H5PredType.h"
+
+ // Change previous constant to reference - in "H5PredType.h"
+ static const PredType& NATIVE_INT;
+
+ // The assignment of the first static constant, named
+ // PREDTYPE_CONST, calls makePredTypes() which allocates the
+ // dynamic memory for every PredType constant.
+
+ // Creates a dynamic PredType object representing a C constant
+ // - in makePredTypes()
+ NATIVE_INT_ = new PredType(H5T_NATIVE_INT);
+
+ // Assign the constant reference to the dynamic object
+ // - in "H5PredType.cpp"
+ const PredType& PredType::NATIVE_INT = *NATIVE_INT_;
+
+ Functions added to class PredType:
+
+ // Creates the constants
+ static void makePredTypes(); // private
+
+ // Calls makePredTypes to create the constants and returns
+ // the dummy constant PREDTYPE_CONST;
+ static PredType* getPredTypes(); // private
+
+ // Deletes the constants
+ static void deleteConstants(); // public
+
+ 3. This section shows the differences between the old and new methods
+ for allocating the DataSpace constant, DataSpace::ALL.
+
+ Old Method:
+ ----------
+ // Declaration of the constant - in "H5DataSpace.h"
+ static const DataSpace ALL;
+
+ // Definition of the constant - in "H5DataSpace.cpp"
+ const DataSpace DataSpace::ALL(H5S_ALL);
+
+ New Method:
+ ----------
+ // Declare pointer for a constant - in "H5DataSpace.h"
+ static DataSpace* ALL_; // "H5DataSpace.h"
+
+ // Change previous constant to reference - in "H5DataSpace.h"
+ static const DataSpace& ALL;
+
+ // Creates a dynamic DataSpace object representing the C constant
+ // - in "H5DataSpace.cpp"
+ ALL_ = new DataSpace(H5S_ALL);
+
+ // Assign the constant reference to the dynamic object
+ // - in "H5DataSpace.cpp"
+ const DataSpace& DataSpace::ALL = *ALL_;
+
+ Functions added to class DataSpace:
+
+ // Creates the constant
+ static DataSpace* getConstant(); // private
+
+ // Deletes the constant
+ static void deleteConstants(); // public
+
+ 4. This section shows the differences between the old and new methods
+ for allocating the following constants
+ - PropList constant, PropList::DEFAULT.
+ - DSetCreatPropList constant, DSetCreatPropList::DEFAULT.
+ - DSetMemXferPropList constant, DSetMemXferPropList::DEFAULT.
+ - FileCreatPropList constant, FileCreatPropList::DEFAULT.
+ - FileAccPropList constant, FileAccPropList::DEFAULT.
+
+ For these constants, the library has the same changes, except the
+ class names and the HDF5 corresponding constants. Only the items
+ of PropList are listed, and "PropList" can be replaced by any of
+ DSetCreatPropList, DSetMemXferPropList, FileCreatPropList,
+ FileAccPropList for those classes. The HDF5 C constant "H5P_DEFAULT"
+ can be replaced by any of these respectively: H5P_DATASET_CREATE,
+ H5P_DATASET_XFER, H5P_FILE_CREATE, and H5P_FILE_ACCESS.
+
+ Old Method:
+ ----------
+ // Declaration of the constant - in "H5PropList.h"
+ static const PropList DEFAULT;
+
+ // Definition of the constant - in "H5PropList.cpp"
+ const PropList PropList::DEFAULT(H5P_DEFAULT);
+
+ New Method:
+ ----------
+ // Declare pointer for a constant - in "H5PropList.h"
+ static PropList* DEFAULT_; // "H5PropList.h"
+
+ // Change previous constant to reference - in "H5PropList.h"
+ static const PropList& DEFAULT;
+
+ // Creates a dynamic PropList object representing the C constant
+ // - in "H5PropList.cpp"
+ DEFAULT_ = new PropList(H5P_DEFAULT);
+
+ // Assign the constant reference to the dynamic object
+ // - in "H5PropList.cpp"
+ const PropList& PropList::DEFAULT = *DEFAULT_;
+
+ Functions added to class PropList:
+
+ // Creates the constant
+ static PropList* getConstant(); // private
+
+ // Deletes the constants
+ static void deleteConstants(); // public
+
+ The same functions are added to the subclasses of PropList instead of
+ using PropList's because of the class types and in favor of clarity.
+
+****************************************************************************/
+
diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h
index 494b169..f560765 100644
--- a/c++/src/H5PredType.h
+++ b/c++/src/H5PredType.h
@@ -21,16 +21,6 @@
namespace H5 {
#endif
-/* This constant is defined for a workaround to eliminate memory leaks due to
- the library being re-initiated when PredType destructors are invoked. A
- PredType instant with H5CPP_EXITED as the value of its "id" is constructed
- 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 PredType
\brief Class PredType holds the definition of all the HDF5 predefined
datatypes.
@@ -53,211 +43,400 @@ class H5_DLLCPP PredType : public AtomType {
// Noop destructor
virtual ~PredType();
- // Declaration of predefined types; their definition is in H5PredType.cpp
- static const PredType STD_I8BE;
- static const PredType STD_I8LE;
- static const PredType STD_I16BE;
- static const PredType STD_I16LE;
- static const PredType STD_I32BE;
- static const PredType STD_I32LE;
- static const PredType STD_I64BE;
- static const PredType STD_I64LE;
- static const PredType STD_U8BE;
- static const PredType STD_U8LE;
- static const PredType STD_U16BE;
- static const PredType STD_U16LE;
- static const PredType STD_U32BE;
- static const PredType STD_U32LE;
- static const PredType STD_U64BE;
- static const PredType STD_U64LE;
- static const PredType STD_B8BE;
- static const PredType STD_B8LE;
- static const PredType STD_B16BE;
- static const PredType STD_B16LE;
- static const PredType STD_B32BE;
- static const PredType STD_B32LE;
- static const PredType STD_B64BE;
- static const PredType STD_B64LE;
- static const PredType STD_REF_OBJ;
- static const PredType STD_REF_DSETREG;
-
- static const PredType C_S1;
- static const PredType FORTRAN_S1;
-
- static const PredType IEEE_F32BE;
- static const PredType IEEE_F32LE;
- static const PredType IEEE_F64BE;
- static const PredType IEEE_F64LE;
-
- static const PredType UNIX_D32BE;
- static const PredType UNIX_D32LE;
- static const PredType UNIX_D64BE;
- static const PredType UNIX_D64LE;
-
- static const PredType INTEL_I8;
- static const PredType INTEL_I16;
- static const PredType INTEL_I32;
- static const PredType INTEL_I64;
- static const PredType INTEL_U8;
- static const PredType INTEL_U16;
- static const PredType INTEL_U32;
- static const PredType INTEL_U64;
- static const PredType INTEL_B8;
- static const PredType INTEL_B16;
- static const PredType INTEL_B32;
- static const PredType INTEL_B64;
- static const PredType INTEL_F32;
- static const PredType INTEL_F64;
-
- static const PredType ALPHA_I8;
- static const PredType ALPHA_I16;
- static const PredType ALPHA_I32;
- static const PredType ALPHA_I64;
- static const PredType ALPHA_U8;
- static const PredType ALPHA_U16;
- static const PredType ALPHA_U32;
- static const PredType ALPHA_U64;
- static const PredType ALPHA_B8;
- static const PredType ALPHA_B16;
- static const PredType ALPHA_B32;
- static const PredType ALPHA_B64;
- static const PredType ALPHA_F32;
- static const PredType ALPHA_F64;
-
- static const PredType MIPS_I8;
- static const PredType MIPS_I16;
- static const PredType MIPS_I32;
- static const PredType MIPS_I64;
- static const PredType MIPS_U8;
- static const PredType MIPS_U16;
- static const PredType MIPS_U32;
- static const PredType MIPS_U64;
- static const PredType MIPS_B8;
- static const PredType MIPS_B16;
- static const PredType MIPS_B32;
- static const PredType MIPS_B64;
- static const PredType MIPS_F32;
- static const PredType MIPS_F64;
-
- static const PredType NATIVE_CHAR;
- static const PredType NATIVE_SCHAR;
- static const PredType NATIVE_UCHAR;
- static const PredType NATIVE_SHORT;
- static const PredType NATIVE_USHORT;
- static const PredType NATIVE_INT;
- static const PredType NATIVE_UINT;
- static const PredType NATIVE_LONG;
- static const PredType NATIVE_ULONG;
- static const PredType NATIVE_LLONG;
- static const PredType NATIVE_ULLONG;
- static const PredType NATIVE_FLOAT;
- static const PredType NATIVE_DOUBLE;
- static const PredType NATIVE_LDOUBLE;
- static const PredType NATIVE_B8;
- static const PredType NATIVE_B16;
- static const PredType NATIVE_B32;
- static const PredType NATIVE_B64;
- static const PredType NATIVE_OPAQUE;
- static const PredType NATIVE_HSIZE;
- static const PredType NATIVE_HSSIZE;
- static const PredType NATIVE_HERR;
- static const PredType NATIVE_HBOOL;
-
- static const PredType NATIVE_INT8;
- static const PredType NATIVE_UINT8;
- static const PredType NATIVE_INT16;
- static const PredType NATIVE_UINT16;
- static const PredType NATIVE_INT32;
- static const PredType NATIVE_UINT32;
- static const PredType NATIVE_INT64;
- static const PredType NATIVE_UINT64;
+ /*! \brief This dummy function do not inherit from DataType - it will
+ throw a DataTypeIException if invoked.
+ */
+ void commit(H5Location& loc, const H5std_string& name );
+ /*! \brief This dummy function do not inherit from DataType - it will
+ throw a DataTypeIException if invoked.
+ */
+ void commit(H5Location& loc, const char* name );
+ /*! \brief This dummy function do not inherit from DataType - it will
+ throw a DataTypeIException if invoked.
+ */
+ bool committed();
+
+ ///\brief PredType constants
+ static const PredType& STD_I8BE;
+ static const PredType& STD_I8LE;
+ static const PredType& STD_I16BE;
+ static const PredType& STD_I16LE;
+ static const PredType& STD_I32BE;
+ static const PredType& STD_I32LE;
+ static const PredType& STD_I64BE;
+ static const PredType& STD_I64LE;
+ static const PredType& STD_U8BE;
+ static const PredType& STD_U8LE;
+ static const PredType& STD_U16BE;
+ static const PredType& STD_U16LE;
+ static const PredType& STD_U32BE;
+ static const PredType& STD_U32LE;
+ static const PredType& STD_U64BE;
+ static const PredType& STD_U64LE;
+ static const PredType& STD_B8BE;
+ static const PredType& STD_B8LE;
+ static const PredType& STD_B16BE;
+ static const PredType& STD_B16LE;
+ static const PredType& STD_B32BE;
+ static const PredType& STD_B32LE;
+ static const PredType& STD_B64BE;
+ static const PredType& STD_B64LE;
+ static const PredType& STD_REF_OBJ;
+ static const PredType& STD_REF_DSETREG;
+
+ static const PredType& C_S1;
+ static const PredType& FORTRAN_S1;
+
+ static const PredType& IEEE_F32BE;
+ static const PredType& IEEE_F32LE;
+ static const PredType& IEEE_F64BE;
+ static const PredType& IEEE_F64LE;
+
+ static const PredType& UNIX_D32BE;
+ static const PredType& UNIX_D32LE;
+ static const PredType& UNIX_D64BE;
+ static const PredType& UNIX_D64LE;
+
+ static const PredType& INTEL_I8;
+ static const PredType& INTEL_I16;
+ static const PredType& INTEL_I32;
+ static const PredType& INTEL_I64;
+ static const PredType& INTEL_U8;
+ static const PredType& INTEL_U16;
+ static const PredType& INTEL_U32;
+ static const PredType& INTEL_U64;
+ static const PredType& INTEL_B8;
+ static const PredType& INTEL_B16;
+ static const PredType& INTEL_B32;
+ static const PredType& INTEL_B64;
+ static const PredType& INTEL_F32;
+ static const PredType& INTEL_F64;
+
+ static const PredType& ALPHA_I8;
+ static const PredType& ALPHA_I16;
+ static const PredType& ALPHA_I32;
+ static const PredType& ALPHA_I64;
+ static const PredType& ALPHA_U8;
+ static const PredType& ALPHA_U16;
+ static const PredType& ALPHA_U32;
+ static const PredType& ALPHA_U64;
+ static const PredType& ALPHA_B8;
+ static const PredType& ALPHA_B16;
+ static const PredType& ALPHA_B32;
+ static const PredType& ALPHA_B64;
+ static const PredType& ALPHA_F32;
+ static const PredType& ALPHA_F64;
+
+ static const PredType& MIPS_I8;
+ static const PredType& MIPS_I16;
+ static const PredType& MIPS_I32;
+ static const PredType& MIPS_I64;
+ static const PredType& MIPS_U8;
+ static const PredType& MIPS_U16;
+ static const PredType& MIPS_U32;
+ static const PredType& MIPS_U64;
+ static const PredType& MIPS_B8;
+ static const PredType& MIPS_B16;
+ static const PredType& MIPS_B32;
+ static const PredType& MIPS_B64;
+ static const PredType& MIPS_F32;
+ static const PredType& MIPS_F64;
+
+ static const PredType& NATIVE_CHAR;
+ static const PredType& NATIVE_SCHAR;
+ static const PredType& NATIVE_UCHAR;
+ static const PredType& NATIVE_SHORT;
+ static const PredType& NATIVE_USHORT;
+ static const PredType& NATIVE_INT;
+ static const PredType& NATIVE_UINT;
+ static const PredType& NATIVE_LONG;
+ static const PredType& NATIVE_ULONG;
+ static const PredType& NATIVE_LLONG;
+ static const PredType& NATIVE_ULLONG;
+ static const PredType& NATIVE_FLOAT;
+ static const PredType& NATIVE_DOUBLE;
+ static const PredType& NATIVE_LDOUBLE;
+ static const PredType& NATIVE_B8;
+ static const PredType& NATIVE_B16;
+ static const PredType& NATIVE_B32;
+ static const PredType& NATIVE_B64;
+ static const PredType& NATIVE_OPAQUE;
+ static const PredType& NATIVE_HSIZE;
+ static const PredType& NATIVE_HSSIZE;
+ static const PredType& NATIVE_HERR;
+ static const PredType& NATIVE_HBOOL;
+
+ static const PredType& NATIVE_INT8;
+ static const PredType& NATIVE_UINT8;
+ static const PredType& NATIVE_INT16;
+ static const PredType& NATIVE_UINT16;
+ static const PredType& NATIVE_INT32;
+ static const PredType& NATIVE_UINT32;
+ static const PredType& NATIVE_INT64;
+ static const PredType& NATIVE_UINT64;
// LEAST types
#if H5_SIZEOF_INT_LEAST8_T != 0
- static const PredType NATIVE_INT_LEAST8;
+ static const PredType& NATIVE_INT_LEAST8;
#endif /* H5_SIZEOF_INT_LEAST8_T */
#if H5_SIZEOF_UINT_LEAST8_T != 0
- static const PredType NATIVE_UINT_LEAST8;
+ static const PredType& NATIVE_UINT_LEAST8;
#endif /* H5_SIZEOF_UINT_LEAST8_T */
#if H5_SIZEOF_INT_LEAST16_T != 0
- static const PredType NATIVE_INT_LEAST16;
+ static const PredType& NATIVE_INT_LEAST16;
#endif /* H5_SIZEOF_INT_LEAST16_T */
#if H5_SIZEOF_UINT_LEAST16_T != 0
- static const PredType NATIVE_UINT_LEAST16;
+ static const PredType& NATIVE_UINT_LEAST16;
#endif /* H5_SIZEOF_UINT_LEAST16_T */
#if H5_SIZEOF_INT_LEAST32_T != 0
- static const PredType NATIVE_INT_LEAST32;
+ static const PredType& NATIVE_INT_LEAST32;
#endif /* H5_SIZEOF_INT_LEAST32_T */
#if H5_SIZEOF_UINT_LEAST32_T != 0
- static const PredType NATIVE_UINT_LEAST32;
+ static const PredType& NATIVE_UINT_LEAST32;
#endif /* H5_SIZEOF_UINT_LEAST32_T */
#if H5_SIZEOF_INT_LEAST64_T != 0
- static const PredType NATIVE_INT_LEAST64;
+ static const PredType& NATIVE_INT_LEAST64;
#endif /* H5_SIZEOF_INT_LEAST64_T */
#if H5_SIZEOF_UINT_LEAST64_T != 0
- static const PredType NATIVE_UINT_LEAST64;
+ static const PredType& NATIVE_UINT_LEAST64;
#endif /* H5_SIZEOF_UINT_LEAST64_T */
// FAST types
#if H5_SIZEOF_INT_FAST8_T != 0
- static const PredType NATIVE_INT_FAST8;
+ static const PredType& NATIVE_INT_FAST8;
#endif /* H5_SIZEOF_INT_FAST8_T */
#if H5_SIZEOF_UINT_FAST8_T != 0
- static const PredType NATIVE_UINT_FAST8;
+ static const PredType& NATIVE_UINT_FAST8;
#endif /* H5_SIZEOF_UINT_FAST8_T */
#if H5_SIZEOF_INT_FAST16_T != 0
- static const PredType NATIVE_INT_FAST16;
+ static const PredType& NATIVE_INT_FAST16;
#endif /* H5_SIZEOF_INT_FAST16_T */
#if H5_SIZEOF_UINT_FAST16_T != 0
- static const PredType NATIVE_UINT_FAST16;
+ static const PredType& NATIVE_UINT_FAST16;
#endif /* H5_SIZEOF_UINT_FAST16_T */
#if H5_SIZEOF_INT_FAST32_T != 0
- static const PredType NATIVE_INT_FAST32;
+ static const PredType& NATIVE_INT_FAST32;
#endif /* H5_SIZEOF_INT_FAST32_T */
#if H5_SIZEOF_UINT_FAST32_T != 0
- static const PredType NATIVE_UINT_FAST32;
+ static const PredType& NATIVE_UINT_FAST32;
#endif /* H5_SIZEOF_UINT_FAST32_T */
#if H5_SIZEOF_INT_FAST64_T != 0
- static const PredType NATIVE_INT_FAST64;
+ static const PredType& NATIVE_INT_FAST64;
#endif /* H5_SIZEOF_INT_FAST64_T */
#if H5_SIZEOF_UINT_FAST64_T != 0
- static const PredType NATIVE_UINT_FAST64;
+ static const PredType& NATIVE_UINT_FAST64;
#endif /* H5_SIZEOF_UINT_FAST64_T */
- /*! \brief This dummy function do not inherit from DataType - it will
- throw a DataTypeIException if invoked.
- */
- void commit(H5Location& loc, const H5std_string& name );
- /*! \brief This dummy function do not inherit from DataType - it will
- throw a DataTypeIException if invoked.
- */
- void commit(H5Location& loc, const char* name );
- /*! \brief This dummy function do not inherit from DataType - it will
- throw a DataTypeIException if invoked.
- */
- bool committed();
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ // Deletes the PredType global constants
+ static void deleteConstants();
+
+ // Dummy constant
+ static const PredType& PREDTYPE_CONST; // dummy constant
protected:
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Default constructor
PredType();
// Creates a pre-defined type using an HDF5 pre-defined constant
PredType( const hid_t predtype_id ); // used by the library only
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
private:
- // Added this to work around the atexit/global destructor problem.
- // It'll help to terminate the library after other PredType instances
- // are closed. -BMR, Mar 30, 2012
- static const PredType AtExit;
+ // Activates the creation of the PredType global constants
+ static PredType* getPredTypes();
+
+ // Dynamically allocates PredType global constants
+ static void makePredTypes();
+
+ // Dummy constant
+ static PredType* PREDTYPE_CONST_;
+
+ // Declaration of pointers to constants
+ static PredType* STD_I8BE_;
+ static PredType* STD_I8LE_;
+ static PredType* STD_I16BE_;
+ static PredType* STD_I16LE_;
+ static PredType* STD_I32BE_;
+ static PredType* STD_I32LE_;
+ static PredType* STD_I64BE_;
+ static PredType* STD_I64LE_;
+ static PredType* STD_U8BE_;
+ static PredType* STD_U8LE_;
+ static PredType* STD_U16BE_;
+ static PredType* STD_U16LE_;
+ static PredType* STD_U32BE_;
+ static PredType* STD_U32LE_;
+ static PredType* STD_U64BE_;
+ static PredType* STD_U64LE_;
+ static PredType* STD_B8BE_;
+ static PredType* STD_B8LE_;
+ static PredType* STD_B16BE_;
+ static PredType* STD_B16LE_;
+ static PredType* STD_B32BE_;
+ static PredType* STD_B32LE_;
+ static PredType* STD_B64BE_;
+ static PredType* STD_B64LE_;
+ static PredType* STD_REF_OBJ_;
+ static PredType* STD_REF_DSETREG_;
+
+ static PredType* C_S1_;
+ static PredType* FORTRAN_S1_;
+
+ static PredType* IEEE_F32BE_;
+ static PredType* IEEE_F32LE_;
+ static PredType* IEEE_F64BE_;
+ static PredType* IEEE_F64LE_;
+
+ static PredType* UNIX_D32BE_;
+ static PredType* UNIX_D32LE_;
+ static PredType* UNIX_D64BE_;
+ static PredType* UNIX_D64LE_;
+
+ static PredType* INTEL_I8_;
+ static PredType* INTEL_I16_;
+ static PredType* INTEL_I32_;
+ static PredType* INTEL_I64_;
+ static PredType* INTEL_U8_;
+ static PredType* INTEL_U16_;
+ static PredType* INTEL_U32_;
+ static PredType* INTEL_U64_;
+ static PredType* INTEL_B8_;
+ static PredType* INTEL_B16_;
+ static PredType* INTEL_B32_;
+ static PredType* INTEL_B64_;
+ static PredType* INTEL_F32_;
+ static PredType* INTEL_F64_;
+
+ static PredType* ALPHA_I8_;
+ static PredType* ALPHA_I16_;
+ static PredType* ALPHA_I32_;
+ static PredType* ALPHA_I64_;
+ static PredType* ALPHA_U8_;
+ static PredType* ALPHA_U16_;
+ static PredType* ALPHA_U32_;
+ static PredType* ALPHA_U64_;
+ static PredType* ALPHA_B8_;
+ static PredType* ALPHA_B16_;
+ static PredType* ALPHA_B32_;
+ static PredType* ALPHA_B64_;
+ static PredType* ALPHA_F32_;
+ static PredType* ALPHA_F64_;
+
+ static PredType* MIPS_I8_;
+ static PredType* MIPS_I16_;
+ static PredType* MIPS_I32_;
+ static PredType* MIPS_I64_;
+ static PredType* MIPS_U8_;
+ static PredType* MIPS_U16_;
+ static PredType* MIPS_U32_;
+ static PredType* MIPS_U64_;
+ static PredType* MIPS_B8_;
+ static PredType* MIPS_B16_;
+ static PredType* MIPS_B32_;
+ static PredType* MIPS_B64_;
+ static PredType* MIPS_F32_;
+ static PredType* MIPS_F64_;
+
+ static PredType* NATIVE_CHAR_;
+ static PredType* NATIVE_SCHAR_;
+ static PredType* NATIVE_UCHAR_;
+ static PredType* NATIVE_SHORT_;
+ static PredType* NATIVE_USHORT_;
+ static PredType* NATIVE_INT_;
+ static PredType* NATIVE_UINT_;
+ static PredType* NATIVE_LONG_;
+ static PredType* NATIVE_ULONG_;
+ static PredType* NATIVE_LLONG_;
+ static PredType* NATIVE_ULLONG_;
+ static PredType* NATIVE_FLOAT_;
+ static PredType* NATIVE_DOUBLE_;
+ static PredType* NATIVE_LDOUBLE_;
+ static PredType* NATIVE_B8_;
+ static PredType* NATIVE_B16_;
+ static PredType* NATIVE_B32_;
+ static PredType* NATIVE_B64_;
+ static PredType* NATIVE_OPAQUE_;
+ static PredType* NATIVE_HSIZE_;
+ static PredType* NATIVE_HSSIZE_;
+ static PredType* NATIVE_HERR_;
+ static PredType* NATIVE_HBOOL_;
+
+ static PredType* NATIVE_INT8_;
+ static PredType* NATIVE_UINT8_;
+ static PredType* NATIVE_INT16_;
+ static PredType* NATIVE_UINT16_;
+ static PredType* NATIVE_INT32_;
+ static PredType* NATIVE_UINT32_;
+ static PredType* NATIVE_INT64_;
+ static PredType* NATIVE_UINT64_;
+
+// LEAST types
+#if H5_SIZEOF_INT_LEAST8_T != 0
+ static PredType* NATIVE_INT_LEAST8_;
+#endif /* H5_SIZEOF_INT_LEAST8_T */
+#if H5_SIZEOF_UINT_LEAST8_T != 0
+ static PredType* NATIVE_UINT_LEAST8_;
+#endif /* H5_SIZEOF_UINT_LEAST8_T */
+
+#if H5_SIZEOF_INT_LEAST16_T != 0
+ static PredType* NATIVE_INT_LEAST16_;
+#endif /* H5_SIZEOF_INT_LEAST16_T */
+#if H5_SIZEOF_UINT_LEAST16_T != 0
+ static PredType* NATIVE_UINT_LEAST16_;
+#endif /* H5_SIZEOF_UINT_LEAST16_T */
+
+#if H5_SIZEOF_INT_LEAST32_T != 0
+ static PredType* NATIVE_INT_LEAST32_;
+#endif /* H5_SIZEOF_INT_LEAST32_T */
+#if H5_SIZEOF_UINT_LEAST32_T != 0
+ static PredType* NATIVE_UINT_LEAST32_;
+#endif /* H5_SIZEOF_UINT_LEAST32_T */
+
+#if H5_SIZEOF_INT_LEAST64_T != 0
+ static PredType* NATIVE_INT_LEAST64_;
+#endif /* H5_SIZEOF_INT_LEAST64_T */
+#if H5_SIZEOF_UINT_LEAST64_T != 0
+ static PredType* NATIVE_UINT_LEAST64_;
+#endif /* H5_SIZEOF_UINT_LEAST64_T */
+
+// FAST types
+#if H5_SIZEOF_INT_FAST8_T != 0
+ static PredType* NATIVE_INT_FAST8_;
+#endif /* H5_SIZEOF_INT_FAST8_T */
+#if H5_SIZEOF_UINT_FAST8_T != 0
+ static PredType* NATIVE_UINT_FAST8_;
+#endif /* H5_SIZEOF_UINT_FAST8_T */
+
+#if H5_SIZEOF_INT_FAST16_T != 0
+ static PredType* NATIVE_INT_FAST16_;
+#endif /* H5_SIZEOF_INT_FAST16_T */
+#if H5_SIZEOF_UINT_FAST16_T != 0
+ static PredType* NATIVE_UINT_FAST16_;
+#endif /* H5_SIZEOF_UINT_FAST16_T */
+
+#if H5_SIZEOF_INT_FAST32_T != 0
+ static PredType* NATIVE_INT_FAST32_;
+#endif /* H5_SIZEOF_INT_FAST32_T */
+#if H5_SIZEOF_UINT_FAST32_T != 0
+ static PredType* NATIVE_UINT_FAST32_;
+#endif /* H5_SIZEOF_UINT_FAST32_T */
+
+#if H5_SIZEOF_INT_FAST64_T != 0
+ static PredType* NATIVE_INT_FAST64_;
+#endif /* H5_SIZEOF_INT_FAST64_T */
+#if H5_SIZEOF_UINT_FAST64_T != 0
+ static PredType* NATIVE_UINT_FAST64_;
+#endif /* H5_SIZEOF_UINT_FAST64_T */
+ // End of Declaration of pointers
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
};
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 70ec629..807aa0a 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -36,10 +36,60 @@ namespace H5 {
#endif // H5_NO_STD
#endif
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+// This DOXYGEN_SHOULD_SKIP_THIS block is a work-around approach to control
+// the order of creation and deletion of the global constants. See Design Notes
+// in "H5PredType.cpp" for information.
+
+// Initialize a pointer for the constant
+PropList* PropList::DEFAULT_ = 0;
+
//--------------------------------------------------------------------------
-///\brief Constant for default property.
+// Function: PropList::getConstant
+// Purpose: Creates a PropList object representing the HDF5 constant
+// H5P_DEFAULT, pointed to by PropList::DEFAULT_.
+// Exception H5::PropListIException
+// Description
+// If PropList::DEFAULT_ already points to an allocated object,
+// throw a PropListIException. This scenario should not happen.
+// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
-const PropList PropList::DEFAULT;
+PropList* PropList::getConstant()
+{
+ // Tell the C library not to clean up, H5Library::termH5cpp will call
+ // H5close - more dependency if use H5Library::dontAtExit()
+ if (!IdComponent::H5dontAtexit_called)
+ {
+ (void) H5dont_atexit();
+ IdComponent::H5dontAtexit_called = true;
+ }
+
+ // If the constant pointer is not allocated, allocate it. Otherwise,
+ // throw because it shouldn't be.
+ if (DEFAULT_ == 0)
+ DEFAULT_ = new PropList(H5P_DEFAULT);
+ else
+ throw PropListIException("PropList::getConstant", "PropList::getConstant is being invoked on an allocated DEFAULT_");
+ return(DEFAULT_);
+}
+
+//--------------------------------------------------------------------------
+// Function: PropList::deleteConstants
+// Purpose: Deletes the constant object that PropList::DEFAULT_ points to.
+// Programmer Binh-Minh Ribler - 2015
+//--------------------------------------------------------------------------
+void PropList::deleteConstants()
+{
+ if (DEFAULT_ != 0)
+ delete DEFAULT_;
+}
+
+//--------------------------------------------------------------------------
+// Purpose Constant for default property.
+//--------------------------------------------------------------------------
+const PropList& PropList::DEFAULT = *getConstant();
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function Default constructor
diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h
index f26201d..be04451 100644
--- a/c++/src/H5PropList.h
+++ b/c++/src/H5PropList.h
@@ -24,8 +24,8 @@ namespace H5 {
//! Class PropList provides operations for generic property lists.
class H5_DLLCPP PropList : public IdComponent {
public:
- // Default property list
- static const PropList DEFAULT;
+ ///\brief Default property list
+ static const PropList& DEFAULT;
// Creates a property list of a given type or creates a copy of an
// existing property list giving the property list id.
@@ -110,12 +110,23 @@ class H5_DLLCPP PropList : public IdComponent {
// Destructor: properly terminates access to this property list.
virtual ~PropList();
- protected:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ // Deletes the PropList global constant
+ static void deleteConstants();
+
+ protected:
hid_t id; // HDF5 property list id
// Sets the property list id.
virtual void p_setId(const hid_t new_id);
+
+ private:
+ static PropList* DEFAULT_;
+
+ // Dynamically allocates the PropList global constant
+ static PropList* getConstant();
+
#endif // DOXYGEN_SHOULD_SKIP_THIS
};