summaryrefslogtreecommitdiffstats
path: root/c++/src/H5FcreatProp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++/src/H5FcreatProp.cpp')
-rw-r--r--c++/src/H5FcreatProp.cpp55
1 files changed, 53 insertions, 2 deletions
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