summaryrefslogtreecommitdiffstats
path: root/c++/src/H5FaccProp.cpp
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-10-08 15:41:08 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-10-08 15:41:08 (GMT)
commitd4e7a87244a01698b0d1e0728f877019564a879d (patch)
treec416924d8bc63260ee010c430da0d37c6552eb49 /c++/src/H5FaccProp.cpp
parentd80a13f75a408bf01069a8b276c4229d118307e8 (diff)
parent8edfabd297c10579eac941f31a26d5727889fa88 (diff)
downloadhdf5-inactive/avoid_truncate.zip
hdf5-inactive/avoid_truncate.tar.gz
hdf5-inactive/avoid_truncate.tar.bz2
[svn-r28002] merge from trunk.inactive/avoid_truncate
Diffstat (limited to 'c++/src/H5FaccProp.cpp')
-rw-r--r--c++/src/H5FaccProp.cpp57
1 files changed, 55 insertions, 2 deletions
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