diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-03-30 21:57:37 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2015-03-30 21:57:37 (GMT) |
commit | ea029945f5b663cb5dc3aeda447e3d34a77632e0 (patch) | |
tree | 54e1cd65c7b2168d3685cbad4f1b6e76dec13047 /c++/src/H5File.cpp | |
parent | d2c5e2bf5780be51159d70cc1aec6496099a5f91 (diff) | |
download | hdf5-ea029945f5b663cb5dc3aeda447e3d34a77632e0.zip hdf5-ea029945f5b663cb5dc3aeda447e3d34a77632e0.tar.gz hdf5-ea029945f5b663cb5dc3aeda447e3d34a77632e0.tar.bz2 |
[svn-r26667] Purpose: Fixed HDFFV-8766
Description:
Per user Jason Newton request, the following constructor is added:
H5File(hid_t existing_id);
Also, fixed H5File::openFile to close current file first before re-using
the object.
Platforms tested:
Linux/64 (platypus)
Linux/32 2.6 (jam gnu and Intel 15.0)
SunOS 5.11 (emu)
Diffstat (limited to 'c++/src/H5File.cpp')
-rw-r--r-- | c++/src/H5File.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index e0a0da5..7ca126f 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -158,6 +158,25 @@ void H5File::p_get_file(const char* name, unsigned int flags, const FileCreatPro #endif // DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- +// Function: H5File overloaded constructor +///\brief Creates an H5File object using an existing file id. +///\param existing_id - IN: Id of an existing file +// Programmer Binh-Minh Ribler - 2015 +// Description +// Mar 29, 2015 +// Added in responding to a request from user Jason Newton. +// However, it is not recommended to use the private member "id" +// in applications. Unlike other situations, where similar +// constructor is needed by the library in order to return +// an object, H5File doesn't need it. -BMR (HDFFV-8766 partially) +//-------------------------------------------------------------------------- +H5File::H5File(hid_t existing_id) : H5Location(), CommonFG() +{ + id = existing_id; + incRefCount(); // increment number of references to this id +} + +//-------------------------------------------------------------------------- // Function: H5File copy constructor ///\brief Copy constructor: makes a copy of the original /// H5File object. @@ -225,6 +244,13 @@ bool H5File::isHdf5(const H5std_string& name ) //-------------------------------------------------------------------------- void H5File::openFile(const char* name, unsigned int flags, const FileAccPropList& access_plist) { + try { + close(); + } + catch (Exception close_error) { + throw FileIException("H5File::openFile", close_error.getDetailMsg()); + } + hid_t access_plist_id = access_plist.getId(); id = H5Fopen (name, flags, access_plist_id); if (id < 0) // throw an exception when open fails |