diff options
Diffstat (limited to 'c++')
-rw-r--r-- | c++/src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5ArrayType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5AtomType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5Attribute.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5CommonFG.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5CompType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5Cpp.h | 1 | ||||
-rw-r--r-- | c++/src/H5DataSet.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.cpp | 7 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.h | 2 | ||||
-rw-r--r-- | c++/src/H5EnumType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5FloatType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5IntType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5Library.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5Location.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5Object.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5OcreatProp.cpp | 222 | ||||
-rw-r--r-- | c++/src/H5OcreatProp.h | 76 | ||||
-rw-r--r-- | c++/src/H5StrType.cpp | 1 | ||||
-rw-r--r-- | c++/src/H5VarLenType.cpp | 1 | ||||
-rw-r--r-- | c++/src/Makefile.am | 18 | ||||
-rw-r--r-- | c++/src/Makefile.in | 28 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 285 |
27 files changed, 614 insertions, 45 deletions
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 1ae5647..473605a 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -35,6 +35,7 @@ set (CPP_SRCS ${HDF5_CPP_SRC_SOURCE_DIR}/H5Library.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5Location.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5Object.cpp + ${HDF5_CPP_SRC_SOURCE_DIR}/H5OcreatProp.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5PredType.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5PropList.cpp ${HDF5_CPP_SRC_SOURCE_DIR}/H5StrType.cpp @@ -70,6 +71,7 @@ set (CPP_HDRS ${HDF5_CPP_SRC_SOURCE_DIR}/H5Library.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5Location.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5Object.h + ${HDF5_CPP_SRC_SOURCE_DIR}/H5OcreatProp.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5PredType.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5PropList.h ${HDF5_CPP_SRC_SOURCE_DIR}/H5StrType.h diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index d59c1eb..5929444 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -22,6 +22,7 @@ #include "H5Object.h" #include "H5AbstractDs.h" #include "H5DataSpace.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5Alltypes.h" diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 8807dca..85340f8 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 09f762f..90c2ae3 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 5a47dac..6705739 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -28,6 +28,7 @@ #include "H5AbstractDs.h" #include "H5FaccProp.h" #include "H5FcreatProp.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index c7f25f1..a482fc2 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -22,6 +22,7 @@ #include "H5Object.h" #include "H5FaccProp.h" #include "H5FcreatProp.h" +#include "H5OcreatProp.h" #include "H5DxferProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 393aafc..6d31a68 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5Alltypes.h" diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 044108b..4e82ee3 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -26,6 +26,7 @@ #include "H5Object.h" #include "H5AbstractDs.h" #include "H5Attribute.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index b134d39..9497a08 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -26,6 +26,7 @@ #include "H5PropList.h" #include "H5Object.h" #include "H5PropList.h" +#include "H5OcreatProp.h" #include "H5DxferProp.h" #include "H5DcreatProp.h" #include "H5FaccProp.h" diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index dfed3c1..47aaa14 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -28,6 +28,7 @@ #include "H5Object.h" #include "H5FaccProp.h" #include "H5FcreatProp.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5DxferProp.h" #include "H5CommonFG.h" diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index 5ee212a..60cf0fc 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -19,6 +19,7 @@ #include "H5Exception.h" #include "H5IdComponent.h" #include "H5PropList.h" +#include "H5OcreatProp.h" #include "H5Object.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" @@ -91,7 +92,7 @@ const DSetCreatPropList& DSetCreatPropList::DEFAULT = *getConstant(); ///\brief Default constructor: creates a stub dataset creation property list // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList() : PropList( H5P_DATASET_CREATE) {} +DSetCreatPropList::DSetCreatPropList() : ObjCreatPropList(H5P_DATASET_CREATE) {} //-------------------------------------------------------------------------- // Function: DSetCreatPropList copy constructor @@ -99,7 +100,7 @@ DSetCreatPropList::DSetCreatPropList() : PropList( H5P_DATASET_CREATE) {} /// DSetCreatPropList object // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList( const DSetCreatPropList& orig ) : PropList( orig ) {} +DSetCreatPropList::DSetCreatPropList( const DSetCreatPropList& orig ) : ObjCreatPropList(orig) {} //-------------------------------------------------------------------------- // Function: DSetCreatPropList overloaded constructor @@ -107,7 +108,7 @@ DSetCreatPropList::DSetCreatPropList( const DSetCreatPropList& orig ) : PropList /// existing dataset creation property list. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : PropList(plist_id) {} +DSetCreatPropList::DSetCreatPropList(const hid_t plist_id) : ObjCreatPropList(plist_id) {} //-------------------------------------------------------------------------- // Function: DSetCreatPropList::setChunk diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index d36eec3..792956a 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -28,7 +28,7 @@ namespace H5 { \brief Class DSetCreatPropList represents the dataset creation property list. */ -class H5_DLLCPP DSetCreatPropList : public PropList { +class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList { public: ///\brief Default dataset creation property list. static const DSetCreatPropList& DEFAULT; diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index a91c053..b096a36 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -23,6 +23,7 @@ #include "H5AbstractDs.h" #include "H5DxferProp.h" #include "H5DataSpace.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 83d3413..b169472 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -27,6 +27,7 @@ #include "H5Object.h" #include "H5FaccProp.h" #include "H5FcreatProp.h" +#include "H5OcreatProp.h" #include "H5DxferProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp index 784e419..cdf9872 100644 --- a/c++/src/H5FloatType.cpp +++ b/c++/src/H5FloatType.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index fd04f1a..174dd1e 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -28,6 +28,7 @@ #include "H5AbstractDs.h" #include "H5FaccProp.h" #include "H5FcreatProp.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5DxferProp.h" #include "H5DataSpace.h" diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp index a884829..5719eed 100644 --- a/c++/src/H5IntType.cpp +++ b/c++/src/H5IntType.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index 31856ec..e7e9fb6 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -23,6 +23,7 @@ #include "H5PropList.h" #include "H5FaccProp.h" #include "H5FcreatProp.h" +#include "H5OcreatProp.h" #include "H5DxferProp.h" #include "H5Object.h" #include "H5DataType.h" diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 226be22..30a7bc5 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -21,6 +21,7 @@ #include "H5PropList.h" #include "H5Location.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5DxferProp.h" #include "H5FaccProp.h" diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index df3f565..35e34b5 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5DxferProp.h" #include "H5FaccProp.h" diff --git a/c++/src/H5OcreatProp.cpp b/c++/src/H5OcreatProp.cpp new file mode 100644 index 0000000..635ffe9 --- /dev/null +++ b/c++/src/H5OcreatProp.cpp @@ -0,0 +1,222 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 "H5FaccProp.h" +#include "H5OcreatProp.h" + +#ifndef H5_NO_NAMESPACE +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 +ObjCreatPropList* ObjCreatPropList::DEFAULT_ = 0; + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList::getConstant +// Creates a ObjCreatPropList object representing the HDF5 constant +// H5P_FILE_ACCESS, pointed to by ObjCreatPropList::DEFAULT_ +// exception H5::PropListIException +// Description +// If ObjCreatPropList::DEFAULT_ already points to an allocated +// object, throw a PropListIException. This scenario should not +// happen. +// Programmer Binh-Minh Ribler - 2015 +//-------------------------------------------------------------------------- +ObjCreatPropList* ObjCreatPropList::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 ObjCreatPropList(H5P_OBJECT_CREATE); + else + throw PropListIException("ObjCreatPropList::getConstant", "ObjCreatPropList::getConstant is being invoked on an allocated DEFAULT_"); + return(DEFAULT_); +} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList::deleteConstants +// Purpose: Deletes the constant object that ObjCreatPropList::DEFAULT_ +// points to. +// exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2015 +//-------------------------------------------------------------------------- +void ObjCreatPropList::deleteConstants() +{ + if (DEFAULT_ != 0) + delete DEFAULT_; +} + +//-------------------------------------------------------------------------- +// Purpose: Constant for default property +//-------------------------------------------------------------------------- +const ObjCreatPropList& ObjCreatPropList::DEFAULT = *getConstant(); + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +//-------------------------------------------------------------------------- +// Function: Default Constructor +///\brief Creates a file access property list +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +ObjCreatPropList::ObjCreatPropList() : PropList(H5P_OBJECT_CREATE) {} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList copy constructor +///\brief Copy Constructor: makes a copy of the original +///\param original - IN: ObjCreatPropList instance to copy +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +ObjCreatPropList::ObjCreatPropList(const ObjCreatPropList& original) : PropList(original) {} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList overloaded constructor +///\brief Creates a file access property list using the id of an +/// existing one. +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +ObjCreatPropList::ObjCreatPropList(const hid_t plist_id) : PropList(plist_id) {} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList::setAttrPhaseChange +///\brief Sets attribute storage phase change thresholds. +///\param max_compact - IN: Maximum number of attributes to be stored in +/// compact storage. Default to 8 +///\param min_dense - IN: Minimum number of attributes to be stored in +/// dense storage. Default to 6 +///\exception H5::PropListIException +///\par Description +/// If \c max_compact is set to 0, dense storage will be used. +/// For more detail about on attribute storage, please refer to the +/// C layer Reference Manual at: +/// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetAttrPhaseChange +// Programmer: Binh-Minh Ribler - September 2015 +//-------------------------------------------------------------------------- +void ObjCreatPropList::setAttrPhaseChange(unsigned max_compact, unsigned min_dense) const +{ + herr_t ret_value = H5Pset_attr_phase_change(id, max_compact, min_dense); + if (ret_value < 0) + { + throw PropListIException("ObjCreatPropList::setAttrPhaseChange", "H5Pset_attr_phase_change failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList::getAttrPhaseChange +///\brief Gets attribute storage phase change thresholds. +///\param max_compact - OUT: Maximum number of attributes to be stored in +/// compact storage. +///\param min_dense - OUT: Minimum number of attributes to be stored in +/// dense storage. +///\exception H5::PropListIException +///\par Description +/// If \c max_compact is set to 0, dense storage will be used. +/// For more detail about on attribute storage, please refer to the +/// C layer Reference Manual at: +/// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetAttrPhaseChange +// Programmer: Binh-Minh Ribler - September 2015 +//-------------------------------------------------------------------------- +void ObjCreatPropList::getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const +{ + herr_t ret_value; + ret_value = H5Pget_attr_phase_change(id, &max_compact, &min_dense); + if (ret_value < 0) + { + throw PropListIException("ObjCreatPropList::getAttrPhaseChange", "H5Pget_attr_phase_change failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList::setAttrCrtOrder +///\brief Sets tracking and indexing of attribute creation order. +///\param crt_order_flags - IN: Flags specifying whether to track and +/// index attribute creation order. Default: No flag set +///\exception H5::PropListIException +///\par Description +/// Valid flags are: +/// \li \c H5P_CRT_ORDER_TRACKED - Attribute creation order is tracked +/// \li \c H5P_CRT_ORDER_INDEXED - Attribute creation order is +/// indexed (requires H5P_CRT_ORDER_TRACKED). +/// When no flag is set, attribute creation order is neither +/// tracked not indexed. Note that HDF5 currently provides no +/// mechanism to turn on attribute creation order tracking at object +/// creation time and to build the index later. +/// The C layer Reference Manual at can be found at: +/// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-SetAttrCreationOrder +// Programmer: Binh-Minh Ribler - September 2015 +//-------------------------------------------------------------------------- +void ObjCreatPropList::setAttrCrtOrder(unsigned crt_order_flags) const +{ + herr_t ret_value = H5Pset_attr_creation_order(id, crt_order_flags); + if (ret_value < 0) + { + throw PropListIException("ObjCreatPropList::setAttrCrtOrder", "H5Pset_attr_creation_order failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList::getAttrCrtOrder +///\brief Gets tracking and indexing settings for attribute +/// creation order. +///\param crt_order_flags - OUT: Flags specifying whether to track and +/// index attribute creation order +///\exception H5::PropListIException +///\par Description +/// When no flag is set, i.e. crt_order_flags = 0, attribute +/// creation order is neither tracked not indexed. +/// The C layer Reference Manual at can be found at: +/// https://www.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-GetAttrCreationOrder +// Programmer: Binh-Minh Ribler - September 2015 +//-------------------------------------------------------------------------- +unsigned ObjCreatPropList::getAttrCrtOrder() const +{ + herr_t ret_value; + unsigned crt_order_flags = 0; + ret_value = H5Pget_attr_creation_order(id, &crt_order_flags); + if (ret_value < 0) + { + throw PropListIException("ObjCreatPropList::getAttrCrtOrder", "H5Pget_attr_creation_order failed"); + } + return(crt_order_flags); +} + +//-------------------------------------------------------------------------- +// Function: ObjCreatPropList destructor +///\brief Noop destructor +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +ObjCreatPropList::~ObjCreatPropList() {} + +#ifndef H5_NO_NAMESPACE +} // end namespace +#endif diff --git a/c++/src/H5OcreatProp.h b/c++/src/H5OcreatProp.h new file mode 100644 index 0000000..0fda34d --- /dev/null +++ b/c++/src/H5OcreatProp.h @@ -0,0 +1,76 @@ +// 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef __H5ObjCreatPropList_H +#define __H5ObjCreatPropList_H + +#ifndef H5_NO_NAMESPACE +namespace H5 { +#endif + +//! Class ObjCreatPropList represents the HDF5 object creation property list. +class H5_DLLCPP ObjCreatPropList : public PropList { + public: + ///\brief Default object creation property list. + static const ObjCreatPropList& DEFAULT; + + // Creates a object creation property list. + ObjCreatPropList(); + + // Sets attribute storage phase change thresholds. + void setAttrPhaseChange(unsigned max_compact = 8, unsigned min_dense = 6) const; + + // Gets attribute storage phase change thresholds. + void getAttrPhaseChange(unsigned& max_compact, unsigned& min_dense) const; + + // Sets tracking and indexing of attribute creation order. + void setAttrCrtOrder(unsigned crt_order_flags) const; + + // Gets tracking and indexing settings for attribute creation order. + unsigned getAttrCrtOrder() const; + + + ///\brief Returns this class name. + virtual H5std_string fromClass () const { return("ObjCreatPropList"); } + + // Copy constructor: creates a copy of a ObjCreatPropList object. + ObjCreatPropList( const ObjCreatPropList& original ); + + // Creates a copy of an existing object creation property list + // using the property list id. + ObjCreatPropList (const hid_t plist_id); + + // Noop destructor + virtual ~ObjCreatPropList(); + +#ifndef DOXYGEN_SHOULD_SKIP_THIS + + // Deletes the global constant, should only be used by the library + static void deleteConstants(); + + private: + static ObjCreatPropList* DEFAULT_; + + // Creates the global constant, should only be used by the library + static ObjCreatPropList* getConstant(); + +#endif // DOXYGEN_SHOULD_SKIP_THIS + +}; +#ifndef H5_NO_NAMESPACE +} +#endif +#endif // __H5ObjCreatPropList_H diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index 5195bba..b067746 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/H5VarLenType.cpp b/c++/src/H5VarLenType.cpp index 3641a5d..2fab1f3 100644 --- a/c++/src/H5VarLenType.cpp +++ b/c++/src/H5VarLenType.cpp @@ -20,6 +20,7 @@ #include "H5IdComponent.h" #include "H5PropList.h" #include "H5Object.h" +#include "H5OcreatProp.h" #include "H5DcreatProp.h" #include "H5CommonFG.h" #include "H5DataType.h" diff --git a/c++/src/Makefile.am b/c++/src/Makefile.am index cdef7bf..84af348 100644 --- a/c++/src/Makefile.am +++ b/c++/src/Makefile.am @@ -36,10 +36,10 @@ bin_SCRIPTS=h5c++ 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 \ - 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 + 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 # HDF5 C++ library depends on HDF5 Library. libhdf5_cpp_la_LIBADD=$(LIBHDF5) @@ -47,11 +47,11 @@ 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 \ - 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 + 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 # h5c++ and libhdf5.settings are generated during configure. Remove only when # distclean. diff --git a/c++/src/Makefile.in b/c++/src/Makefile.in index c4ebc2f..9a10306 100644 --- a/c++/src/Makefile.in +++ b/c++/src/Makefile.in @@ -148,10 +148,11 @@ libhdf5_cpp_la_DEPENDENCIES = $(LIBHDF5) am_libhdf5_cpp_la_OBJECTS = H5Exception.lo H5IdComponent.lo \ H5Library.lo H5Attribute.lo H5Location.lo H5Object.lo \ H5PropList.lo H5FaccProp.lo H5FcreatProp.lo H5DcreatProp.lo \ - H5DxferProp.lo H5DataType.lo H5DataSpace.lo H5AbstractDs.lo \ - H5AtomType.lo H5PredType.lo H5EnumType.lo H5IntType.lo \ - H5FloatType.lo H5StrType.lo H5ArrayType.lo H5VarLenType.lo \ - H5CompType.lo H5DataSet.lo H5CommonFG.lo H5Group.lo H5File.lo + H5DxferProp.lo H5OcreatProp.lo H5DataType.lo H5DataSpace.lo \ + H5AbstractDs.lo H5AtomType.lo H5PredType.lo H5EnumType.lo \ + H5IntType.lo H5FloatType.lo H5StrType.lo H5ArrayType.lo \ + H5VarLenType.lo H5CompType.lo H5DataSet.lo H5CommonFG.lo \ + H5Group.lo H5File.lo libhdf5_cpp_la_OBJECTS = $(am_libhdf5_cpp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -684,10 +685,10 @@ bin_SCRIPTS = h5c++ 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 \ - 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 + 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 # HDF5 C++ library depends on HDF5 Library. @@ -696,11 +697,11 @@ 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 \ - 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 + 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 # h5c++ and libhdf5.settings are generated during configure. Remove only when @@ -869,6 +870,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Library.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Location.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Object.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5OcreatProp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5PredType.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5PropList.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5StrType.Plo@am__quote@ diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 275a287..0fefe22 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -1570,6 +1570,198 @@ static void test_attr_exists() /**************************************************************** ** +** test_attr_dense_create(): Test phase change properties +** Tests "dense" attribute storage creation +** +****************************************************************/ +const H5std_string FILE_CRTPROPS("tattr_crt_properties.h5"); +const int NAME_BUF_SIZE = 1024; +const unsigned MAX_COMPACT_DEF = 8; +const unsigned MIN_DENSE_DEF = 6; + +static void test_attr_dense_create(FileCreatPropList& fcpl, + FileAccPropList& fapl) +{ + // Output message about test being performed + SUBTEST("Dense Attribute Storage Creation"); + + try { + // Create file + H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + + // Close file + fid1.close(); + + // Get size of file + h5_stat_size_t empty_filesize; // Size of empty file + empty_filesize = h5_get_file_size(FILE_CRTPROPS.c_str(), fapl.getId()); + if (empty_filesize < 0) + TestErrPrintf("Line %d: file size wrong!\n", __LINE__); + + // Re-open file + fid1.openFile(FILE_CRTPROPS, H5F_ACC_RDWR, fapl); + + // Create dataspace for dataset + DataSpace ds_space(H5S_SCALAR); + + // Create dataset creation property list. + DSetCreatPropList dcpl; + + // Create a dataset + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space, dcpl); + + unsigned max_compact = 0, min_dense = 0; + + // Retrieve limits for compact/dense attribute storage + dcpl.getAttrPhaseChange(max_compact, min_dense); + verify_val(max_compact, MAX_COMPACT_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(min_dense, MIN_DENSE_DEF, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + + // Set new compact/dense attribute storage limits to some random numbers + dcpl.setAttrPhaseChange(7, 5); + + // Retrieve limits for compact/dense attribute storage and verify them + dcpl.getAttrPhaseChange(max_compact, min_dense); + verify_val(max_compact, 7, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(min_dense, 5, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + + // Close property list + dcpl.close(); + + // H5O_is_attr_dense_test - un-usable + + // Add attributes, until just before converting to dense storage + char attr_name[NAME_BUF_SIZE]; + unsigned attr_num; + for (attr_num = 0; attr_num < max_compact; attr_num++) + { + // Create attribute + sprintf(attr_name, "attr %02u", attr_num); + Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); + + // Write data to the attribute + attr.write(PredType::NATIVE_UINT, &attr_num); + } // end for + + // H5O_is_attr_dense_test - un-usable + + { // Add one more attribute, to push into "dense" storage + + // Create another attribute + sprintf(attr_name, "attr %02u", attr_num); + Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); + + // Write data to the attribute + attr.write(PredType::NATIVE_UINT, &attr_num); + } + + // Attempt to add attribute again, which should fail + try + { + // Create another attribute + sprintf(attr_name, "attr %02u", attr_num); + Attribute attr = dataset.createAttribute(attr_name, PredType::NATIVE_UINT, ds_space); + + // continuation here, that means no exception has been thrown + throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); + } + catch (AttributeIException E) // catching invalid action + {} // do nothing, exception expected + + PASSED(); + } // end try block + + catch (Exception E) { + issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_attr_dense_create() + +/**************************************************************** +** +** test_attr_corder_create_basic(): Test creation order properties +** Tests creating an object w/attribute creation order info +** +****************************************************************/ +static void test_attr_corder_create_basic(FileCreatPropList& fcpl, + FileAccPropList& fapl) +{ + // Output message about test being performed + SUBTEST("Basic Code for Attributes with Creation Order Info"); + + try { + // Create file + H5File fid1 (FILE_CRTPROPS, H5F_ACC_TRUNC, fcpl, fapl); + + // Create dataset creation property list. + DSetCreatPropList dcpl; + + // Get creation order indexing on object + unsigned crt_order_flags = 0; + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, 0, "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + + // Setting invalid combination of a attribute order creation order + // indexing on should fail + try { + dcpl.setAttrCrtOrder(H5P_CRT_ORDER_INDEXED); + + // continuation here, that means no exception has been thrown + throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); + } + catch (PropListIException E) // catching invalid action + {} // do nothing, exception expected + + // Set attribute creation order tracking & indexing for object then + // verify them + dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + + // Create dataspace for dataset + DataSpace ds_space(H5S_SCALAR); + + // Create a dataset + DataSet dataset = fid1.createDataSet(DSET1_NAME, PredType::NATIVE_UCHAR, ds_space, dcpl); + + // Close dataspace + ds_space.close(); + + // Check on dataset's attribute storage status. + // NOTE: Wrappers not available yet (H5O_is_attr_empty_test + // and H5O_is_attr_dense_test) + + // Close dataset + dataset.close(); + + // Close property list + dcpl.close(); + + // Close file + fid1.close(); + + // Re-open file + fid1.openFile(FILE_CRTPROPS, H5F_ACC_RDWR, fapl); + + // Open dataset created previously + dataset = fid1.openDataSet(DSET1_NAME); + + // Retrieve dataset creation property list for the dataset + dcpl = dataset.getCreatePlist(); + + // Query the attribute creation properties + crt_order_flags = dcpl.getAttrCrtOrder(); + verify_val(crt_order_flags, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED), "DSetCreatPropList::getAttrCrtOrder",__LINE__,__FILE__); + + PASSED(); + } // end try block + + catch (Exception E) { + issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); + } +} // test_attr_corder_create_basic() + +/**************************************************************** +** ** test_attr(): Main attribute testing routine. ** ****************************************************************/ @@ -1582,26 +1774,80 @@ void test_attr() //MESSAGE("Testing Attributes\n"); MESSAGE(5, ("Testing Attributes\n")); - test_attr_basic_write(); // Test basic H5A writing code - test_attr_getname(); // Test overloads of Attribute::getName - test_attr_rename(); // Test renaming attribute - test_attr_basic_read(); // Test basic H5A reading code - - test_attr_compound_write(); // Test complex datatype H5A writing code - test_attr_compound_read(); // Test complex datatype H5A reading code - - test_attr_scalar_write(); // Test scalar dataspace H5A writing code - test_attr_scalar_read(); // Test scalar dataspace H5A reading code - - test_attr_mult_write(); // Test writing multiple attributes - test_attr_mult_read(); // Test reading multiple attributes - test_attr_delete(); // Test deleting attributes - - test_attr_dtype_shared(); // Test using shared datatypes in attributes - - test_string_attr(); // Test read/write string attribute - test_attr_exists(); // Test H5Location::attrExists + try + { + // Create a default file access property list + FileAccPropList fapl; + + // Copy the file access property list for new format test + FileAccPropList fapl_new = fapl; + + // Set the "use the latest version of the format" bounds for creating + // objects in the file + fapl_new.setLibverBounds(H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + + // Create a default file creation property list + FileCreatPropList fcpl; + + // Copy the file creation property list for new format test + FileCreatPropList fcpl_new = fcpl; + + // Wrappers for ..._shared_mesg_nindexes are not available, skip + // use_shared test + + // Loop over using new group format + hbool_t new_format; + for (new_format = FALSE; new_format <= TRUE; new_format++) + { + FileAccPropList curr_fapl; + + // Set the file access proplist for the type of format + if (new_format) + { + MESSAGE(7, ("testing with new file format\n")); + curr_fapl = fapl_new; + } + else + { + MESSAGE(7, ("testing with old file format\n")); + curr_fapl = fapl; + } + + test_attr_basic_write(); // Test basic H5A writing code + test_attr_getname(); // Test overloads of Attribute::getName + test_attr_rename(); // Test renaming attribute + test_attr_basic_read(); // Test basic H5A reading code + + test_attr_compound_write(); // Test complex datatype H5A writing code + test_attr_compound_read(); // Test complex datatype H5A reading code + + test_attr_scalar_write(); // Test scalar dataspace H5A writing code + test_attr_scalar_read(); // Test scalar dataspace H5A reading code + + test_attr_mult_write(); // Test writing multiple attributes + test_attr_mult_read(); // Test reading multiple attributes + test_attr_delete(); // Test deleting attributes + + test_attr_dtype_shared(); // Test using shared datatypes in attributes + + test_string_attr(); // Test read/write string attribute + test_attr_exists(); // Test H5Location::attrExists + + // Test with new format + if (new_format) + { + // Test dense attribute storage creation + test_attr_dense_create(fcpl, curr_fapl); + + // Test create objects with attribute creation info + test_attr_corder_create_basic(fcpl, curr_fapl); + } + } // end for + } // end try block + catch (Exception E) { + issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); + } } // test_attr() /*------------------------------------------------------------------------- @@ -1628,5 +1874,6 @@ void cleanup_attr() HDremove(FILE_SCALAR.c_str()); HDremove(FILE_MULTI.c_str()); HDremove(FILE_DTYPE.c_str()); + HDremove(FILE_CRTPROPS.c_str()); } |