Merge pull request #232 in HDFFV/hdf5 from ~BMRIBLER/hdf5_bmr_cpp:develop to develop

Added subclass LinkAccPropList, exception ObjHeaderIException, and members H5Location::exists() and H5Object::objVersion().  This concluded HDFFV-10004.

* commit '7aff4266f85f850ee8d4ce25e8ceaa354ee3baee':
  Description:     Added H5LaccProp.[h,cpp].
  Removed commented section left in by mistake.
  Purpose: Add more tests Description:     Added more tests for the new constructors that replaced openXxxType() Platforms tested:     Linux/32 2.6 (jam)     Linux/64 (platypus)     Darwin (osx1010test)
  Purpose: Add new wrappers Description:     Added wrappers H5Location::exists() for H5Lexists.     Added wrapper H5Object::objVersion() to return the header version         of an HDF5 object.     Added new class LinkAccPropList to be used by H5Location::exists()     Added new exception: ObjHeaderIException for H5Object::objVersion()     Rearranged source files in Makefile.am Platforms tested:     Linux/32 2.6 (jam)     Linux/64 (platypus)     Darwin (osx1010test)
This commit is contained in:
Binh-Minh Ribler 2017-01-04 22:07:07 -06:00
commit 5a55331bed
35 changed files with 416 additions and 83 deletions

View File

@ -32,6 +32,7 @@ set (CPP_SOURCES
${HDF5_CPP_SRC_SOURCE_DIR}/H5Group.cpp
${HDF5_CPP_SRC_SOURCE_DIR}/H5IdComponent.cpp
${HDF5_CPP_SRC_SOURCE_DIR}/H5IntType.cpp
${HDF5_CPP_SRC_SOURCE_DIR}/H5LaccProp.cpp
${HDF5_CPP_SRC_SOURCE_DIR}/H5Library.cpp
${HDF5_CPP_SRC_SOURCE_DIR}/H5Location.cpp
${HDF5_CPP_SRC_SOURCE_DIR}/H5Object.cpp
@ -68,6 +69,7 @@ set (CPP_HDRS
${HDF5_CPP_SRC_SOURCE_DIR}/H5IdComponent.h
${HDF5_CPP_SRC_SOURCE_DIR}/H5Include.h
${HDF5_CPP_SRC_SOURCE_DIR}/H5IntType.h
${HDF5_CPP_SRC_SOURCE_DIR}/H5LaccProp.h
${HDF5_CPP_SRC_SOURCE_DIR}/H5Library.h
${HDF5_CPP_SRC_SOURCE_DIR}/H5Location.h
${HDF5_CPP_SRC_SOURCE_DIR}/H5Object.h

View File

@ -24,6 +24,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataSpace.h"

View File

@ -21,6 +21,7 @@
#include "H5PropList.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -21,6 +21,7 @@
#include "H5PropList.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -29,6 +29,7 @@
#include "H5FcreatProp.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5AbstractDs.h"

View File

@ -25,6 +25,7 @@ namespace H5 {
class PropList;
class FileCreatPropList;
class FileAccPropList;
class LinkAccPropList;
class DSetCreatPropList;
class DSetMemXferPropList;
class DTypePropList;

View File

@ -24,6 +24,7 @@
#include "H5DxferProp.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5Alltypes.h"

View File

@ -22,6 +22,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5Alltypes.h"

View File

@ -27,6 +27,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5AbstractDs.h"

View File

@ -30,6 +30,7 @@
#include "H5OcreatProp.h"
#include "H5DxferProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -30,6 +30,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -21,6 +21,7 @@
#include "H5PropList.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -24,6 +24,7 @@
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5DataSpace.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5AbstractDs.h"

View File

@ -424,7 +424,7 @@ DataTypeIException::DataTypeIException(const H5std_string& func, const H5std_str
//--------------------------------------------------------------------------
DataTypeIException::~DataTypeIException() throw() {}
/* //--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Subclass: ObjHeaderIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
@ -446,7 +446,6 @@ ObjHeaderIException::ObjHeaderIException(const H5std_string& func, const H5std_s
///\brief Noop destructor.
//--------------------------------------------------------------------------
ObjHeaderIException::~ObjHeaderIException() throw() {}
*/
//--------------------------------------------------------------------------
// Subclass: PropListIException

View File

@ -120,13 +120,12 @@ class H5_DLLCPP DataTypeIException : public Exception {
virtual ~DataTypeIException() throw();
};
/* class H5_DLLCPP ObjHeaderIException : public Exception {
class H5_DLLCPP ObjHeaderIException : public Exception {
public:
ObjHeaderIException(const H5std_string& func_name, const H5std_string& message = DEFAULT_MSG);
ObjHeaderIException();
virtual ~ObjHeaderIException() throw();
};
*/
class H5_DLLCPP PropListIException : public Exception {
public:

View File

@ -29,6 +29,7 @@
#include "H5OcreatProp.h"
#include "H5DxferProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5CommonFG.h"

View File

@ -22,6 +22,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -29,6 +29,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5AbstractDs.h"

View File

@ -22,6 +22,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

114
c++/src/H5LaccProp.cpp Normal file
View File

@ -0,0 +1,114 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string>
#include "H5Include.h"
#include "H5Exception.h"
#include "H5IdComponent.h"
#include "H5PropList.h"
#include "H5LaccProp.h"
namespace H5 {
#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
LinkAccPropList* LinkAccPropList::DEFAULT_ = 0;
//--------------------------------------------------------------------------
// Function: LinkAccPropList::getConstant
// Creates a LinkAccPropList object representing the HDF5 constant
// H5P_LINK_ACCESS, pointed to by LinkAccPropList::DEFAULT_
// exception H5::PropListIException
// Description
// If LinkAccPropList::DEFAULT_ already points to an allocated
// object, throw a PropListIException. This scenario should not
// happen.
// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
LinkAccPropList* LinkAccPropList::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 LinkAccPropList(H5P_LINK_ACCESS);
else
throw PropListIException("LinkAccPropList::getConstant", "LinkAccPropList::getConstant is being invoked on an allocated DEFAULT_");
return(DEFAULT_);
}
//--------------------------------------------------------------------------
// Function: LinkAccPropList::deleteConstants
// Purpose: Deletes the constant object that LinkAccPropList::DEFAULT_
// points to.
// exception H5::PropListIException
// Programmer Binh-Minh Ribler - 2015
//--------------------------------------------------------------------------
void LinkAccPropList::deleteConstants()
{
if (DEFAULT_ != 0)
delete DEFAULT_;
}
//--------------------------------------------------------------------------
// Purpose: Constant for default property
//--------------------------------------------------------------------------
const LinkAccPropList& LinkAccPropList::DEFAULT = *getConstant();
#endif // DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: Default Constructor
///\brief Creates a file access property list
// Programmer: Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
LinkAccPropList::LinkAccPropList() : PropList( H5P_LINK_ACCESS ) {}
//--------------------------------------------------------------------------
// Function: LinkAccPropList copy constructor
///\brief Copy Constructor: makes a copy of the original
///\param original - IN: LinkAccPropList instance to copy
// Programmer: Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
LinkAccPropList::LinkAccPropList(const LinkAccPropList& original) : PropList(original) {}
//--------------------------------------------------------------------------
// Function: LinkAccPropList overloaded constructor
///\brief Creates a file access property list using the id of an
/// existing one.
// Programmer: Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
LinkAccPropList::LinkAccPropList(const hid_t plist_id) : PropList(plist_id) {}
//--------------------------------------------------------------------------
// Function: LinkAccPropList destructor
///\brief Noop destructor
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
LinkAccPropList::~LinkAccPropList() {}
} // end namespace

67
c++/src/H5LaccProp.h Normal file
View File

@ -0,0 +1,67 @@
// C++ informative line for the emacs editor: -*- C++ -*-
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Class LinkAccPropList represents the HDF5 file access property list and
// inherits from DataType.
#ifndef __H5LinkAccPropList_H
#define __H5LinkAccPropList_H
namespace H5 {
/*! \class LinkAccPropList
\brief Class LinkAccPropList inherits from PropList and provides
wrappers for the HDF5 file access property list.
Inheritance: PropList -> IdComponent
*/
class H5_DLLCPP LinkAccPropList : public PropList {
public:
///\brief Default file access property list.
static const LinkAccPropList& DEFAULT;
// Creates a file access property list.
LinkAccPropList();
///\brief Returns this class name.
virtual H5std_string fromClass () const { return("LinkAccPropList"); }
// Copy constructor: creates a copy of a LinkAccPropList object.
LinkAccPropList( const LinkAccPropList& original );
// Creates a copy of an existing file access property list
// using the property list id.
LinkAccPropList (const hid_t plist_id);
// Noop destructor
virtual ~LinkAccPropList();
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Deletes the global constant, should only be used by the library
static void deleteConstants();
private:
static LinkAccPropList* DEFAULT_;
// Creates the global constant, should only be used by the library
static LinkAccPropList* getConstant();
#endif // DOXYGEN_SHOULD_SKIP_THIS
};
}
#endif // __H5LinkAccPropList_H

View File

@ -26,6 +26,7 @@
#include "H5OcreatProp.h"
#include "H5DxferProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"
@ -185,28 +186,27 @@ void H5Library::initH5cpp()
if (ret_value != 0)
throw LibraryIException("H5Library::initH5cpp", "Registrating PropList::deleteConstants failed");
/* ret_value = std::atexit(LinkAccPropList::deleteConstants);
ret_value = std::atexit(LinkAccPropList::deleteConstants);
if (ret_value != 0)
throw LibraryIException("H5Library::initH5cpp", "Registrating LinkAccPropList::deleteConstants failed");
*/
ret_value = std::atexit(FileAccPropList::deleteConstants);
ret_value = std::atexit(FileAccPropList::deleteConstants);
if (ret_value != 0)
throw LibraryIException("H5Library::initH5cpp", "Registrating FileAccPropList::deleteConstants failed");
ret_value = std::atexit(FileCreatPropList::deleteConstants);
ret_value = std::atexit(FileCreatPropList::deleteConstants);
if (ret_value != 0)
throw LibraryIException("H5Library::initH5cpp", "Registrating FileCreatPropList::deleteConstants failed");
ret_value = std::atexit(DSetMemXferPropList::deleteConstants);
ret_value = std::atexit(DSetMemXferPropList::deleteConstants);
if (ret_value != 0)
throw LibraryIException("H5Library::initH5cpp", "Registrating DSetMemXferPropList::deleteConstants failed");
ret_value = std::atexit(DSetCreatPropList::deleteConstants);
ret_value = std::atexit(DSetCreatPropList::deleteConstants);
if (ret_value != 0)
throw LibraryIException("H5Library::initH5cpp", "Registrating DSetCreatPropList::deleteConstants failed");
ret_value = std::atexit(ObjCreatPropList::deleteConstants);
ret_value = std::atexit(ObjCreatPropList::deleteConstants);
if (ret_value != 0)
throw LibraryIException("H5Library::initH5cpp", "Registrating ObjCreatPropList::deleteConstants failed");

View File

@ -26,6 +26,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"
@ -76,7 +77,7 @@ H5Location::H5Location() : IdComponent() {}
#endif // DOXYGEN_SHOULD_SKIP_THIS
/* //--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Function: H5Location::exists
///\brief Checks if a link of a given name exists in a location
///\param name - IN: Searched name
@ -96,11 +97,9 @@ bool H5Location::exists(const char* name, const LinkAccPropList& lapl) const
{
throwException("exists", "H5Lexists failed");
}
return false; // warning: control reaches end of non-void function
}
*/
/* //--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Function: H5Location::exists
///\brief Checks if a link of a given name exists in a location
///\param name - IN: Searched name
@ -113,7 +112,6 @@ bool H5Location::exists(const H5std_string& name, const LinkAccPropList& lapl) c
{
return(exists(name.c_str(), lapl));
}
*/
//--------------------------------------------------------------------------
// Function: H5Location::flush

View File

@ -33,15 +33,13 @@ namespace H5 {
*/
// Class forwarding
class H5_DLLCPP ArrayType;
/* class H5_DLLCPP LinkAccPropList; // remove when done
*/
class H5_DLLCPP LinkAccPropList;
class H5_DLLCPP VarLenType;
class H5_DLLCPP H5Location : public IdComponent {
public:
/* // Checks if a link of a given name exists in a location
// Checks if a link of a given name exists in a location
bool exists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
bool exists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
*/
// Flushes all buffers associated with this location to disk.
void flush( H5F_scope_t scope ) const;
@ -213,9 +211,9 @@ class H5_DLLCPP H5Location : public IdComponent {
// Retrieves the type of object that an object reference points to.
H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
// Sets the identifier of this object to a new value. - this one
// doesn't increment reference count
//virtual void p_setId(const hid_t new_id);
// Sets the identifier of this object to a new value. - this one
// doesn't increment reference count
//virtual void p_setId(const hid_t new_id);
#endif // DOXYGEN_SHOULD_SKIP_THIS

View File

@ -25,6 +25,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"
@ -256,6 +257,39 @@ int H5Object::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_da
throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate2 failed");
}
//--------------------------------------------------------------------------
// Function: H5Object::objVersion
///\brief Returns the header version of this HDF5 object.
///\return Object version, which can have the following values:
/// \li \c H5O_VERSION_1
/// \li \c H5O_VERSION_2
///\exception H5::ObjHeaderIException
/// Exception will be thrown when:
/// - an error returned by the C API
/// - version number is not one of the valid values above
// Programmer Binh-Minh Ribler - December, 2016
//--------------------------------------------------------------------------
unsigned H5Object::objVersion() const
{
H5O_info_t objinfo;
unsigned version = 0;
// Use C API to get information of the object
herr_t ret_value = H5Oget_info(getId(), &objinfo);
// Throw exception if C API returns failure
if (ret_value < 0)
throw Exception(inMemFunc("objVersion"), "H5Oget_info failed");
// Return a valid version or throw an exception for invalid value
else
{
version = objinfo.hdr.version;
if (version != H5O_VERSION_1 && version != H5O_VERSION_2)
throw ObjHeaderIException("objVersion", "Invalid version for object");
}
return(version);
}
//--------------------------------------------------------------------------
// Function: H5Object::getNumAttrs
///\brief Returns the number of attributes attached to this HDF5 object.

View File

@ -77,6 +77,9 @@ class H5_DLLCPP H5Object : public H5Location {
// Iterate user's function over the attributes of this object.
int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL, void* op_data = NULL);
// Returns the object header version of an object
unsigned objVersion() const;
// Determines the number of attributes belong to this object.
int getNumAttrs() const;
@ -106,12 +109,12 @@ class H5_DLLCPP H5Object : public H5Location {
// Default constructor
H5Object();
// *** Deprecation warning ***
// The following two constructors are no longer appropriate after the
// data member "id" had been moved to the sub-classes.
// The copy constructor is a noop and is removed in 1.8.15 and the
// other will be removed from 1.10 release, and then from 1.8 if its
// removal does not raise any problems in two 1.10 releases.
// *** Deprecation warning ***
// The following two constructors are no longer appropriate after the
// data member "id" had been moved to the sub-classes.
// The copy constructor is a noop and is removed in 1.8.15 and the
// other will be removed from 1.10 release, and then from 1.8 if its
// removal does not raise any problems in two 1.10 releases.
// Creates a copy of an existing object giving the object id
H5Object( const hid_t object_id );
@ -119,9 +122,9 @@ class H5_DLLCPP H5Object : public H5Location {
// Copy constructor: makes copy of an H5Object object.
// H5Object(const H5Object& original);
// Sets the identifier of this object to a new value. - this one
// doesn't increment reference count
virtual void p_setId(const hid_t new_id) = 0;
// Sets the identifier of this object to a new value. - this one
// doesn't increment reference count
virtual void p_setId(const hid_t new_id) = 0;
// Noop destructor.
virtual ~H5Object();

View File

@ -21,6 +21,7 @@
#include "H5PropList.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -22,6 +22,7 @@
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5DxferProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -21,6 +21,7 @@
#include "H5PropList.h"
#include "H5OcreatProp.h"
#include "H5DcreatProp.h"
#include "H5LaccProp.h"
#include "H5Location.h"
#include "H5Object.h"
#include "H5DataType.h"

View File

@ -33,25 +33,28 @@ libhdf5_cpp_la_LDFLAGS= -version-info $(LT_CXX_VERS_INTERFACE):$(LT_CXX_VERS_REV
bin_SCRIPTS=h5c++
# Source files for the library
libhdf5_cpp_la_SOURCES=H5Exception.cpp H5IdComponent.cpp H5Library.cpp \
H5Attribute.cpp H5Location.cpp H5Object.cpp H5PropList.cpp \
H5FaccProp.cpp H5FcreatProp.cpp H5DcreatProp.cpp H5DxferProp.cpp \
H5OcreatProp.cpp H5DataType.cpp H5DataSpace.cpp H5AbstractDs.cpp \
H5AtomType.cpp H5PredType.cpp H5EnumType.cpp H5IntType.cpp \
H5FloatType.cpp H5StrType.cpp H5ArrayType.cpp H5VarLenType.cpp \
H5CompType.cpp H5DataSet.cpp H5CommonFG.cpp H5Group.cpp H5File.cpp
libhdf5_cpp_la_SOURCES=H5Exception.cpp H5IdComponent.cpp \
H5DataSpace.cpp H5PropList.cpp H5Library.cpp \
H5FaccProp.cpp H5FcreatProp.cpp H5LaccProp.cpp \
H5DxferProp.cpp H5DcreatProp.cpp H5Location.cpp \
H5AbstractDs.cpp H5Attribute.cpp H5Object.cpp \
H5OcreatProp.cpp H5DataType.cpp H5AtomType.cpp \
H5PredType.cpp H5EnumType.cpp H5IntType.cpp \
H5FloatType.cpp H5StrType.cpp H5ArrayType.cpp \
H5VarLenType.cpp H5CompType.cpp H5DataSet.cpp \
H5CommonFG.cpp H5Group.cpp H5File.cpp
# HDF5 C++ library depends on HDF5 Library.
libhdf5_cpp_la_LIBADD=$(LIBHDF5)
# Public headers
include_HEADERS=H5Cpp.h H5AbstractDs.h H5AtomType.h H5Attribute.h H5Classes.h \
H5CommonFG.h H5CompType.h H5DataSet.h H5DataSpace.h H5DataType.h \
H5OcreatProp.h H5DcreatProp.h H5DxferProp.h H5EnumType.h \
H5CommonFG.h H5CompType.h H5DataSet.h H5DataSpace.h H5DataType.h \
H5OcreatProp.h H5DcreatProp.h H5DxferProp.h H5EnumType.h \
H5Exception.h H5FaccProp.h H5FcreatProp.h H5File.h H5FloatType.h \
H5Group.h H5IdComponent.h H5Include.h H5IntType.h H5Library.h \
H5Location.h H5Object.h H5PredType.h H5PropList.h H5StrType.h \
H5CppDoc.h H5ArrayType.h H5VarLenType.h
H5Group.h H5IdComponent.h H5Include.h H5IntType.h H5LaccProp.h \
H5Library.h H5Location.h H5Object.h H5PredType.h H5PropList.h \
H5StrType.h H5CppDoc.h H5ArrayType.h H5VarLenType.h
# h5c++ and libhdf5.settings are generated during configure. Remove only when
# distclean.

View File

@ -674,8 +674,8 @@ static void test_libver_bounds_real(
*/
Group group = file.createGroup(GROUP1);
obj_version = file.childObjVersion(GROUP1);
verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__);
obj_version = group.objVersion();
verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
group.close(); // close "/G1"
@ -685,8 +685,8 @@ static void test_libver_bounds_real(
*/
group = file.createGroup(SUBGROUP3);
obj_version = group.childObjVersion(SUBGROUP3);
verify_val(obj_version, oh_vers_mod, "H5File::childObjVersion", __LINE__, __FILE__);
obj_version = group.objVersion();
verify_val(obj_version, oh_vers_mod, "Group::objVersion", __LINE__, __FILE__);
group.close(); // close "/G1/G3"

View File

@ -419,10 +419,10 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format)
H5File file(filename, H5F_ACC_RDWR, FileCreatPropList::DEFAULT, fapl);
// Verify link existence
if(H5Lexists(file.getId(), "dset1", H5P_DEFAULT) != TRUE)
throw InvalidActionException("H5Lexists", "dset1 doesn't exist");
if(H5Lexists(file.getId(), "grp1/soft", H5P_DEFAULT) != TRUE)
throw InvalidActionException("H5Lexists", "grp1/soft doesn't exist");
if(file.exists("dset1", LinkAccPropList::DEFAULT) != TRUE)
throw InvalidActionException("H5File::exists", "dset1 doesn't exist");
if(file.exists("grp1/soft", LinkAccPropList::DEFAULT) != TRUE)
throw InvalidActionException("H5File::exists", "grp1/soft doesn't exist");
// Verify link values
H5std_string softlink_val = file.getLinkval("grp1/soft");

View File

@ -41,16 +41,26 @@ const H5std_string GROUP1_2_PATH("/Top Group/Sub-Group 1.2");
const H5std_string DSET_DEFAULT_NAME("default");
const H5std_string DSET_IN_FILE("Dataset in File");
const H5std_string DSET_IN_FILE_PATH("/Dataset in File");
const H5std_string DSET_IN_GRP1("Dataset in Group 1");
const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset in Group 1");
const H5std_string DSET_IN_GRP1_2("Dataset in Group 1.2");
const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset in Group 1.2");
const H5std_string DSET_IN_GRP1("Dataset_in_Group_1");
const H5std_string DSET_IN_GRP1_PATH("/Top Group/Dataset_in_Group_1");
const H5std_string DSET_IN_GRP1_2("Dataset_in_Group_1.2");
const H5std_string DSET_IN_GRP1_2_PATH("/Top Group/Sub-Group 1.2/Dataset_in_Group_1.2");
/*-------------------------------------------------------------------------
* Function: test_get_objname
*
* Purpose: Tests getting object name of groups and datasets.
*
* Description:
* File structure:
* GROUP1
* GROUP1_1
* GROUP1_2
* DSET_IN_GRP1_2
* DSET_IN_GRP1
* DSET_IN_FILE
*
*
* Return: Success: 0
* Failure: -1
*
@ -144,6 +154,82 @@ static void test_get_objname()
}
} // test_get_objname
/*-------------------------------------------------------------------------
* Function: test_existance
*
* Purpose: Tests getting object name of groups and datasets.
*
* Description:
* File structure:
* GROUP1
* GROUP1_1
* GROUP1_2
* DSET_IN_GRP1_2
* DSET_IN_GRP1
* DSET_IN_FILE
*
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Binh-Minh Ribler
* Friday, March 4, 2014
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void test_existance()
{
SUBTEST("H5File::exists and Group::exists");
try {
// Open file
H5File file(FILE_OBJECTS, H5F_ACC_RDONLY);
// Check if GROUP1 exists in the file
bool exists = file.exists(GROUP1);
// Open GROUP1
Group grp1 = file.openGroup(GROUP1);
// Check if GROUP1_1 and GROUP1_2 exist in GROUP1
exists = grp1.exists(GROUP1_1);
verify_val(exists, TRUE, "Group::exists GROUP1_1", __LINE__, __FILE__);
exists = grp1.exists(GROUP1_2);
verify_val(exists, TRUE, "Group::exists GROUP1_2", __LINE__, __FILE__);
// Check if DSET_IN_GRP1 exists in GROUP1
exists = grp1.exists(DSET_IN_GRP1);
verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1", __LINE__, __FILE__);
// Open GROUP1_2
Group grp1_2 = grp1.openGroup(GROUP1_2);
// Check if DSET_IN_GRP1_2 exists in GROUP1_2
exists = grp1_2.exists(DSET_IN_GRP1_2);
verify_val(exists, TRUE, "Group::exists DSET_IN_GRP1_2", __LINE__, __FILE__);
// Check if a dataset exists given dataset as location with full path name
DataSet dset1 = file.openDataSet(DSET_IN_FILE);
exists = dset1.exists("/Top Group/Dataset_in_Group_1");
verify_val(exists, TRUE, "Group::exists given dataset with full path name", __LINE__, __FILE__);
exists = grp1_2.exists(DSET_IN_GRP1);
verify_val(exists, FALSE, "Group::exists DSET_IN_GRP1", __LINE__, __FILE__);
// Everything will be closed as they go out of scope
PASSED();
} // try block
// catch all other exceptions
catch (Exception& E)
{
issue_fail_msg("test_existance", __LINE__, __FILE__);
}
} // test_existance
/*-------------------------------------------------------------------------
* Function: test_get_objname_ontypes
*
@ -176,21 +262,20 @@ static void test_get_objname_ontypes()
// Close the type then open it again to test getting its name
inttype.close();
inttype = file.openIntType("INT type of STD_B8LE");
inttype = file.openIntType("INT type of STD_B8LE"); // deprecated
// Get and verify its name
H5std_string inttype_name = inttype.getObjName();
verify_val(inttype_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
// Close the type then open it again to test getting its name with
// the constructor
// Close the type then open it again to test getting its name, but
// with the constructor this time
inttype.close();
IntType newtype(file, "INT type of STD_B8LE");
IntType std_b8le(file, "INT type of STD_B8LE");
// Get and verify its name
H5std_string type_name = newtype.getObjName();
verify_val(type_name, "/INT type of STD_B8LE", "DataType::getObjName tests constructor", __LINE__, __FILE__);
newtype.close();
H5std_string std_b8le_name = std_b8le.getObjName();
verify_val(std_b8le_name, "/INT type of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
// Make copy of a predefined type and save it
DataType dtype(PredType::STD_B8LE);
@ -202,22 +287,22 @@ static void test_get_objname_ontypes()
// Re-open the file and the data type to test getting its name
file.openFile(FILE_OBJECTS, H5F_ACC_RDWR);
dtype = file.openDataType("STD_B8LE");
dtype = file.openDataType("STD_B8LE"); // deprecated
// Get and verify its name
type_name = dtype.getObjName();
H5std_string type_name = dtype.getObjName();
verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
// Repeat the test with openDataType's replacement
// Close the type and open it again with the constructor then test
// getting its name
dtype.close();
DataType dtype2(file, "STD_B8LE");
// Get and verify its name
type_name = dtype2.getObjName();
verify_val(type_name, "/STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
// Test getting type's name from copied type
DataType copied_type;
copied_type.copy(dtype);
copied_type.copy(dtype2);
copied_type.commit(file, "copy of STD_B8LE");
type_name = copied_type.getObjName();
verify_val(type_name, "/copy of STD_B8LE", "DataType::getObjName", __LINE__, __FILE__);
@ -232,7 +317,7 @@ static void test_get_objname_ontypes()
verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__);
// Close everything or they can be closed when objects go out of scope
dtype.close();
dtype2.close();
copied_type.close();
new_int_type.close();
grp.close();
@ -333,6 +418,7 @@ void test_object()
MESSAGE(5, ("Testing Object Functions\n"));
test_get_objname(); // Test get object name from groups/datasets
test_existance(); // Test check for object existance
test_get_objname_ontypes(); // Test get object name from types
test_get_objtype(); // Test get object type

View File

@ -257,28 +257,35 @@ static void test_query()
tid2.close();
// Open the datatypes for query
// Deprecated functions
tid1 = file.openCompType(CompT_NAME);
tid1.close();
tid2 = file.openEnumType(EnumT_NAME);
tid2.close();
CompType comptype(file, CompT_NAME);
EnumType enumtype(file, EnumT_NAME);
// Query member number and member index by name, for compound type
nmembs = tid1.getNmembers();
nmembs = comptype.getNmembers();
verify_val(nmembs, 4, "CompType::getNmembers()", __LINE__, __FILE__);
index = tid1.getMemberIndex("c");
index = comptype.getMemberIndex("c");
verify_val(index, 2, "CompType::getMemberIndex()", __LINE__, __FILE__);
// Query member number and member index by name, for enumeration type
nmembs = tid2.getNmembers();
nmembs = enumtype.getNmembers();
verify_val(nmembs, 5, "EnumType::getNmembers()", __LINE__, __FILE__);
index = tid2.getMemberIndex("ORANGE");
index = enumtype.getMemberIndex("ORANGE");
verify_val(index, 3, "EnumType::getMemberIndex()", __LINE__, __FILE__);
// Close datatypes and file
tid1.close();
tid2.close();
comptype.close();
enumtype.close();
file.close();
// Try truncating the file to make sure reference counting is good.
// If any references to ids of tid1 and tid2 are left unterminated,
// If any references to ids of the accessed types are left unterminated,
// the truncating will fail, because the file will not be closed in
// the file.close() above.
H5File file1(FILENAME[2], H5F_ACC_TRUNC);

View File

@ -479,10 +479,14 @@ static void test_vlstring_type()
vlst.close();
// Try opening datatype again.
vlst = file1->openStrType(VLSTR_TYPE);
vlst = file1->openStrType(VLSTR_TYPE); // deprecated
// Close again and reopen with constructor.
vlst.close();
StrType vlst1(*file1, VLSTR_TYPE);
// Close datatype and file.
vlst.close();
vlst1.close();
file1->close();
delete file1;
@ -490,16 +494,16 @@ static void test_vlstring_type()
file1 = new H5File(FILENAME, H5F_ACC_RDWR);
// Open the variable-length string datatype just created
vlst = file1->openStrType(VLSTR_TYPE);
StrType vlst2(*file1, VLSTR_TYPE);
// Verify character set and padding
cset = vlst.getCset();
cset = vlst2.getCset();
verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__);
pad = vlst.getStrpad();
pad = vlst2.getStrpad();
verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__);
// Close datatype and file
vlst.close();
vlst2.close();
file1->close();
PASSED();