diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2004-07-11 05:27:00 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2004-07-11 05:27:00 (GMT) |
commit | 10bae2c87537acf666400278849763bd07e239a9 (patch) | |
tree | 63845948e9a83f793a65cbe748533824558060b0 | |
parent | 83ff4069fde3d5ab11fbae80eb260278fcf721a5 (diff) | |
download | hdf5-10bae2c87537acf666400278849763bd07e239a9.zip hdf5-10bae2c87537acf666400278849763bd07e239a9.tar.gz hdf5-10bae2c87537acf666400278849763bd07e239a9.tar.bz2 |
[svn-r8857] Purpose: Adding more C++ wrappers and documentation
Description:
Added documentation and C++ wrappers for many C APIs to:
H5PropList.*
H5FaccProp.*
H5DcreatProp.*
H5DxferProp.*
H5DataType.*
H5Group.*
Tests will follow soon.
Platforms tested:
SunOS 5.7 (arabica)
Linux 2.4 (eirene)
-rw-r--r-- | c++/src/H5DataSpace.cpp | 3 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 406 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 20 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.cpp | 477 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.h | 36 | ||||
-rw-r--r-- | c++/src/H5DxferProp.cpp | 344 | ||||
-rw-r--r-- | c++/src/H5DxferProp.h | 67 | ||||
-rw-r--r-- | c++/src/H5FaccProp.cpp | 592 | ||||
-rw-r--r-- | c++/src/H5FaccProp.h | 127 | ||||
-rw-r--r-- | c++/src/H5FcreatProp.cpp | 142 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 174 | ||||
-rw-r--r-- | c++/src/H5Group.h | 18 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 473 | ||||
-rw-r--r-- | c++/src/H5PropList.h | 37 |
14 files changed, 2543 insertions, 373 deletions
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 6b338e2..9f35f13 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -30,6 +30,9 @@ namespace H5 { #endif +//-------------------------------------------------------------------------- +///\brief Constant for default dataspace +//-------------------------------------------------------------------------- const DataSpace DataSpace::ALL( H5S_ALL ); //-------------------------------------------------------------------------- diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 290ebb7..28b2cda 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -25,6 +25,7 @@ #include "H5IdComponent.h" #include "H5Idtemplates.h" #include "H5PropList.h" +#include "H5DataSpace.h" #include "H5Object.h" #include "H5DataType.h" #include "H5AtomType.h" @@ -35,14 +36,31 @@ namespace H5 { #endif -// Constructor creates a copy of an existing DataType using its id. -// 'predefined' is default to false; when a default datatype is -// created, this argument is set to true so H5Tclose will not be -// called on it later. -DataType::DataType( const hid_t existing_id, bool predefined ) : H5Object( existing_id ), is_predtype( predefined ) { -} - -// Creates a datatype given its class and size +//-------------------------------------------------------------------------- +// Function: DataType overloaded constructor +///\brief Creates a datatype using an existing datatype's id +///\param existing_id - IN: Id of the existing datatype +///\param predefined - IN: Indicates whether or not this datatype is +/// a predefined datatype; default to \c false +// Description +// Constructor creates a copy of an existing DataType using +// its id. The argument "predefined" is default to false; +// when a default datatype is created, this argument is set +// to true so H5Tclose will not be called on it later. - need +// a reassessment after changing to the new ref counting mech. +// - BMR 5/2004 +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DataType::DataType(const hid_t existing_id, bool predefined) : H5Object(existing_id), is_predtype(predefined) {} + +//-------------------------------------------------------------------------- +// Function: DataType overloaded constructor +///\brief Creates a object given its class and size +///\param type_class - IN: Class of datatype to create +///\param size - IN: Number of bytes in the datatype to create +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object(), is_predtype( false ) { // Call C routine to create the new datatype @@ -53,18 +71,30 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object(), is } } -// Default constructor -DataType::DataType() : H5Object(), is_predtype( false ) -{ -} - -// Copy constructor: makes a copy of this DataType object. -DataType::DataType( const DataType& original ) : H5Object( original ) +//-------------------------------------------------------------------------- +// Function: DataType default constructor +///\brief Default constructor: Creates a stub datatype +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DataType::DataType() : H5Object(), is_predtype( false ) {} + +//-------------------------------------------------------------------------- +// Function: DataType copy constructor +///\brief Copy constructor: makes a copy of the original DataType object. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +DataType::DataType(const DataType& original) : H5Object(original) { is_predtype = original.is_predtype; // copy data member from original } -// Copies an existing datatype to this datatype object +//-------------------------------------------------------------------------- +// Function: DataType::copy +///\brief Copies an existing datatype to this datatype object +///\param like_type - IN: Datatype to be copied +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DataType::copy( const DataType& like_type ) { // reset the identifier of this instance, H5Tclose will be called @@ -87,15 +117,32 @@ void DataType::copy( const DataType& like_type ) } } -// Makes a copy of the type on the right hand side and stores the new -// id in the left hand side object. +//-------------------------------------------------------------------------- +// Function: DataType::operator= +///\brief Assignment operator +///\param rhs - IN: Reference to the existing datatype +///\return Reference to DataType instance +///\exception H5::DataTypeIException +// Description +// Makes a copy of the type on the right hand side and stores +// the new id in the left hand side object. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- DataType& DataType::operator=( const DataType& rhs ) { copy(rhs); return(*this); } -// Determines whether two datatypes refer to the same actual datatype. +//-------------------------------------------------------------------------- +// Function: DataType::operator== +///\brief Compares this DataType against the given one to determines +/// whether the two objects refer to the same actual datatype. +///\param compared_type - IN: Reference to the datatype to compare +///\return true if the datatypes are equal, and false, otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- bool DataType::operator==(const DataType& compared_type ) const { // Call C routine H5Tequal to determines whether two datatype @@ -112,24 +159,16 @@ bool DataType::operator==(const DataType& compared_type ) const } } -// Operates a user's function on each attribute of an object - commented -// out because it should use the one from H5Object; need to check -// the parameter list??? - work in progress -//int DataType::iterate( unsigned * idx, H5A_operator_t op, void *op_data ) -//{ -//} - -// Creates a new variable-length datatype - Note: should use inheritance - -// work in progress -//DataType DataType::vlenCreate( const DataType& base_type ) -//{ -//} - +//-------------------------------------------------------------------------- +// Function: DataType::commit +///\brief Commits a transient datatype to a file, creating a new +/// named datatype +///\param loc - IN: Either a file or a group +///\param name - IN: Name of the datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- // Commits a transient datatype to a file, creating a new named datatype -void DataType::commit( H5Object& loc, const string& name ) const -{ - commit( loc, name.c_str() ); -} void DataType::commit( H5Object& loc, const char* name ) const { hid_t loc_id = loc.getId(); // get location id for C API @@ -141,8 +180,26 @@ void DataType::commit( H5Object& loc, const char* name ) const throw DataTypeIException("DataType::commit", "H5Tcommit failed"); } } +//-------------------------------------------------------------------------- +// Function: DataType::commit +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataType::commit( H5Object& loc, const string& name ) const +{ + commit( loc, name.c_str() ); +} -// Determines whether a datatype is a named type or a transient type. +//-------------------------------------------------------------------------- +// Function: DataType::committed +///\brief Determines whether a datatype is a named type or a +/// transient type. +///\return true if the datatype is a named type, and false, otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- bool DataType::committed() const { // Call C function to determine if a datatype is a named one @@ -157,7 +214,16 @@ bool DataType::committed() const } } -// Finds a conversion function. +//-------------------------------------------------------------------------- +// Function: DataType::find +///\brief Finds a conversion function that can handle a conversion +/// from this datatype to the specified datatype, \a dest. +///\param dest - IN: Destination datatype +///\param pcdata - IN: Pointer to type conversion data +///\return Pointer to a suitable conversion function +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const { // Call C routine to find the conversion function @@ -169,7 +235,19 @@ H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const return( func ); } -// Converts data from between specified datatypes. +//-------------------------------------------------------------------------- +// Function: DataType::convert +///\brief Converts data from this datatype to the specified datatypes. +///\param dest - IN: Destination datatype +///\param nelmts - IN: Size of array \a buf +///\param buf - IN/OUT: Array containing pre- and post-conversion +/// values +///\param background - IN: Optional backgroud buffer +///\param plist - IN: Dataset transfer property list +///\return Pointer to a suitable conversion function +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DataType::convert( const DataType& dest, hsize_t nelmts, void *buf, void *background, PropList& plist ) const { // Get identifiers for C API @@ -203,7 +281,19 @@ H5T_overflow_t DataType::getOverflow(void) const // NULL can be returned as well } -// Locks a datatype. +//-------------------------------------------------------------------------- +// Function: DataType::lock +///\brief Locks a datatype, making it read-only and non-destructible. +///\exception H5::DataTypeIException +///\par Descrition +/// This is normally done by the library for predefined data +/// types so the application doesn't inadvertently change or +/// delete a predefined type. +/// +/// Once a data type is locked it can never be unlocked unless +/// the entire library is closed. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DataType::lock() const { // Call C routine to lock the datatype @@ -214,7 +304,13 @@ void DataType::lock() const } } -// Returns the datatype class identifier. +//-------------------------------------------------------------------------- +// Function: DataType::getClass +///\brief Returns the datatype class identifier. +///\return Datatype class identifier +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- H5T_class_t DataType::getClass() const { H5T_class_t type_class = H5Tget_class( id ); @@ -228,7 +324,13 @@ H5T_class_t DataType::getClass() const return( type_class ); } -// Returns the size of a datatype. +//-------------------------------------------------------------------------- +// Function: DataType::getSize +///\brief Returns the size of a datatype. +///\return Datatype size in bytes +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- size_t DataType::getSize() const { // Call C routine to get the datatype size @@ -241,8 +343,13 @@ size_t DataType::getSize() const return( type_size ); } -// Returns the base datatype from which a datatype is derived. -// - just for DataType? +//-------------------------------------------------------------------------- +// Function: DataType::getSuper +///\brief Returns the base datatype from which a datatype is derived. +///\return DataType object +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- DataType DataType::getSuper() const { // Call C routine to get the base datatype from which the specified @@ -262,11 +369,22 @@ DataType DataType::getSuper() const } } -// Registers the specified conversion function. -void DataType::registerFunc( H5T_pers_t pers, const string& name, const DataType& dest, H5T_conv_t func ) const -{ - registerFunc( pers, name.c_str(), dest, func ); -} +//-------------------------------------------------------------------------- +// Function: DataType::registerFunc +///\brief Registers the specified conversion function. +///\param pers - IN: Conversion option +/// \li \c H5T_PERS_HARD for hard conversion functions +/// \li \c H5T_PERS_SOFT for soft conversion functions. +///\param name - IN: Name displayed in diagnostic output. +///\param dest - IN: Destination datatype. +///\param func - IN: Function to convert between source and +/// destination datatypes. +///\exception H5::DataTypeIException +///\par Description +/// For more information, please see: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5T.html#Datatype-Register +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const { hid_t dest_id = dest.getId(); // get id of the destination datatype @@ -278,12 +396,31 @@ void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType& throw DataTypeIException("DataType::registerFunc", "H5Tregister failed"); } } - -// Removes a conversion function from all conversion paths. -void DataType::unregister( H5T_pers_t pers, const string& name, const DataType& dest, H5T_conv_t func ) const +//-------------------------------------------------------------------------- +// Function: DataType::registerFunc +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataType::registerFunc( H5T_pers_t pers, const string& name, const DataType& dest, H5T_conv_t func ) const { - unregister( pers, name.c_str(), dest, func ); + registerFunc( pers, name.c_str(), dest, func ); } + +//-------------------------------------------------------------------------- +// Function: DataType::unregister +///\brief Removes a conversion function from all conversion paths. +///\param pers - IN: Conversion option +/// \li \c H5T_PERS_HARD for hard conversion functions +/// \li \c H5T_PERS_SOFT for soft conversion functions. +///\param name - IN: Name displayed in diagnostic output. +///\param dest - IN: Destination datatype. +///\param func - IN: Function to convert between source and +/// destination datatypes. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& dest, H5T_conv_t func ) const { hid_t dest_id = dest.getId(); // get id of the dest datatype for C API @@ -295,12 +432,26 @@ void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& de throw DataTypeIException("DataType::unregister", "H5Tunregister failed"); } } - -// Tags an opaque datatype. -void DataType::setTag( const string& tag ) const +//-------------------------------------------------------------------------- +// Function: DataType::unregister +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataType::unregister( H5T_pers_t pers, const string& name, const DataType& dest, H5T_conv_t func ) const { - setTag( tag.c_str()); + unregister( pers, name.c_str(), dest, func ); } + +//-------------------------------------------------------------------------- +// Function: DataType::setTag +///\brief Tags an opaque datatype. +///\param tag - IN: Descriptive ASCII string with which the opaque +/// datatype is to be tagged. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DataType::setTag( const char* tag ) const { // Call C routine H5Tset_tag to tag an opaque datatype. @@ -310,8 +461,25 @@ void DataType::setTag( const char* tag ) const throw DataTypeIException("DataType::setTag", "H5Tset_tag failed"); } } +//-------------------------------------------------------------------------- +// Function: DataType::setTag +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in the type of the +/// argument \a name. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +void DataType::setTag( const string& tag ) const +{ + setTag( tag.c_str()); +} -// Gets the tag associated with an opaque datatype. +//-------------------------------------------------------------------------- +// Function: DataType::getTag +///\brief Gets the tag associated with an opaque datatype. +///\return Tag associated with the opaque datatype +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- string DataType::getTag() const { char* tag_Cstr = H5Tget_tag( id ); @@ -331,6 +499,118 @@ string DataType::getTag() const } } +//-------------------------------------------------------------------------- +// Function: DataType::detectClass +///\brief Checks whether a datatype contains (or is) a certain type of +/// datatype. +///\return true if this datatype contains or is the specified type, +/// and false, otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +bool DataType::detectClass(H5T_class_t cls) const +{ + htri_t ret_value = H5Tdetect_class(id, cls); + if( ret_value > 0 ) + return true; + else if( ret_value == 0 ) + return false; + else + { + throw DataTypeIException("DataType::detectClass", + "H5Tdetect_class returns negative value"); + } +} + +//-------------------------------------------------------------------------- +// Function: DataType::isVariableStr +///\brief Check whether this datatype is a variable-length string. +///\return true if this datatype is a variable-length string, and +/// false, otherwise. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +bool DataType::isVariableStr() const +{ + htri_t is_varlen_str = H5Tis_variable_str(id); + if( is_varlen_str == 1 ) + return true; + else if( is_varlen_str == 0 ) + return false; + else + { + throw DataTypeIException("DataType::isVariableStr", + "H5Tis_variable_str returns negative value"); + } +} + +//-------------------------------------------------------------------------- +// Function: DataType::Reference +///\brief Creates a reference to an HDF5 object or a dataset region. +///\param name - IN: Name of the object to be referenced +///\param dataspace - IN: Dataspace with selection +///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION +///\return A reference +///\exception H5::ReferenceIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void* DataType::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const +{ + return(p_reference(name, dataspace.getId(), ref_type)); +} + +//-------------------------------------------------------------------------- +// Function: DataType::Reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it only creates +/// a reference to an HDF5 object, not to a dataset region. +///\param name - IN: Name of the object to be referenced +///\return A reference +///\exception H5::ReferenceIException +///\par Description +// This function passes H5R_OBJECT and -1 to the protected +// function for it to pass to the C API H5Rcreate +// to create a reference to the named object. +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void* DataType::Reference(const char* name) const +{ + return(p_reference(name, -1, H5R_OBJECT)); +} + +//-------------------------------------------------------------------------- +// Function: DataType::getObjType +///\brief Retrieves the type of object that an object reference points to. +///\param ref - IN: Reference to query +///\param ref_type - IN: Type of reference to query +///\return Object type, which can be one of the following: +/// \li \c H5G_LINK Object is a symbolic link. +/// \li \c H5G_GROUP Object is a group. +/// \li \c H5G_DATASET Object is a dataset. +/// \li \c H5G_TYPE Object is a named datatype +///\exception H5::ReferenceIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +H5G_obj_t DataType::getObjType(void *ref, H5R_type_t ref_type) const +{ + return(p_get_obj_type(ref, ref_type)); +} + +//-------------------------------------------------------------------------- +// Function: DataType::getRegion +///\brief Retrieves a dataspace with the region pointed to selected. +///\param ref - IN: Reference to get region of +///\param ref_type - IN: Type of reference to get region of - default +///\return DataSpace instance +///\exception H5::ReferenceIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const +{ + DataSpace dataspace(p_get_region(ref, ref_type)); + return(dataspace); +} + // This private function calls the C API H5Tclose to close this datatype. // Used by H5Object::p_reset. void DataType::p_close() const @@ -346,11 +626,11 @@ void DataType::p_close() const } } -// The destructor of this instance calls IdComponent::reset to -// reset its identifier - no longer true -// Older compilers (baldric) don't support template member functions -// and IdComponent::reset is one; so at this time, the resetId is not -// a member function so it can be template to work around that problem. +//-------------------------------------------------------------------------- +// Function: DataType destructor +///\brief Properly terminates access to this datatype. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- DataType::~DataType() { // The datatype id will be closed properly diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index c0aa56d..3f695ff 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -87,10 +87,24 @@ class H5_DLLCPP DataType : public H5Object { // Gets the tag associated with an opaque datatype. string getTag() const; - // Creates a new variable-length datatype - not implemented yet - // Will be moved into a subclass when completed - //DataType vlenCreate( const DataType& base_type ); + // Checks whether this datatype contains (or is) a certain type class. + bool detectClass(H5T_class_t cls) const; + // Checks whether this datatype is a variable-length string. + bool isVariableStr() const; + + // Creates a reference to a named Hdf5 object in this object. + void* Reference(const char* name) const; + + // Creates a reference to a named Hdf5 object or to a dataset region + // in this object. + void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Retrieves the type of object that an object reference points to. + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type) const; + + // Retrieves a dataspace with the region pointed to selected. + DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; // Used by the API to appropriately close a datatype void p_close() const; diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index d8327c2..66a2862 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -27,15 +27,38 @@ namespace H5 { #endif +//-------------------------------------------------------------------------- +///\brief Constant for default property +//-------------------------------------------------------------------------- const DSetCreatPropList DSetCreatPropList::DEFAULT( H5P_DEFAULT ); -// Creates a dataset creation property list +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList default constructor +///\brief Default Constructor: Creates a dataset creation property list +//-------------------------------------------------------------------------- DSetCreatPropList::DSetCreatPropList() : PropList( H5P_DATASET_CREATE) {} -// Copy constructor: makes a copy of the original DSetCreatPropList object; +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList copy constructor +///\brief Copy Constructor: Makes a copy of the original +/// DSetCreatPropList object +//-------------------------------------------------------------------------- DSetCreatPropList::DSetCreatPropList( const DSetCreatPropList& orig ) : PropList( orig ) {} -// Sets the size of the chunks used to store a chunked layout dataset. +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setChunk +///\brief Sets the size of the chunks used to store a chunked layout +/// dataset. +///\param ndims - IN: Number of dimensions of each chunk +///\param dim - IN: Array containing the size of each chunk +///\exception H5::PropListIException +///\par Description +/// The \a ndims parameter currently must have the same value as +/// the rank of the dataset. The values of the \a dim array +/// define the size of the chunks to store the dataset's raw +/// data. As a side-effect, the layout of the dataset will be +/// changed to \c H5D_CHUNKED, if it is not so already. +//-------------------------------------------------------------------------- void DSetCreatPropList::setChunk( int ndims, const hsize_t* dim ) const { herr_t ret_value = H5Pset_chunk( id, ndims, dim ); @@ -45,20 +68,14 @@ void DSetCreatPropList::setChunk( int ndims, const hsize_t* dim ) const } } -// Gets the layout of the raw data storage of the data that uses this -// property list -H5D_layout_t DSetCreatPropList::getLayout() const -{ - H5D_layout_t layout = H5Pget_layout( id ); - if( layout == H5D_LAYOUT_ERROR ) - { - throw PropListIException("DSetCreatPropList::getLayout", - "H5Pget_layout returns H5D_LAYOUT_ERROR"); - } - return( layout ); -} - -// Retrieves the size of the chunks used to store a chunked layout dataset. +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getChunk +///\brief Retrieves the size of the chunks used to store a chunked +/// layout dataset. +///\param max_ndims - IN: Size of \a dim array +///\param dim - OUT: Array to store the chunk dimensions +///\exception H5::PropListIException +//-------------------------------------------------------------------------- int DSetCreatPropList::getChunk( int max_ndims, hsize_t* dim ) const { int chunk_size = H5Pget_chunk( id, max_ndims, dim ); @@ -70,7 +87,16 @@ int DSetCreatPropList::getChunk( int max_ndims, hsize_t* dim ) const return( chunk_size ); } -// Sets the type of storage used store the raw data for a dataset. +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setLayout +///\brief Sets the type of storage used store the raw data for a dataset. +///\param plist - IN: Property list id, here by mistake, should be removed +///\param layout - IN: Type of storage layout for raw data +///\exception H5::PropListIException +///\par Description +/// For information on setting layout type, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetLayout +//-------------------------------------------------------------------------- void DSetCreatPropList::setLayout(hid_t plist, H5D_layout_t layout ) const { herr_t ret_value = H5Pset_layout( id, layout ); @@ -81,7 +107,43 @@ void DSetCreatPropList::setLayout(hid_t plist, H5D_layout_t layout ) const } } -// Sets compression method and compression level +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getLayout +///\brief Retrieves the layout type of this property list +///\return Layout type, which can be: +/// \li \c H5D_COMPACT - raw data is stored in the object +/// header in the file. +/// \li \c H5D_CONTIGUOUS - raw data is stored separately from the +/// object header in one contiguous chunk in +/// the file. +/// \li \c H5D_CHUNKED - raw data is stored separately from the +/// object header in chunks in separate locations +/// in the file. +///\exception H5::PropListIException +///\par Description +//-------------------------------------------------------------------------- +H5D_layout_t DSetCreatPropList::getLayout() const +{ + H5D_layout_t layout = H5Pget_layout( id ); + if( layout == H5D_LAYOUT_ERROR ) + { + throw PropListIException("DSetCreatPropList::getLayout", + "H5Pget_layout returns H5D_LAYOUT_ERROR"); + } + return( layout ); +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setDeflate +///\brief Sets compression method and compression level +///\param level - IN: Compression level, should [0..9], inclusive +///\exception H5::PropListIException +///\par Description +/// The function sets the compression method for this property +/// list to \c H5D_COMPRESS_DEFLATE and the compression level to +/// \a level. Lower compression levels are faster but result in +/// less compression. +//-------------------------------------------------------------------------- void DSetCreatPropList::setDeflate( int level ) const { herr_t ret_value = H5Pset_deflate( id, level ); @@ -92,7 +154,23 @@ void DSetCreatPropList::setDeflate( int level ) const } } -// Sets a dataset fill value +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setFillValue +///\brief Sets a dataset fill value +///\param fvalue_type - IN: Data type for the value passed via \a value +///\param value - IN: Pointer to buffer containing the fill value +///\exception H5::PropListIException +///\par Description +/// The datatype may differ from that of the dataset, but it must +/// be one that the HDF5 library is able to convert \a value to +/// the dataset datatype when the dataset is created. +/// The default fill value is 0 (zero,) which is interpreted +/// according to the actual dataset datatype. +///\par +/// For information on setting fill value, please refer to the +/// C layer Reference Manual at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetFillValue +//-------------------------------------------------------------------------- void DSetCreatPropList::setFillValue( const DataType& fvalue_type, const void* value ) const { herr_t ret_value = H5Pset_fill_value( id, fvalue_type.getId(), value ); @@ -103,7 +181,18 @@ void DSetCreatPropList::setFillValue( const DataType& fvalue_type, const void* v } } -// Retrieves a dataset fill value +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getFillValue +///\brief Retrieves a dataset fill value +///\param fvalue_type - IN: Data type for the value passed via \a value +///\param value - OUT: Pointer to buffer to hold the retrieved fill value +///\exception H5::PropListIException +///\par Description +/// The fill value is returned through \a value pointer +/// and the memory is allocated by the caller. The fill +/// value will be converted from its current data type to the +/// specified by \a fvalue_type. +//-------------------------------------------------------------------------- void DSetCreatPropList::getFillValue( const DataType& fvalue_type, void* value ) const { herr_t ret_value = H5Pget_fill_value( id, fvalue_type.getId(), value ); @@ -114,7 +203,47 @@ void DSetCreatPropList::getFillValue( const DataType& fvalue_type, void* value ) } } -// Adds a filter to the filter pipeline +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::isFillValueDefined +///\brief Check if fill value has been defined for this property +///\return +/// \li \c H5D_FILL_VALUE_UNDEFINED =0, +/// \li \c H5D_FILL_VALUE_DEFAULT =1, +/// \li \c H5D_FILL_VALUE_USER_DEFINED =2 +///\exception H5::PropListIException +//-------------------------------------------------------------------------- +H5D_fill_value_t DSetCreatPropList::isFillValueDefined() +{ + H5D_fill_value_t status; + herr_t ret_value = H5Pfill_value_defined(id, &status); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::isFillValueDefined", + "H5Pfill_value_defined returned H5D_FILL_VALUE_ERROR (-1)"); + } + else + return (status); +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setFilter +///\brief Adds a filter to the filter pipeline +///\param filter_id - IN: Filter to add +///\param flags - IN: Specifies general properties of the filter +///\param cd_nelmts - IN: Number of elements in cd_values +///\param cd_values - IN: Auxiliary data for the filter +///\exception H5::PropListIException +///\par Description +/// The \a flags argument is a bit vector of the field: +/// \c H5Z_FLAG_OPTIONAL(0x0001) +///\par +/// If this bit is set then the filter is optional. If the filter +/// fails during a \c DataSet::write() operation then the filter +/// is just excluded from the pipeline for the chunk for which it +/// failed; the filter will not participate in the pipeline +/// during a \c DataSet::read() of the chunk. If this bit is clear +/// and the filter fails then the entire I/O operation fails. +//-------------------------------------------------------------------------- void DSetCreatPropList::setFilter( H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const { herr_t ret_value = H5Pset_filter( id, filter, flags, cd_nelmts, cd_values ); @@ -125,7 +254,31 @@ void DSetCreatPropList::setFilter( H5Z_filter_t filter, unsigned int flags, size } } -// Returns the number of filters in the pipeline +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::removeFilter +///\brief Removes one or more filters +///\param filter_id - IN: Filter to remove +///\exception H5::PropListIException +///\par Description +/// Deletes a filter from the dataset creation property list; +/// deletes all filters if \a filter_id is \c H5Z_FILTER_NONE. +//-------------------------------------------------------------------------- +void DSetCreatPropList::removeFilter(H5Z_filter_t filter_id) const +{ + herr_t ret_value = H5Premove_filter( id, filter_id); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::removeFilter", + "H5Premove_filter failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getNfilters +///\brief Returns the number of filters in the pipeline +///\return Number of filters +///\exception H5::PropListIException +//-------------------------------------------------------------------------- int DSetCreatPropList::getNfilters() const { int num_filters = H5Pget_nfilters( id ); @@ -138,22 +291,251 @@ int DSetCreatPropList::getNfilters() const return( num_filters ); } -// Returns information about a filter in a pipeline +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getFilter +///\brief Returns information about a filter in a pipeline +///\param filter_number - IN: Filter to get, range [0..N-1], where +/// N is returned by H5Pget_nfilters() +///\param flags - OUT: General properties of the filter +///\param cd_nelmts - IN/OUT: Number of elements in \a cd_values /Number +/// of values defined by the filter +///\param cd_values - OUT: Array to hold the data; allocated by the user +///\param namelen - OUT: Length of \a name +///\param name - OUT: Name of the filter +///\return Filter id +///\exception H5::PropListIException +///\par Description +/// Failure occurs when \a filter_number is out of range. +//-------------------------------------------------------------------------- H5Z_filter_t DSetCreatPropList::getFilter( int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[] ) const { - H5Z_filter_t filter; - filter = H5Pget_filter( id, filter_number, &flags, &cd_nelmts, - cd_values, namelen, name ); - if( filter == H5Z_FILTER_ERROR ) + H5Z_filter_t filter_id; + filter_id = H5Pget_filter(id, filter_number, &flags, &cd_nelmts, + cd_values, namelen, name); + if (filter_id == H5Z_FILTER_ERROR) { throw PropListIException("DSetCreatPropList::getFilter", "H5Pget_filter returned H5Z_FILTER_ERROR"); } else - return( filter ); + return(filter_id); +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getFilterById +///\brief Returns information about a filter in a pipeline given the +/// filter id +///\param filter_id - IN: Filter to get +///\param flags - OUT: General properties of the filter +///\param cd_nelmts - IN/OUT: Number of elements in \a cd_values /Number +/// of values defined by the filter +///\param cd_values - OUT: Array to hold the data; allocated by the user +///\param namelen - IN: Length of \a name +///\param name - OUT: Name of the filter +///\exception H5::PropListIException +//-------------------------------------------------------------------------- +void DSetCreatPropList::getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[]) const +{ + herr_t ret_value = H5Pget_filter_by_id(id, filter_id, &flags, &cd_nelmts, + cd_values, namelen, name ); + if (ret_value < 0) + { + throw PropListIException("DSetCreatPropList::getFilterById", + "H5Pget_filter_by_id failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::modifyFilter +///\brief Modifies the specified filter +///\param filter_id - IN: Filter to get +///\param flags - OUT: General properties of the filter +///\param cd_nelmts - IN: Number of elements in \a cd_values +/// \n OUT: Number of values defined by the filter +///\param cd_values - OUT: Array to hold the data; allocated by the user +///\exception H5::PropListIException +///\par Description +/// The \a flags argument is a bit vector of the field: +/// \c H5Z_FLAG_OPTIONAL(0x0001) +///\par +/// If this bit is set then the filter is optional. If the filter +/// fails during a DataSet::write() operation then the filter +/// is just excluded from the pipeline for the chunk for which it +/// failed; the filter will not participate in the pipeline +/// during a DataSet::read() of the chunk. If this bit is clear +/// and the filter fails then the entire I/O operation fails. +//-------------------------------------------------------------------------- +void DSetCreatPropList::modifyFilter( H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const +{ + herr_t ret_value = H5Pmodify_filter(id, filter_id, flags, cd_nelmts, cd_values); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::modifyFilter", + "H5Pmodify_filter failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::allFiltersAvail +///\brief Queries whether all the filters set in this property list +/// are available currently. +///\return true if all filters available, and false if one or more +/// filters not currently available +///\exception H5::PropListIException +//-------------------------------------------------------------------------- +bool DSetCreatPropList::allFiltersAvail() +{ + htri_t ret_value = H5Pall_filters_avail(id); + if( ret_value > 0 ) + return true; + else if( ret_value == 0 ) + return false; + else // Raise exception when H5Pall_filters_avail returns a negative value + { + throw PropListIException("DSetCreatPropList::allFiltersAvail", "H5Pall_filters_avail returned negative value"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setShuffle +///\brief Sets method of the shuffle filter +///\exception H5::PropListIException +///\par Description +/// Please refer to the Reference Manual of \c H5Pset_shuffle for +/// details. +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetShuffle +//-------------------------------------------------------------------------- +void DSetCreatPropList::setShuffle() +{ + herr_t ret_value = H5Pset_shuffle(id); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::setShuffle", + "H5Pset_shuffle failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getAllocTime +///\brief Get space allocation time for this property. +///\return Space allocation time. +///\exception H5::PropListIException +///\par Description +/// The values of space allocation time can be one of the +/// followings: +/// \li \c H5D_ALLOC_TIME_DEFAULT +/// \li \c H5D_ALLOC_TIME_EARLY +/// \li \c H5D_ALLOC_TIME_LATE +/// \li \c H5D_ALLOC_TIME_INCR +//-------------------------------------------------------------------------- +H5D_alloc_time_t DSetCreatPropList::getAllocTime() +{ + H5D_alloc_time_t alloc_time; + herr_t ret_value = H5Pget_alloc_time(id, &alloc_time); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::getAllocTime", + "H5Pget_alloc_time failed"); + } + else + return (alloc_time); +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getFillTime +///\brief Gets fill value writing time. +///\return Fill value writing time +///\exception H5::PropListIException +///\par Description +/// Valid values for fill value writing time include +/// \li \c H5D_FILL_TIME_NEVER +/// \li \c H5D_FILL_TIME_ALLOC. +//-------------------------------------------------------------------------- +H5D_fill_time_t DSetCreatPropList::getFillTime() +{ + H5D_fill_time_t fill_time; + herr_t ret_value = H5Pget_fill_time(id, &fill_time); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::getFillTime", + "H5Pget_fill_time failed"); + } + else + return (fill_time); +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setAllocTime +///\brief Sets space allocation time for dataset during creation. +///\param alloc_time - IN: Allocation time +///\exception H5::PropListIException +///\par Description +/// Valid values for space allocation time include: +/// \li \c H5D_ALLOC_TIME_DEFAULT +/// \li \c H5D_ALLOC_TIME_EARLY +/// \li \c H5D_ALLOC_TIME_LATE +/// \li \c H5D_ALLOC_TIME_INCR +//-------------------------------------------------------------------------- +void DSetCreatPropList::setAllocTime(H5D_alloc_time_t alloc_time) +{ + herr_t ret_value = H5Pset_alloc_time(id, alloc_time); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::setAllocTime", + "H5Pset_alloc_time failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setFillTime +///\brief Sets fill value writing time for dataset. +///\return Fill value writing time +///\exception H5::PropListIException +///\par Description +/// Valid values for fill value writing time include +/// \li \c H5D_FILL_TIME_NEVER +/// \li \c H5D_FILL_TIME_ALLOC. +//-------------------------------------------------------------------------- +void DSetCreatPropList::setFillTime(H5D_fill_time_t fill_time) +{ + herr_t ret_value = H5Pset_fill_time(id, fill_time); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::setFillTime", + "H5Pset_fill_time failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setFletcher32 +///\brief Sets Fletcher32 checksum of EDC for this property list. +///\exception H5::PropListIException +//-------------------------------------------------------------------------- +void DSetCreatPropList::setFletcher32() +{ + herr_t ret_value = H5Pset_fletcher32(id); + if( ret_value < 0 ) + { + throw PropListIException("DSetCreatPropList::setFletcher32", + "H5Pset_fletcher32 failed"); + } } -// Adds an external file to the list of external files +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::setExternal +///\brief Adds an external file to the list of external files +///\param name - IN: Name of the external file +///\param offset - IN: Location where the data starts in the file +///\param size - IN: Number of bytes reserved in the file for the data +///\exception H5::PropListIException +///\par Description +/// If a dataset is splitted across multiple files then the files +/// should be defined in order. The total size of the dataset is +/// the sum of the \a size arguments for all the external files. If +/// the total size is larger than the size of a dataset then the +/// dataset can be extended (provided the data space also allows +/// the extending). +//-------------------------------------------------------------------------- void DSetCreatPropList::setExternal( const char* name, off_t offset, hsize_t size ) const { herr_t ret_value = H5Pset_external( id, name, offset, size ); @@ -164,7 +546,12 @@ void DSetCreatPropList::setExternal( const char* name, off_t offset, hsize_t siz } } -// Returns the number of external files for a dataset +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getExternalCount +///\brief Returns the number of external files for a dataset +///\return Number of external files +///\exception H5::PropListIException +//-------------------------------------------------------------------------- int DSetCreatPropList::getExternalCount() const { int num_ext_files = H5Pget_external_count( id ); @@ -177,7 +564,27 @@ int DSetCreatPropList::getExternalCount() const return( num_ext_files ); } -// Returns information about an external file +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList::getExternal +///\brief Returns information about an external file +///\param idx - IN: Index of the external file, ranges [0-(N-1)] and +/// returned by getExternalCount() +///\param name_size - IN: Maximum length of \a name +///\param name - IN: Name of the external file +///\param offset - IN: Location to return an offset value +///\param size - OUT: Location to return the size of the external file data +///\exception H5::PropListIException +///\par Description +/// The parameter \a idx ranges [0..N-1] where N is returned by +/// getExternalCount(). At most \a name_size characters are copied +/// into the name array. If the external file name is longer than +/// name_size with the null terminator, the return value is not +/// null terminated (similar to strncpy()). +/// If \a name_size is zero or \a name is a null pointer, the +/// external file name will not be returned. If \a offset or +/// \a size are null pointers then the corresponding information +/// will not be returned. +//-------------------------------------------------------------------------- void DSetCreatPropList::getExternal( int idx, size_t name_size, char* name, off_t& offset, hsize_t& size ) const { herr_t ret_value = H5Pget_external( id, idx, name_size, name, &offset, &size ); @@ -188,7 +595,11 @@ void DSetCreatPropList::getExternal( int idx, size_t name_size, char* name, off_ } } -// Default destructor +//-------------------------------------------------------------------------- +// Function: DSetCreatPropList destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- DSetCreatPropList::~DSetCreatPropList () {} #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 931a478..8c1a831 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -54,14 +54,48 @@ class H5_DLLCPP DSetCreatPropList : public PropList { // Retrieves a dataset fill value void getFillValue( const DataType& fvalue_type, void* value ) const; + // Checks if fill value has been defined for this property + H5D_fill_value_t isFillValueDefined(); + // Adds a filter to the filter pipeline void setFilter( H5Z_filter_t filter, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const; + // Remove one or all filters from the filter pipeline + void removeFilter( H5Z_filter_t filter_id) const; + // Returns the number of filters in the pipeline int getNfilters() const; // Returns information about a filter in a pipeline - H5Z_filter_t getFilter( int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[] ) const; + H5Z_filter_t getFilter(int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[]) const; + + // Returns information about a filter in a pipeline given the filter id + void getFilterById(H5Z_filter_t filter_id, unsigned int &flags, size_t &cd_nelmts, unsigned int* cd_values, size_t namelen, char name[]) const; + + // Modifies the specified filter + void modifyFilter( H5Z_filter_t filter_id, unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[] ) const; + + // Queries whether all the filters set in this property list are + // available currently. + bool allFiltersAvail(); + + // Sets method of the shuffle filter + void setShuffle(); + + // Get space allocation time for this property + H5D_alloc_time_t getAllocTime(); + + // Gets fill value writing time + H5D_fill_time_t getFillTime(); + + // Set space allocation time for dataset during creation + void setAllocTime(H5D_alloc_time_t alloc_time); + + // Sets fill value writing time for dataset + void setFillTime(H5D_fill_time_t fill_time); + + // Sets Fletcher32 checksum of EDC for this property list + void setFletcher32(); // Adds an external file to the list of external files void setExternal( const char* name, off_t offset, hsize_t size ) const; diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index e663eeb..1f9ade3 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -25,16 +25,39 @@ namespace H5 { #endif +//-------------------------------------------------------------------------- +///\brief Constant for default property +//-------------------------------------------------------------------------- const DSetMemXferPropList DSetMemXferPropList::DEFAULT( H5P_DEFAULT ); -// Creates a dataset memory and transfer property list -DSetMemXferPropList::DSetMemXferPropList() : PropList( H5P_DATASET_XFER) {} +//-------------------------------------------------------------------------- +// Function Default constructor +///\brief Default constructor - Creates a stub dataset memory and +/// transfer property list object. +// Programmer: Binh-Minh Ribler +//-------------------------------------------------------------------------- +DSetMemXferPropList::DSetMemXferPropList() : PropList(H5P_DATASET_XFER) {} -// Copy constructor: makes a copy of the original DSetMemXferPropList object; -DSetMemXferPropList::DSetMemXferPropList( const DSetMemXferPropList& orig ) : PropList( orig ) {} +//-------------------------------------------------------------------------- +// Function Copy constructor +///\brief Copy constructor - makes a copy of the original +/// DSetMemXferPropList object +///\param original - IN: Original dataset memory and transfer property +/// list object to copy +// Programmer: Binh-Minh Ribler +//-------------------------------------------------------------------------- +DSetMemXferPropList::DSetMemXferPropList( const DSetMemXferPropList& original ) : PropList( original ) {} #ifdef H5_WANT_H5_V1_4_COMPAT -// Sets type conversion and background buffers +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setBuffer +///\brief Sets type conversion and background buffers. +///\param size - IN: Size, in bytes, of the type conversion and background buffers +///\param tconv - IN: Pointer to application-allocated type conversion buffer +///\param bkg - IN: Pointer to application-allocated background buffer +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::setBuffer( hsize_t size, void* tconv, void* bkg ) const { herr_t ret_value = H5Pset_buffer( id, size, tconv, bkg ); @@ -45,7 +68,15 @@ void DSetMemXferPropList::setBuffer( hsize_t size, void* tconv, void* bkg ) cons } } -// Reads buffer settings +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getBuffer +///\brief Reads buffer settings. +///\param tconv - IN: Pointer to application-allocated type conversion buffer +///\param bkg - IN: Pointer to application-allocated background buffer +///\return Buffer size, in bytes +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- hsize_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const { hsize_t buffer_size = H5Pget_buffer( id, tconv, bkg ); @@ -57,7 +88,15 @@ hsize_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const return( buffer_size ); } #else /* H5_WANT_H5_V1_4_COMPAT */ -// Sets type conversion and background buffers +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setBuffer +///\brief Sets type conversion and background buffers. +///\param size - IN: Size, in bytes, of the type conversion and background buffers +///\param tconv - IN: Pointer to application-allocated type conversion buffer +///\param bkg - IN: Pointer to application-allocated background buffer +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::setBuffer( size_t size, void* tconv, void* bkg ) const { herr_t ret_value = H5Pset_buffer( id, size, tconv, bkg ); @@ -68,7 +107,15 @@ void DSetMemXferPropList::setBuffer( size_t size, void* tconv, void* bkg ) const } } -// Reads buffer settings +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getBuffer +///\brief Reads buffer settings. +///\param tconv - IN: Pointer to application-allocated type conversion buffer +///\param bkg - IN: Pointer to application-allocated background buffer +///\return Buffer size, in bytes +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- size_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const { size_t buffer_size = H5Pget_buffer( id, tconv, bkg ); @@ -81,7 +128,13 @@ size_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const } #endif /* H5_WANT_H5_V1_4_COMPAT */ -// Sets the dataset transfer property list status to TRUE or FALSE +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setPreserve +///\brief Sets the dataset transfer property list status to true or false. +///\param status - IN: Status to set, true or false +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::setPreserve( bool status ) const { herr_t ret_value = H5Pset_preserve( id, (hbool_t) status ); @@ -92,7 +145,13 @@ void DSetMemXferPropList::setPreserve( bool status ) const } } -// Checks status of the dataset transfer property list +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getPreserve +///\brief Checks status of the dataset transfer property list. +///\return Status of the dataset transfer property list +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- bool DSetMemXferPropList::getPreserve() const { int ret_value = H5Pget_preserve( id ); @@ -108,7 +167,21 @@ bool DSetMemXferPropList::getPreserve() const } #ifdef H5_WANT_H5_V1_4_COMPAT -// Indicates whether to cache hyperslab blocks during I/O +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setHyperCache +///\brief Indicates whether to cache hyperslab blocks during I/O +///\param cache - IN: Flag indicating whether caching is to be set +/// to on (1) or off (0) +///\param limit - IN: Maximum size of the hyperslab block to cache or +/// 0 (zero) for no limit +///\exception H5::PropListIException +///\note This function is deprecated in HDF5 Release 1.6 and will +/// eventually be removed from the HDF5 distribution. It is +/// provided in this release only to enable backward compatibility +/// with HDF5 Releases 1.4.x and is enabled only if the HDF5 +/// library is configured with the flag H5_WANT_H5_V1_4_COMPAT. +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::setHyperCache( bool cache, unsigned limit ) const { herr_t ret_value = H5Pset_hyper_cache( id, cache, limit ); @@ -119,7 +192,22 @@ void DSetMemXferPropList::setHyperCache( bool cache, unsigned limit ) const } } -// Returns information regarding the caching of hyperslab blocks during I/O +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getHyperCache +///\brief Returns information regarding the caching of hyperslab +/// blocks during I/O. +///\param cache - OUT: Flag indicating whether caching is set +/// to on (1) or off (0) +///\param limit - OUT: Maximum size of the hyperslab block to cache or +/// 0 (zero) for no limit +///\exception H5::PropListIException +///\note This function is deprecated in HDF5 Release 1.6 and will +/// eventually be removed from the HDF5 distribution. It is +/// provided in this release only to enable backward compatibility +/// with HDF5 Releases 1.4.x and is enabled only if the HDF5 +/// library is configured with the flag H5_WANT_H5_V1_4_COMPAT. +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::getHyperCache( bool& cache, unsigned& limit ) const { unsigned temp_cache; // C routine takes hid_t, unsigned*, unsigned* @@ -136,7 +224,15 @@ void DSetMemXferPropList::getHyperCache( bool& cache, unsigned& limit ) const } #endif /* H5_WANT_H5_V1_4_COMPAT */ -// Sets B-tree split ratios for a dataset transfer property list +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setBtreeRatios +///\brief Sets B-tree split ratios for a dataset transfer property list. +///\param left - IN: B-tree split ratio for left-most nodes +///\param middle - IN: B-tree split ratio for right-most nodes and lone nodes +///\param right - IN: B-tree split ratio for all other nodes +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::setBtreeRatios( double left, double middle, double right ) const { herr_t ret_value = H5Pset_btree_ratios( id, left, middle, right ); @@ -147,7 +243,15 @@ void DSetMemXferPropList::setBtreeRatios( double left, double middle, double rig } } -// Gets B-tree split ratios for a dataset transfer property list +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getBtreeRatios +///\brief Gets B-tree split ratios for a dataset transfer property list. +///\param left - OUT: B-tree split ratio for left-most nodes +///\param middle - OUT: B-tree split ratio for right-most nodes and lone nodes +///\param right - OUT: B-tree split ratio for all other nodes +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::getBtreeRatios( double& left, double& middle, double& right ) const { herr_t ret_value = H5Pget_btree_ratios( id, &left, &middle, &right ); @@ -158,7 +262,16 @@ void DSetMemXferPropList::getBtreeRatios( double& left, double& middle, double& } } -// Sets the memory manager for variable-length datatype allocation +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setVlenMemManager +///\brief Sets the memory manager for variable-length datatype allocation. +///\param alloc - IN: User's allocate routine +///\param alloc_info - IN: User's allocation parameters +///\param free - IN: User's free routine +///\param free_info - IN: User's free parameters +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::setVlenMemManager( H5MM_allocate_t alloc_func, void* alloc_info, H5MM_free_t free_func, void* free_info ) const { herr_t ret_value = H5Pset_vlen_mem_manager( id, alloc_func, alloc_info, @@ -170,20 +283,28 @@ void DSetMemXferPropList::setVlenMemManager( H5MM_allocate_t alloc_func, void* a } } -// alloc_func and free_func are set to NULL, indicating that system malloc and -// free are to be used +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setVlenMemManager +///\brief Sets the memory manager for variable-length datatype +/// allocation - system \c malloc and \c free will be used. +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::setVlenMemManager() const { setVlenMemManager( NULL, NULL, NULL, NULL ); - //herr_t ret_value = H5Pset_vlen_mem_manager( id, NULL, NULL, NULL, NULL ); - //if( ret_value < 0 ) - //{ - //throw PropListIException("DSetMemXferPropList::setVlenMemManager", - //"H5Pset_vlen_mem_manager failed"); - //} } -// Gets the memory manager for variable-length datatype allocation +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getVlenMemManager +///\brief Gets the memory manager for variable-length datatype allocation +///\param alloc - OUT: User's allocate routine +///\param alloc_info - OUT: User's allocation parameters +///\param free - OUT: User's free routine +///\param free_info - OUT: User's free parameters +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void DSetMemXferPropList::getVlenMemManager( H5MM_allocate_t& alloc_func, void** alloc_info, H5MM_free_t& free_func, void** free_info ) const { herr_t ret_value = H5Pget_vlen_mem_manager( id, &alloc_func, alloc_info, &free_func, free_info ); @@ -194,36 +315,173 @@ void DSetMemXferPropList::getVlenMemManager( H5MM_allocate_t& alloc_func, void** } } -/* this function is in parallel mode only - not supported at this time. -// Sets the transfer mode -void DSetMemXferPropList::setXfer( H5D_transfer_t data_xfer_mode = H5D_XFER_INDEPENDENT ) const +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setMulti +///\brief Sets the data transfer property list for the multi-file driver. +///\param memb_dxpl - OUT: Array of data access property lists +///\exception H5::PropListIException +///\par Description +/// This function can only be used after the member map has +/// been set with FileAccPropList::setMulti (not done - BMR.) +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +void DSetMemXferPropList::setMulti(const hid_t *memb_dxpl) { - herr_t ret_value = H5Pset_xfer( ... ); - if( ret_value < 0 ) + herr_t ret_value = H5Pset_dxpl_multi(id, memb_dxpl); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setMulti", + "H5Pset_dxpl_multi failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getMulti +///\brief Returns multi-file data transfer property list information. +///\param memb_dxpl - OUT: Array of data access property lists +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +void DSetMemXferPropList::getMulti(hid_t *memb_dxpl) +{ + herr_t ret_value = H5Pget_dxpl_multi(id, memb_dxpl); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::getMulti", + "H5Pget_dxpl_multi failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setSmallDataBlockSize +///\brief Sets the size of a contiguous block reserved for small data. +///\param size - IN: Maximum size, in bytes, of the small data block. +///\exception H5::PropListIException +///\par Description +/// For detail, please refer to the C layer Reference Manual at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetSmallData +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +void DSetMemXferPropList::setSmallDataBlockSize(hsize_t size) +{ + herr_t ret_value = H5Pset_small_data_block_size(id, size); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setSmallDataBlockSize", + "H5Pset_small_data_block_size failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getSmallDataBlockSize +///\brief Returns the current small data block size setting. +///\return Size of the small data block, in bytes +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +hsize_t DSetMemXferPropList::getSmallDataBlockSize() +{ + hsize_t size; + herr_t ret_value = H5Pget_small_data_block_size(id, &size); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::getSmallDataBlockSize", + "H5Pget_small_data_block_size failed"); + } + return(size); +} + +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setHyperVectorSize +///\brief Sets number of I/O vectors to be read/written in hyperslab I/O. +///\exception H5::PropListIException +///\par Description +/// For information, please refer to the C layer Reference +/// Manual at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetHyperVectorSize +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +void DSetMemXferPropList::setHyperVectorSize(size_t vector_size) +{ + herr_t ret_value = H5Pset_hyper_vector_size(id, vector_size); + if (ret_value < 0) { - throw PropListIException("DSetMemXferPropList::setXfer", - "H5Pset_xfer failed"); + throw PropListIException("DSetMemXferPropList::setHyperVectorSize", + "H5Pset_hyper_vector_size failed"); } } -// this function is in parallel mode only - not supported at this time. -// Gets the transfer mode -H5D_transfer_t DSetMemXferPropList::getXfer() const +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getSmallDataBlockSize +///\brief Returns the number of I/O vectors to be read/written in +/// hyperslab I/O. +///\return Number of I/O vectors +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +size_t DSetMemXferPropList::getHyperVectorSize() { - H5D_transfer_t xfer = H5Pget_xfer( id ); -// BMR - need to find out what the value is for ?? when this function -// is supported - if( xfer == ?? ) + size_t vector_size; + herr_t ret_value = H5Pget_hyper_vector_size(id, &vector_size); + if (ret_value < 0) { - throw PropListIException("DSetMemXferPropList::getXfer", - "H5Pget_xfer failed"); + throw PropListIException("DSetMemXferPropList::getHyperVectorSize", + "H5Pget_hyper_vector_size failed"); } - return( xfer ); + return(vector_size); } -*/ +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::setEDCCheck +///\brief Enables or disables error-detecting for a dataset reading +/// process. +///\param check - IN: Specifies whether error detection is enabled or +/// disabled +///\exception H5::PropListIException +///\par Description +/// The error detection algorithm used is the algorithm previously +/// specified in the corresponding dataset creation property +/// list. This function does not affect the use of error +/// detection in the writing process. +///\par +/// Valid values are as follows: +/// \li \c H5Z_ENABLE_EDC (default) +/// \li \c H5Z_DISABLE_EDC +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +void DSetMemXferPropList::setEDCCheck(H5Z_EDC_t check) +{ + herr_t ret_value = H5Pset_edc_check(id, check); + if (ret_value < 0) + { + throw PropListIException("DSetMemXferPropList::setEDCCheck", + "H5Pset_edc_check failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList::getEDCCheck +///\brief Determines whether error-detection is enabled for dataset reads. +///\return \c H5Z_ENABLE_EDC or \c H5Z_DISABLE_EDC +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - July, 2004 +//-------------------------------------------------------------------------- +H5Z_EDC_t DSetMemXferPropList::getEDCCheck() +{ + H5Z_EDC_t check = H5Pget_edc_check(id); + if (check < 0) + { + throw PropListIException("DSetMemXferPropList::getEDCCheck", + "H5Pget_edc_check failed"); + } + return(check); +} -// Default destructor +//-------------------------------------------------------------------------- +// Function: DSetMemXferPropList destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- DSetMemXferPropList::~DSetMemXferPropList() {} #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index e071870..652af55 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -31,31 +31,24 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { DSetMemXferPropList( const DSetMemXferPropList& orig ); #ifdef H5_WANT_H5_V1_4_COMPAT - // Sets type conversion and background buffers - void setBuffer( hsize_t size, void* tconv, void* bkg ) const; + // Sets type conversion and background buffers + void setBuffer( hsize_t size, void* tconv, void* bkg ) const; - // Reads buffer settings - hsize_t getBuffer( void** tconv, void** bkg ) const; -#else /* H5_WANT_H5_V1_4_COMPAT */ - // Sets type conversion and background buffers - void setBuffer( size_t size, void* tconv, void* bkg ) const; + // Reads buffer settings + hsize_t getBuffer( void** tconv, void** bkg ) const; - // Reads buffer settings - size_t getBuffer( void** tconv, void** bkg ) const; -#endif /* H5_WANT_H5_V1_4_COMPAT */ + // Indicates whether to cache hyperslab blocks during I/O + void setHyperCache( bool cache, unsigned limit = 0 ) const; - // Sets the dataset transfer property list status to TRUE or FALSE - void setPreserve( bool status ) const; + // Returns information regarding the caching of hyperslab blocks during I/O + void getHyperCache( bool& cache, unsigned& limit ) const; - // Checks status of the dataset transfer property list - bool getPreserve() const; - -#ifdef H5_WANT_H5_V1_4_COMPAT - // Indicates whether to cache hyperslab blocks during I/O - void setHyperCache( bool cache, unsigned limit = 0 ) const; +#else /* H5_WANT_H5_V1_4_COMPAT */ + // Sets type conversion and background buffers + void setBuffer( size_t size, void* tconv, void* bkg ) const; - // Returns information regarding the caching of hyperslab blocks during I/O - void getHyperCache( bool& cache, unsigned& limit ) const; + // Reads buffer settings + size_t getBuffer( void** tconv, void** bkg ) const; #endif /* H5_WANT_H5_V1_4_COMPAT */ // Sets B-tree split ratios for a dataset transfer property list @@ -64,6 +57,12 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { // Gets B-tree split ratios for a dataset transfer property list void getBtreeRatios( double& left, double& middle, double& right ) const; + // Sets the dataset transfer property list status to TRUE or FALSE + void setPreserve( bool status ) const; + + // Checks status of the dataset transfer property list + bool getPreserve() const; + // Sets the memory manager for variable-length datatype // allocation in H5Dread and H5Dvlen_reclaim void setVlenMemManager( H5MM_allocate_t alloc, void* alloc_info, @@ -78,11 +77,31 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { void getVlenMemManager( H5MM_allocate_t& alloc, void** alloc_info, H5MM_free_t& free, void** free_info ) const; - // Sets the transfer mode - parallel mode, not currently supported - //void setXfer( H5D_transfer_t data_xfer_mode = H5D_XFER_INDEPENDENT ) const; + // Sets the data transfer property list for the multi-file driver. + void setMulti(const hid_t *memb_dxpl); + + // Returns multi-file data transfer property list information. + void getMulti(hid_t *memb_dxpl); + + // Sets the size of a contiguous block reserved for small data. + void setSmallDataBlockSize(hsize_t size); + + // Returns the current small data block size setting. + hsize_t getSmallDataBlockSize(); + + // Sets number of I/O vectors to be read/written in hyperslab I/O. + void setHyperVectorSize(size_t vector_size); + + // Returns the number of I/O vectors to be read/written in + // hyperslab I/O. + size_t getHyperVectorSize(); + + // Enables or disables error-detecting for a dataset reading + // process. + void setEDCCheck(H5Z_EDC_t check); - // Gets the transfer mode - parallel mode, not currently supported - //H5D_transfer_t getXfer() const; + // Determines whether error-detection is enabled for dataset reads. + H5Z_EDC_t getEDCCheck(); // Creates a copy of an existing dataset memory and transfer // property list using the property list id diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index 1e33ce3..36b127f 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -25,145 +25,447 @@ namespace H5 { #endif +//-------------------------------------------------------------------------- +///\brief Constant for default property +//-------------------------------------------------------------------------- const FileAccPropList FileAccPropList::DEFAULT( H5P_DEFAULT ); -// Creates a file access property list +//-------------------------------------------------------------------------- +// Function: Default Constructor +///\brief Default constructor: Creates a file access property list +//-------------------------------------------------------------------------- FileAccPropList::FileAccPropList() : PropList( H5P_FILE_ACCESS ) {} -// Copy constructor: makes a copy of the original FileAccPropList object; -FileAccPropList::FileAccPropList( const FileAccPropList& orig ) : PropList( orig ) {} +//-------------------------------------------------------------------------- +// Function: Copy Constructor +///\brief Copy Constructor: Makes a copy of the original +/// FileAccPropList object +//-------------------------------------------------------------------------- +FileAccPropList::FileAccPropList(const FileAccPropList& orig) : PropList(orig) {} -/* commented out for 1.3.x, only in 1.2.x +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setStdio +///\brief Modifies this property list to use the \c H5FD_STDIO driver +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- void FileAccPropList::setStdio() const { - herr_t ret_value = H5Pset_stdio( id ); + herr_t ret_value = H5Pset_fapl_stdio(id); if( ret_value < 0 ) { - throw PropListIException("FileAccPropList::setStdio", "H5Pset_stdio failed"); + throw PropListIException("FileAccPropList::setStdio", "H5Pset_fapl_stdio failed"); } } -bool FileAccPropList::getStdio() const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getDriver +///\brief Return the ID of the low-level file driver. +///\return A low-level driver ID which is the same ID used when the +/// driver was set for the property list. The driver ID is +/// only valid as long as the file driver remains registered. +/// Valid driver identifiers can be found at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-GetDriver +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +hid_t FileAccPropList::getDriver() const { - herr_t ret_value = H5Pget_stdio( id ); - if( ret_value < 0 ) - return( false ); - else - return( true ); + hid_t driver = H5Pget_driver( id ); + if (driver < 0) + { + throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed"); + } + return( driver ); } -H5F_driver_t FileAccPropList::getDriver() const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setDriver +///\brief Set file driver for this property list +///\param new_driver_id - IN: File driver +///\param new_driver_info - IN: Struct containing the driver-specific properites +///\exception H5::PropListIException +///\par Description +/// For a list of valid driver identifiers, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-GetDriver +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setDriver(hid_t new_driver_id, const void *new_driver_info) const { - H5F_driver_t driver = H5Pget_driver( id ); - if( driver == H5F_LOW_ERROR ) + herr_t ret_value = H5Pset_driver(id, new_driver_id, new_driver_info); + if (ret_value < 0) { - throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed"); + throw PropListIException("FileAccPropList::setDriver", "H5Pset_driver failed"); } - return( driver ); } -void FileAccPropList::setSec2() const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setFamilyOffset +///\brief Sets offset for family driver. +///\param offset - IN: offset value +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setFamilyOffset(hsize_t offset) const { - herr_t ret_value = H5Pset_sec2( id ); - if( ret_value < 0 ) + herr_t ret_value = H5Pset_family_offset(id, offset); + if (ret_value < 0) { - throw PropListIException("FileAccPropList::setSec2", "H5Pset_sec2 failed"); + throw PropListIException("FileAccPropList::setFamilyOffset", "H5Pset_family_offset failed"); } } -bool FileAccPropList::getSec2() const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getFamilyOffset +///\brief Get offset for family driver. +///\return Offset for family driver +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +hsize_t FileAccPropList::getFamilyOffset() const { - herr_t ret_value = H5Pget_sec2( id ); - if( ret_value < 0 ) - return( false ); - else - return( true ); + hsize_t offset; + herr_t ret_value = H5Pget_family_offset(id, &offset); + if (ret_value < 0) + { + throw PropListIException("FileAccPropList::getFamilyOffset", "H5Pget_family_offset failed"); + } + return(offset); } -void FileAccPropList::setCore( size_t increment ) const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setCore +///\brief Modifies this file access property list to use the \c H5FD_CORE +/// driver. +///\param increment - IN: Specifies how much memory to increase each +/// time more memory is needed, in bytes +///\param backing_store - IN: Indicating whether to write the file +/// contents to disk when the file is closed +///\exception H5::PropListIException +///\par Description +/// For more details on the use of \c H5FD_CORE driver, please +/// refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetFaplCore +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setCore (size_t increment, hbool_t backing_store) const { - herr_t ret_value = H5Pset_core( id, increment ); - if( ret_value < 0 ) + herr_t ret_value = H5Pset_fapl_core (id, increment, backing_store); + if (ret_value < 0) { - throw PropListIException("FileAccPropList::setCore", "H5Pset_core failed"); + throw PropListIException ("FileAccPropList::setCore", "H5Pset_fapl_core failed"); } } -bool FileAccPropList::getCore( size_t& increment) const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getCore +///\brief Queries core file driver properties. +///\param increment - OUT: Size of memory increment, in bytes +///\param backing_store - OUT: Indicating whether to write the file +/// contents to disk when the file is closed +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::getCore (size_t& increment, hbool_t& backing_store) const { - herr_t ret_value = H5Pget_core( id, &increment ); + herr_t ret_value = H5Pget_fapl_core(id, &increment, &backing_store); if( ret_value < 0 ) - return( false ); - else - return( true ); + { + throw PropListIException("FileAccPropList::getCore", "H5Pget_fapl_core failed"); + } } +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setFamily +///\brief Sets this file access property list to use the family driver. +///\param memb_size - IN: Size in bytes of each file member +///\param memb_plist - IN: File access property list to be used for +/// each family member +///\exception H5::PropListIException +///\par Description +/// Note that \a memb_size is used only when creating a new file. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- void FileAccPropList::setFamily( hsize_t memb_size, const FileAccPropList& memb_plist ) const { - herr_t ret_value = H5Pset_family( id, memb_size, memb_plist.getId() ); + herr_t ret_value = H5Pset_fapl_family (id, memb_size, memb_plist.getId() ); if( ret_value < 0 ) { - throw PropListIException("FileAccPropList::setFamily", "H5Pset_family failed"); + throw PropListIException("FileAccPropList::setFamily", "H5Pset_fapl_family failed"); } } -//Note: working on this return value here. added copy constructor -//that uses PropList copy const. but din't work -// Determines whether the file access property list is set to the family -// driver then retrieves the family member's property list and returns -// true or false -bool FileAccPropList::getFamily( hsize_t& memb_size, FileAccPropList& memb_plist ) const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getFamily +///\brief Returns information about the family file access property +/// list. +///\param memb_size - OUT: Size in bytes of each file member +///\param memb_plist - OUT: Retrieved file access property list for each +/// file member +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const { hid_t memb_plist_id; - herr_t ret_value = H5Pget_family( id, &memb_size, &memb_plist_id ); + herr_t ret_value = H5Pget_fapl_family( id, &memb_size, &memb_plist_id ); if( ret_value < 0 ) { - memb_plist.setId( 0 ); - return( false ); + throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } - else + memb_plist.setId(memb_plist_id); +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getFamily +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts and its return value. +///\param memb_size - OUT: Size in bytes of each file member +///\return The file access property list for each file member +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +FileAccPropList FileAccPropList::getFamily(hsize_t& memb_size) const +{ + hid_t memb_plist_id; + herr_t ret_value = H5Pget_fapl_family( id, &memb_size, &memb_plist_id ); + if( ret_value < 0 ) { - memb_plist.setId( memb_plist_id ); - return( true ); + throw PropListIException("FileAccPropList::getFamily", "H5Pget_fapl_family failed"); } + FileAccPropList memb_plist(memb_plist_id); + return(memb_plist); } +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setSplit +///\brief Emulates the old split file driver, which stored meta data +/// in one file and raw data in another file. +///\param meta_plist - IN: File access plist for the metadata file +///\param raw_plist - IN: File access plist for the raw data file +///\param meta_ext - IN: Metadata filename extension as \c char* +///\param raw_ext - IN: Raw data filename extension as \c char* +///\exception H5::PropListIException +///\par Description +/// Temporary - For information, please refer to: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetFaplSplit +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- void FileAccPropList::setSplit( FileAccPropList& meta_plist, FileAccPropList& raw_plist, const char* meta_ext, const char* raw_ext ) const { hid_t meta_pid = meta_plist.getId(); hid_t raw_pid = raw_plist.getId(); - herr_t ret_value = H5Pset_split( id, meta_ext, meta_pid, raw_ext, raw_pid ); + herr_t ret_value = H5Pset_fapl_split( id, meta_ext, meta_pid, raw_ext, raw_pid ); if( ret_value < 0 ) - { - throw PropListIException("FileAccPropList::setSplit", "H5Pset_split failed"); +{ + throw PropListIException("FileAccPropList::setSplit", "H5Pset_fapl_split failed"); } } +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setSplit +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param meta_plist - IN: File access plist for the metadata file +///\param raw_plist - IN: File access plist for the raw data file +///\param meta_ext - IN: Metadata filename extension as \c string +///\param raw_ext - IN: Raw data filename extension as \c string +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- void FileAccPropList::setSplit( FileAccPropList& meta_plist, FileAccPropList& raw_plist, const string& meta_ext, const string& raw_ext ) const { setSplit( meta_plist, raw_plist, meta_ext.c_str(), raw_ext.c_str() ); } -void FileAccPropList::getSplit( size_t meta_ext_size, string& meta_ext, FileAccPropList& meta_plist, size_t raw_ext_size, string& raw_ext, FileAccPropList& raw_plist ) const +#ifdef H5_HAVE_STREAM // for Stream Virtual File Driver +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getStream +///\brief Retrieves the streaming I/O driver settings +///\return The streaming I/O file access property list structure +/// For detail on this structure, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetFaplStream +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +H5FD_stream_fapl_t FileAccPropList::getStream() const +{ + H5FD_stream_fapl_t fapl; + herr_t ret_value = H5Pget_fapl_stream(id, &fapl); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::getStream", "H5Pget_fapl_stream failed"); + } + return(fapl); +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setStream +///\brief Modifies this file access property list to use the Stream +/// driver. +///\param fapl - IN: The streaming I/O file access property list +///\exception H5::PropListIException +///\par Description +/// For detail on \a fapl, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetFaplStream +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setStream(H5FD_stream_fapl_t &fapl) const +{ + herr_t ret_value = H5Pset_fapl_stream (id, &fapl); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::setStream", "H5Pset_fapl_stream failed"); + } +} +#endif // Stream Virtual File Driver + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getSieveBufSize +///\brief Returns the current settings for the data sieve buffer size +/// property from this property list. +///\return Data sieve buffer size, in bytes +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +size_t FileAccPropList::getSieveBufSize() const +{ + size_t bufsize; + herr_t ret_value = H5Pget_sieve_buf_size(id, &bufsize); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); + } + return(bufsize); +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setSieveBufSize +///\brief Sets the maximum size of the data sieve buffer. +///\param bufsize - IN: Maximum size, in bytes, of data sieve buffer +///\exception H5::PropListIException +///\par Description +/// For detail on data sieving, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetSieveBufSize +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setSieveBufSize(size_t bufsize) const +{ + herr_t ret_value = H5Pset_sieve_buf_size(id, bufsize); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::getSieveBufSize", "H5Pget_sieve_buf_size failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setMetaBlockSize +///\brief Sets the minimum size of metadata block allocations. +///\param block_size - IN: Minimum size, in bytes, of metadata +/// block allocations +///\exception H5::PropListIException +///\par Description +/// For more detail, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetMetaBlockSize +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setMetaBlockSize(hsize_t &block_size) const +{ + herr_t ret_value = H5Pset_meta_block_size(id, block_size); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::setMetaBlockSize", "H5Pset_meta_block_size failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getMetaBlockSize +///\brief Returns the current metadata block size setting. +///\return Metadata block size +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +hsize_t FileAccPropList::getMetaBlockSize() const { - hid_t meta_plist_id, raw_plist_id; // meta-data and raw-data plist ids - char* meta_ext_C = new char[meta_ext_size]; // meta-data extension in C - char* raw_ext_C = new char[raw_ext_size]; // raw-data extension in C - herr_t ret_value = H5Pget_split( id, meta_ext_size, meta_ext_C, - &meta_plist_id, raw_ext_size, raw_ext_C, &raw_plist_id ); + hsize_t block_size; + herr_t ret_value = H5Pget_meta_block_size(id, &block_size); if( ret_value < 0 ) { - throw PropListIException("FileAccPropList::getSplit", "H5Pget_split failed"); + throw PropListIException("FileAccPropList::getMetaBlockSize", "H5Pget_meta_block_size failed"); } - meta_plist.setId( meta_plist_id ); - raw_plist.setId( raw_plist_id ); - raw_ext = string( raw_ext_C ); - meta_ext = string( raw_ext_C ); - delete [] raw_ext_C; - delete [] meta_ext_C; + return(block_size); } -*/ +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setLog +///\brief Modifies this file access property list to use the logging +/// driver. +///\param logfile - IN: Name of the log file +///\param flags - IN: Flags specifying the types of logging activity +///\param buf_size - IN: Size of the logging buffer +///\exception H5::PropListIException +///\par Description +/// For detail on \a flags, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetFaplStream +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setLog(const char *logfile, unsigned flags, size_t buf_size) const +{ + herr_t ret_value = H5Pset_fapl_log(id, logfile, flags, buf_size); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::setLog", "H5Pset_fapl_log failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setLog +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param logfile - IN: Name of the log file - string +///\param flags - IN: Flags specifying the types of logging activity +///\param buf_size - IN: Size of the logging buffer +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setLog(const string& logfile, unsigned flags, size_t buf_size) const +{ + setLog(logfile.c_str(), flags, buf_size); +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setSec2 +///\brief Modifies this file access property list to use the sec2 +/// driver. +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setSec2() const +{ + herr_t ret_value = H5Pset_fapl_sec2(id); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::setSec2", "H5Pset_fapl_sec2 failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setAlignment +///\brief Sets the alignment properties of this property list. +///\param threshold - IN: Threshold value for file object size +///\param alignment - IN: Alignment value +///\exception H5::PropListIException +///\par Description +/// The parameter \a threshold must have a non-negative value. +/// Note that setting the threshold value to 0 (zero) has the +/// effect of a special case, forcing everything to be aligned. +/// The parameter \a alignment must have a positive value. +/// +/// For detail on \a setting alignment, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetAlignment +//-------------------------------------------------------------------------- void FileAccPropList::setAlignment( hsize_t threshold, hsize_t alignment ) const { herr_t ret_value = H5Pset_alignment( id, threshold, alignment ); @@ -173,7 +475,15 @@ void FileAccPropList::setAlignment( hsize_t threshold, hsize_t alignment ) const } } -void FileAccPropList::getAlignment( hsize_t& threshold, hsize_t& alignment ) const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getAlignment +///\brief Returns the current settings for alignment properties from +/// this property list. +///\param threshold - OUT: Retrieved threshold value for file object size +///\param alignment - OUT: Retrieved alignment value +///\exception H5::PropListIException +//-------------------------------------------------------------------------- +void FileAccPropList::getAlignment( hsize_t &threshold, hsize_t &alignment ) const { herr_t ret_value = H5Pget_alignment( id, &threshold, &alignment ); if( ret_value < 0 ) @@ -182,27 +492,62 @@ void FileAccPropList::getAlignment( hsize_t& threshold, hsize_t& alignment ) con } } -/* MPI_Comm and MPI_Info not declared in serial mode so leave these -routines out until C++ API needs to deal with parallel -void FileAccPropList::setMpi( MPI_Comm comm, MPI_Info info ) const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setMultiType +///\brief Sets data type for \c MULTI driver. +///\param dtype - IN: Type of data +///\exception H5::PropListIException +///\par Description +/// More details and valid values for \a dtype can be found at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetMultiType +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setMultiType(H5FD_mem_t dtype) const { - herr_t ret_value = H5Pset_mpi( id, comm, info ); + herr_t ret_value = H5Pset_multi_type(id, dtype); if( ret_value < 0 ) { - throw PropListIException("FileAccPropList::setMpi", "H5Pset_mpi failed"); + throw PropListIException("FileAccPropList::setMultiType", "H5Pset_multi_type failed"); } } -void FileAccPropList::getMpi( MPI_Comm& comm, MPI_Info& info ) const +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getMultiType +///\brief Returns the data type property for \c MULTI driver. +///\return The data type property +///\exception H5::PropListIException +///\par Description +/// More details and possible returned values can be found at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-GetMultiType +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +H5FD_mem_t FileAccPropList::getMultiType() const { - herr_t ret_value = H5Pget_mpi( id, &comm, &info ); + H5FD_mem_t dtype; + herr_t ret_value = H5Pget_multi_type(id, &dtype); if( ret_value < 0 ) - return( false ); - else - return( true ); + { + throw PropListIException("FileAccPropList::getMultiType", "H5Pget_multi_type failed"); + } + return(dtype); } -*/ +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setCache +///\brief Sets the meta data cache and raw data chunk cache parameters. +///\param mdc_nelmts - IN: Number of elements in the meta data cache +///\param rdcc_nelmts - IN: Number of elements in the raw data chunk cache +///\param rdcc_nbytes - IN: Total size of the raw data chunk cache, in bytes +///\param rdcc_w0 - IN: Preemption policy +///\exception H5::PropListIException +///\par Description +/// The argument \a rdcc_w0 should hold a value between 0 and 1 +/// inclusive. This value indicates how much chunks that have +/// been fully read are favored for preemption. A value of zero +/// means fully read chunks are treated no differently than other +/// chunks (the preemption is strictly LRU) while a value of one +/// means fully read chunks are always preempted before other chunks. +//-------------------------------------------------------------------------- #ifdef H5_WANT_H5_V1_4_COMPAT void FileAccPropList::setCache( int mdc_nelmts, int rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0 ) const { @@ -213,6 +558,15 @@ void FileAccPropList::setCache( int mdc_nelmts, int rdcc_nelmts, size_t rdcc_nby } } +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getCache +///\brief Queries the meta data cache and raw data chunk cache parameters. +///\param mdc_nelmts - OUT: Number of elements in the meta data cache +///\param rdcc_nelmts - OUT: Number of elements in the raw data chunk cache +///\param rdcc_nbytes - OUT: Total size of the raw data chunk cache, in bytes +///\param rdcc_w0 - OUT: Preemption policy +///\exception H5::PropListIException +//-------------------------------------------------------------------------- void FileAccPropList::getCache( int& mdc_nelmts, int& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0 ) const { herr_t ret_value = H5Pget_cache( id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0 ); @@ -222,6 +576,22 @@ void FileAccPropList::getCache( int& mdc_nelmts, int& rdcc_nelmts, size_t& rdcc_ } } #else /* H5_WANT_H5_V1_4_COMPAT */ +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setCache +///\brief Sets the meta data cache and raw data chunk cache parameters. +///\param mdc_nelmts - IN: Number of elements in the meta data cache +///\param rdcc_nelmts - IN: Number of elements in the raw data chunk cache +///\param rdcc_nbytes - IN: Total size of the raw data chunk cache, in bytes +///\param rdcc_w0 - IN: Preemption policy +///\exception H5::PropListIException +///\par Description +/// The argument \a rdcc_w0 should hold a value between 0 and 1 +/// inclusive. This value indicates how much chunks that have +/// been fully read are favored for preemption. A value of zero +/// means fully read chunks are treated no differently than other +/// chunks (the preemption is strictly LRU) while a value of one +/// means fully read chunks are always preempted before other chunks. +//-------------------------------------------------------------------------- void FileAccPropList::setCache( int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0 ) const { herr_t ret_value = H5Pset_cache( id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0 ); @@ -231,6 +601,15 @@ void FileAccPropList::setCache( int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_ } } +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getCache +///\brief Queries the meta data cache and raw data chunk cache parameters. +///\param mdc_nelmts - OUT: Number of elements in the meta data cache +///\param rdcc_nelmts - OUT: Number of elements in the raw data chunk cache +///\param rdcc_nbytes - OUT: Total size of the raw data chunk cache, in bytes +///\param rdcc_w0 - OUT: Preemption policy +///\exception H5::PropListIException +//-------------------------------------------------------------------------- void FileAccPropList::getCache( int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0 ) const { herr_t ret_value = H5Pget_cache( id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0 ); @@ -241,6 +620,50 @@ void FileAccPropList::getCache( int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rd } #endif /* H5_WANT_H5_V1_4_COMPAT */ +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setFcloseDegree +///\brief Sets the degree for the file close behavior. +///\param degree - IN: +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void FileAccPropList::setFcloseDegree(H5F_close_degree_t degree) +{ + herr_t ret_value = H5Pset_fclose_degree(id, degree); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::setFcloseDegree", "H5Pset_fclose_degree failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getFcloseDegree +///\brief Returns the degree for the file close behavior. +///\return The degree for the file close behavior +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +H5F_close_degree_t FileAccPropList::getFcloseDegree() +{ + H5F_close_degree_t degree; + herr_t ret_value = H5Pget_fclose_degree(id, °ree); + if( ret_value < 0 ) + { + throw PropListIException("FileAccPropList::getFcloseDegree", "H5Pget_fclose_degree failed"); + } + return(degree); +} + +//-------------------------------------------------------------------------- +// Function: FileAccPropList::setGcReferences +///\brief Sets garbage collecting references flag. +///\param gc_ref - IN: Flag setting reference garbage collection to +/// on (1) or off (0). +///\exception H5::PropListIException +///\par Description +/// For detail on \a fapl, please refer to +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetFaplStream +//-------------------------------------------------------------------------- void FileAccPropList::setGcReferences( unsigned gc_ref ) const { herr_t ret_value = H5Pset_gc_references( id, gc_ref ); @@ -250,6 +673,12 @@ void FileAccPropList::setGcReferences( unsigned gc_ref ) const } } +//-------------------------------------------------------------------------- +// Function: FileAccPropList::getGcReferences +///\brief Returns the garbage collecting references setting. +///\return Garbage collecting references setting, 0 (off) or 1 (on) +///\exception H5::PropListIException +//-------------------------------------------------------------------------- unsigned FileAccPropList::getGcReferences() const { unsigned gc_ref; @@ -263,6 +692,11 @@ unsigned FileAccPropList::getGcReferences() const return( gc_ref ); } +//-------------------------------------------------------------------------- +// Function: FileAccPropList destructor +///\brief Noop destructor +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- FileAccPropList::~FileAccPropList() {} #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index c55d70d..e10c7d0 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -29,84 +29,95 @@ class H5_DLLCPP FileAccPropList : public PropList { FileAccPropList(); // Copy constructor: creates a copy of a FileAccPropList object - FileAccPropList( const FileAccPropList& orig ); + FileAccPropList( const FileAccPropList& original ); - // Sets the low level file driver to use the functions - // declared in the stdio.h - // void setStdio() const; + // Modifies this property list to use the H5FD_STDIO driver + void setStdio() const; - // Determines whether the file access property list is set to the - // stdio driver. - // bool getStdio() const; + // Set file driver for this property list + void setDriver(hid_t new_driver_id, const void *new_driver_info) const; - // Sets alignment properties of this file access property list - void setAlignment( hsize_t threshold = 1, hsize_t alignment = 1 ) const; + // Returns a low-level file driver identifier. + hid_t getDriver() const; - // Retrieves the current settings for alignment properties from - // this file access property list. - void getAlignment( hsize_t& threshold, hsize_t& alignment ) const; + // Sets offset for family driver. + void setFamilyOffset(hsize_t offset) const; - /* MPI stuff not working in serial mode - //void setMpi( MPI_Comm comm, MPI_Info info ) const; - //void getMpi( MPI_Comm& comm, MPI_Info& info ) const; - */ + // Gets offset for family driver. + hsize_t getFamilyOffset() const; - // Returns a low-level file driver identifier. - // H5F_driver_t getDriver() const; + // Modifies this file access property list to use the sec2 driver. + void setSec2() const; - // Sets the low-level file driver to use the declared functions. - // void setSec2() const; + // Modifies this file access property list to use the H5FD_CORE + // driver. + void setCore (size_t increment, hbool_t backing_store) const; - // Determines whether this file access property list is set to the - // sec2 driver. - // bool getSec2() const; + // Queries H5FD_CORE driver properties. + void getCore (size_t& increment, hbool_t& backing_store) const; - // Sets the low-level file driver to use malloc() and free(). - // void setCore( size_t increment ) const; + // Sets this file access properties list to the family driver. + void setFamily( hsize_t memb_size, const FileAccPropList& memb_plist ) const; - // Determines whether this file access property list is set to the - // core driver and retrieves the increment. - // bool getCore( size_t& increment ) const; + // Returns information about the family file access property list. + void getFamily(hsize_t& memb_size, FileAccPropList& memb_plist) const; + FileAccPropList getFamily(hsize_t& memb_size) const; - // Sets this file access properties list to the family driver. - // void setFamily( hsize_t memb_size, const FileAccPropList& memb_plist ) const; + // Emulates the old split file driver, + void setSplit( FileAccPropList& meta_plist, FileAccPropList& raw_plist, + const char* meta_ext = ".meta", const char* raw_ext = ".raw" ) const; + void setSplit( FileAccPropList& meta_plist, FileAccPropList& raw_plist, + const string& meta_ext, const string& raw_ext ) const; - // Determines whether this file access property list is set to the - // family driver and retrieves the member's file access property list. - // bool getFamily( hsize_t& memb_size, FileAccPropList& memb_plist ) const; +#ifdef H5_HAVE_STREAM // for Stream Virtual File Driver + // Modifies this file access property list to use the Stream driver. + void setStream(H5FD_stream_fapl_t &fapl) const; -#ifdef H5_WANT_H5_V1_4_COMPAT - // Sets the meta data cache and raw data chunk cache parameters. - void setCache( int mdc_nelmts, int rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0 ) const; + // Retrieves the streaming I/O driver settings + H5FD_stream_fapl_t getStream() const; +#endif + + // Sets the maximum size of the data sieve buffer. + void setSieveBufSize(size_t bufsize) const; + + // Returns the current settings for the data sieve buffer size + // property + size_t getSieveBufSize() const; + + // Sets the minimum size of metadata block allocations. + void setMetaBlockSize(hsize_t &block_size) const; + + // Returns the current metadata block size setting. + hsize_t getMetaBlockSize() const; + + // Modifies this file access property list to use the logging driver. + void setLog(const char *logfile, unsigned flags, size_t buf_size) const; + void setLog(const string& logfile, unsigned flags, size_t buf_size) const; + + // Sets alignment properties of this file access property list + void setAlignment( hsize_t threshold = 1, hsize_t alignment = 1 ) const; + + // Retrieves the current settings for alignment properties from + // this property list. + void getAlignment( hsize_t& threshold, hsize_t& alignment ) const; + + // Sets data type for multi driver. + void setMultiType(H5FD_mem_t dtype) const; + + // Returns the data type property for MULTI driver. + H5FD_mem_t getMultiType() const; - // Retrieves maximum sizes of data caches and the preemption - // policy value. - void getCache( int& mdc_nelmts, int& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0 ) const; -#else /* H5_WANT_H5_V1_4_COMPAT */ // Sets the meta data cache and raw data chunk cache parameters. void setCache( int mdc_nelmts, size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0 ) const; - // Retrieves maximum sizes of data caches and the preemption - // policy value. + // Queries the meta data cache and raw data chunk cache parameters. void getCache( int& mdc_nelmts, size_t& rdcc_nelmts, size_t& rdcc_nbytes, double& rdcc_w0 ) const; -#endif /* H5_WANT_H5_V1_4_COMPAT */ - - // Sets the low-level driver to split meta data from raw data. - // void setSplit( FileAccPropList& meta_plist, FileAccPropList& raw_plist, - // const char* meta_ext = ".meta", const char* raw_ext = ".raw" ) const; - - // void setSplit( FileAccPropList& meta_plist, FileAccPropList& raw_plist, - // const string& meta_ext, const string& raw_ext ) const; - // Determines whether this file access property list is set to the - // split driver and retrieves the meta-data and raw-data property lists. - // void getSplit( size_t meta_ext_size, string& meta_ext, FileAccPropList& - // meta_plist, size_t raw_ext_size, string& raw_ext, FileAccPropList& - // raw_plist ) const; + // Sets the degree for the file close behavior. + void setFcloseDegree(H5F_close_degree_t degree); - // Proposal: 2 separate functions - //FileAccPropList getMetaPlist( size_t meta_ext_size, char* meta_ext ); - //FileAccPropList getRawPlist( size_t raw_ext_size, char* raw_ext ); + // Returns the degree for the file close behavior. + H5F_close_degree_t getFcloseDegree(); // Sets garbage collecting references flag. void setGcReferences( unsigned gc_ref = 0 ) const; diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index 404aca2..f2a683a 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -25,18 +25,42 @@ namespace H5 { #endif +//-------------------------------------------------------------------------- +///\brief Constant for default property +//-------------------------------------------------------------------------- const FileCreatPropList FileCreatPropList::DEFAULT( H5P_DEFAULT ); -// Creates a file create property list +//-------------------------------------------------------------------------- +// Function: FileCreatPropList default constructor +///\brief Default constructor: Creates a file create property list +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- FileCreatPropList::FileCreatPropList() : PropList( H5P_FILE_CREATE ) {} -// Copy constructor: makes a copy of the original FileCreatPropList object; -FileCreatPropList::FileCreatPropList( const FileCreatPropList& orig ) : PropList( orig ) {} +//-------------------------------------------------------------------------- +// Function: FileCreatPropList copy constructor +///\brief Copy constructor: makes a copy of the original FileCreatPropList object. +///\param original - IN: FileCreatPropList instance to copy +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- +FileCreatPropList::FileCreatPropList(const FileCreatPropList& original) : PropList(original) {} +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::getVersion +///\brief Retrieves version information for various parts of a file. +///\param super - OUT: The file super block. +///\param freelist - OUT: The global free list. +///\param stab - OUT: The root symbol table entry. +///\param shhdr - OUT: Shared object headers. +///\exception H5::PropListIException +///\par Description +/// Any (or even all) of the output arguments can be null pointers. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::getVersion( - int& boot, int& freelist, int& stab, int& shhdr ) const + int& super, int& freelist, int& stab, int& shhdr ) const { - herr_t ret_value = H5Pget_version( id, &boot, &freelist, &stab, &shhdr ); + herr_t ret_value = H5Pget_version( id, &super, &freelist, &stab, &shhdr ); if( ret_value < 0 ) { throw PropListIException("FileCreatPropList::getVersion", @@ -44,6 +68,16 @@ void FileCreatPropList::getVersion( } } +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::setUserblock +///\brief Sets the user block size field of this file creation property list. +///\param size - IN: User block size to be set, in bytes +///\exception H5::PropListIException +///\par Description +/// The default user block size is 0; it may be set to any power +/// of 2 equal to 512 or greater (512, 1024, 2048, etc.) +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::setUserblock( hsize_t size ) const { herr_t ret_value = H5Pset_userblock( id, size); @@ -54,6 +88,13 @@ void FileCreatPropList::setUserblock( hsize_t size ) const } } +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::getUserblock +///\brief Returns the user block size of this file creation property list. +///\return User block size +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- hsize_t FileCreatPropList::getUserblock() const { hsize_t userblock_size; @@ -66,6 +107,19 @@ hsize_t FileCreatPropList::getUserblock() const return( userblock_size ); } +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::setSizes +///\brief Sets the byte size of the offsets and lengths used to +/// address objects in an HDF5 file. +///\param sizeof_addr - IN: Size of an object offset in bytes +///\param sizeof_size - IN: Size of an object length in bytes. +///\exception H5::PropListIException +///\par Description +/// For information on setting sizes, please refer to the +/// C layer Reference Manual at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetSizes +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::setSizes( size_t sizeof_addr, size_t sizeof_size ) const { herr_t ret_value = H5Pset_sizes( id, sizeof_addr, sizeof_size ); @@ -76,6 +130,13 @@ void FileCreatPropList::setSizes( size_t sizeof_addr, size_t sizeof_size ) const } } +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::getSizes +///\brief Retrieves the size of the offsets and lengths used in an +/// HDF5 file. +///\exception H5::PropListIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::getSizes( size_t& sizeof_addr, size_t& sizeof_size ) const { herr_t ret_value = H5Pget_sizes( id, &sizeof_addr, &sizeof_size ); @@ -87,6 +148,18 @@ void FileCreatPropList::getSizes( size_t& sizeof_addr, size_t& sizeof_size ) con } #ifdef H5_WANT_H5_V1_4_COMPAT +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::setSymk +///\brief Sets the size of parameters used to control the symbol table +/// nodes. +///\param ik - IN: Symbol table tree rank +///\param lk - IN: Symbol table node size +///\exception H5::PropListIException +///\par Description +/// For information, please see the C layer Reference Manual at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetSymK +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::setSymk( int ik, int lk ) const { herr_t ret_value = H5Pset_sym_k( id, ik, lk ); @@ -97,6 +170,16 @@ void FileCreatPropList::setSymk( int ik, int lk ) const } } +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::getSymk +///\brief Retrieves the size of the symbol table B-tree 1/2 rank and +/// the symbol table leaf node 1/2 size. +///\exception H5::PropListIException +///\par Description +/// For information, please see +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetSymK +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::getSymk( int& ik, int& lk ) const { herr_t ret_value = H5Pget_sym_k( id, &ik, &lk ); @@ -107,6 +190,18 @@ void FileCreatPropList::getSymk( int& ik, int& lk ) const } } #else /* H5_WANT_H5_V1_4_COMPAT */ +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::setSymk +///\brief Sets the size of parameters used to control the symbol table +/// nodes. +///\param ik - IN: Symbol table tree rank +///\param lk - IN: Symbol table node size +///\exception H5::PropListIException +///\par Description +/// For information, please see the C layer Reference Manual at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetSymK +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::setSymk( int ik, unsigned lk ) const { herr_t ret_value = H5Pset_sym_k( id, ik, lk ); @@ -117,6 +212,16 @@ void FileCreatPropList::setSymk( int ik, unsigned lk ) const } } +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::getSymk +///\brief Retrieves the size of the symbol table B-tree 1/2 rank and +/// the symbol table leaf node 1/2 size. +///\exception H5::PropListIException +///\par Description +/// For information, please see +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetSymK +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::getSymk( int& ik, unsigned& lk ) const { herr_t ret_value = H5Pget_sym_k( id, &ik, &lk ); @@ -128,6 +233,17 @@ void FileCreatPropList::getSymk( int& ik, unsigned& lk ) const } #endif /* H5_WANT_H5_V1_4_COMPAT */ +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::setIstorek +///\brief Sets the size of the parameter used to control the B-trees +/// for indexing chunked datasets. +///\param ik - IN: 1/2 rank of chunked storage B-tree +///\exception H5::PropListIException +///\par Description +/// For information, please see the C layer Reference Manual at: +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetIstoreK +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void FileCreatPropList::setIstorek( int ik ) const { herr_t ret_value = H5Pset_istore_k( id, ik ); @@ -137,6 +253,16 @@ void FileCreatPropList::setIstorek( int ik ) const "H5Pset_istore_k failed"); } } +//-------------------------------------------------------------------------- +// Function: FileCreatPropList::getIstorek +///\brief Returns the 1/2 rank of an indexed storage B-tree. +///\return 1/2 rank of chunked storage B-tree +///\exception H5::PropListIException +///\par Description +/// For information, please see +/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5P.html#Property-SetIstoreK +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- int FileCreatPropList::getIstorek() const { int ik; @@ -149,7 +275,11 @@ int FileCreatPropList::getIstorek() const return( ik ); } -// Default destructor +//-------------------------------------------------------------------------- +// Function: FileCreatPropList destructor +///\brief Noop destructor. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- FileCreatPropList::~FileCreatPropList() {} #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 03dca68..bb1011f 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -1,7 +1,7 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * 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 * @@ -42,23 +42,46 @@ namespace H5 { #endif -// Default constructor +//-------------------------------------------------------------------------- +// Function: Group default constructor +///\brief Default constructor: Creates a stub group +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- Group::Group() : H5Object() {} -// Copy constructor: makes a copy of the original Group object +//-------------------------------------------------------------------------- +// Function: Group copy constructor +///\brief Copy constructor: makes a copy of the original Group object. +///\param original - IN: Original group to copy +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- Group::Group( const Group& original ) : H5Object( original ) {} -// Get id of the location, which id the group id here; used by CommonFG -// member functions +//-------------------------------------------------------------------------- +// Function: Group::getLocId +///\brief Returns the id of this group. +///\return Id of this group +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- hid_t Group::getLocId() const { return( getId() ); } -// Creates a copy of an existing Group using its id +//-------------------------------------------------------------------------- +// Function: Group overloaded constructor +///\brief Creates a Group object using the id of an existing group. +///\param group_id - IN: Id of an existing group +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- Group::Group( const hid_t group_id ) : H5Object( group_id ) {} -// Returns the number of objects in the group. +//-------------------------------------------------------------------------- +// Function: Group::getNumObjs +///\brief Returns the number of objects in this group. +///\exception H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- hsize_t Group::getNumObjs() const { hsize_t num_objs; @@ -70,7 +93,14 @@ hsize_t Group::getNumObjs() const return (num_objs); } -// Retrieves the name of an object in a given group by giving index +//-------------------------------------------------------------------------- +// Function: Group::getObjnameByIdx +///\brief Retrieves the name of an object in this group by giving the +/// object's index. +///\return Object name +///\exception H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- ssize_t Group::getObjnameByIdx(hsize_t idx, string& name, size_t size) const { char* name_C = new char[size]; @@ -84,7 +114,14 @@ ssize_t Group::getObjnameByIdx(hsize_t idx, string& name, size_t size) const return (name_len); } -// Returns the type of an object in a given group by giving index +//-------------------------------------------------------------------------- +// Function: Group::getObjTypeByIdx +///\brief Returns the type of an object in this group by giving the +/// object's index. +///\return Object type +///\exception H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- int Group::getObjTypeByIdx(hsize_t idx) const { int obj_type = H5Gget_objtype_by_idx(id, idx); @@ -94,6 +131,18 @@ int Group::getObjTypeByIdx(hsize_t idx) const } return (obj_type); } + +//-------------------------------------------------------------------------- +// Function: Group::getObjTypeByIdx +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function because it also provides +/// the returned object type in text. +///\param idx - IN: Index of the object +///\param type_name - IN: Object type in text +///\return Object type +///\exception H5::GroupIException +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- int Group::getObjTypeByIdx(hsize_t idx, string& type_name) const { int obj_type = H5Gget_objtype_by_idx(id, idx); @@ -111,22 +160,72 @@ int Group::getObjTypeByIdx(hsize_t idx, string& type_name) const return (obj_type); } -// Iterates a user's function over the entries of a group. -//int Group::iterateElems( const string& name, int *idx, H5G_iterate_t op , void *op_data ) -//{ - //return( iterateElems( name.c_str(), idx, op, op_data )); -//} -//int Group::iterateElems( const char* name, int *idx, H5G_iterate_t op , void *op_data ) -//{ - //int ret_value = H5Giterate( id, name, idx, op, op_data ); - //if( ret_value >= 0 ) - //return( ret_value ); - //else // raise exception when H5Aiterate returns a negative value - //{ - //throw GroupIException("Group::iterateElems", "H5Giterate failed"); - //} -//} +//-------------------------------------------------------------------------- +// Function: Group::Reference +///\brief Creates a reference to an HDF5 object or a dataset region. +///\param name - IN: Name of the object to be referenced +///\param dataspace - IN: Dataspace with selection +///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION +///\return A reference +///\exception H5::ReferenceIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void* Group::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const +{ + return(p_reference(name, dataspace.getId(), ref_type)); +} + +//-------------------------------------------------------------------------- +// Function: Group::Reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it only creates +/// a reference to an HDF5 object, not to a dataset region. +///\param name - IN: Name of the object to be referenced +///\return A reference +///\exception H5::ReferenceIException +///\par Description +// This function passes H5R_OBJECT and -1 to the protected +// function for it to pass to the C API H5Rcreate +// to create a reference to the named object. +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void* Group::Reference(const char* name) const +{ + return(p_reference(name, -1, H5R_OBJECT)); +} +//-------------------------------------------------------------------------- +// Function: Group::getObjType +///\brief Retrieves the type of object that an object reference points to. +///\param ref - IN: Reference to query +///\param ref_type - IN: Type of reference to query +// Return An object type, which can be one of the following: +// H5G_LINK Object is a symbolic link. +// H5G_GROUP Object is a group. +// H5G_DATASET Object is a dataset. +// H5G_TYPE Object is a named datatype +// Exception H5::ReferenceIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +H5G_obj_t Group::getObjType(void *ref, H5R_type_t ref_type) const +{ + return(p_get_obj_type(ref, ref_type)); +} + +//-------------------------------------------------------------------------- +// Function: Group::getRegion +///\brief Retrieves a dataspace with the region pointed to selected. +///\param ref - IN: Reference to get region of +///\param ref_type - IN: Type of reference to get region of - default +///\return DataSpace instance +///\exception H5::ReferenceIException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +DataSpace Group::getRegion(void *ref, H5R_type_t ref_type) const +{ + DataSpace dataspace(p_get_region(ref, ref_type)); + return(dataspace); +} // Calls the C API H5Gclose to close this group. Used by IdComponent::reset void Group::p_close() const { @@ -137,7 +236,20 @@ void Group::p_close() const } } -// Throw file exception +//-------------------------------------------------------------------------- +// Function: Group::throwException +///\brief Throws group exception - initially implemented for CommonFG +///\param func_name - Name of the function where failure occurs +///\param msg - Message describing the failure +///\exception H5::GroupIException +// Description +// This function is used in CommonFG implementation so that +// proper exception can be thrown for file or group. The +// argument func_name is a member of CommonFG and "Group::" +// will be inserted to indicate the function called is an +// implementation of Group. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- void Group::throwException(const string func_name, const string msg) const { string full_name = func_name; @@ -145,11 +257,11 @@ void Group::throwException(const string func_name, const string msg) const throw GroupIException(full_name, msg); } -// The destructor of this instance calls IdComponent::reset to -// reset its identifier - no longer true -// Older compilers (baldric) don't support template member functions -// and IdComponent::reset is one; so at this time, the resetId is not -// a member function so it can be template to work around that problem. +//-------------------------------------------------------------------------- +// Function: Group destructor +///\brief Properly terminates access to this group. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- Group::~Group() { // The group id will be closed properly diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 7967533..65119dd 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -43,21 +43,31 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { int getObjTypeByIdx(hsize_t idx) const; int getObjTypeByIdx(hsize_t idx, string& type_name) const; + // Creates a reference to a named Hdf5 object in this object. + void* Reference(const char* name) const; + + // Creates a reference to a named Hdf5 object or to a dataset region + // in this object. + void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; + + // Retrieves the type of object that an object reference points to. + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type) const; + + // Retrieves a dataspace with the region pointed to selected. + DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; // for CommonFG to get the file id virtual hid_t getLocId() const; // Throw group exception virtual void throwException(const string func_name, const string msg) const; - // Used by the API to appropriately close a group void p_close() const; + // Destructor virtual ~Group(); - // Creates a copy of an existing Group using its id - // (used only by template functions in FGtemplates.h - // to return a Group; will not be published; maybe, use friend???) + // Creates a copy of an existing group using its id. Group( const hid_t group_id ); }; diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index dbc56d1..df56c69 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -30,23 +30,39 @@ namespace H5 { #endif +//-------------------------------------------------------------------------- +///\brief Constant for default property +//-------------------------------------------------------------------------- const PropList PropList::DEFAULT( H5P_DEFAULT ); -// Default constructor - set id to 0 by default here but may be set -// to a valid one, if any, by a subclass constructor. +//-------------------------------------------------------------------------- +// Function Default constructor +///\brief Default constructor - Creates a stub property list object. +///\par Description +/// The id of this property list is set to 0. +//-------------------------------------------------------------------------- PropList::PropList() : IdComponent( 0 ) {} -// Copy constructor: makes a copy of the original object +//-------------------------------------------------------------------------- +// Function: PropList copy constructor +///\brief Copy constructor +///\param original - IN: The original property list to copy +//-------------------------------------------------------------------------- PropList::PropList( const PropList& original ) : IdComponent( original ) {} -/* Constructor that takes an existing property list id. -Description: - Uses an HDF5 id to create a PropList identifier object. This id - can be either an existing property list id or a default property - list id. Design note: in the case of default property list, - the identifier still has reference counter; the p_close function - will take care of not to call H5Pclose on the default id. -*/ +//-------------------------------------------------------------------------- +// Function: PropList overloaded constructor +///\brief Creates a property list using the id of an existing property. +///\param plist_id - IN: Id of the existing property list +///\exception H5::PropListIException +// Description +// This function calls H5Pcreate to create a new property list +// if the given id, plist_id, is that of a property class. If +// the given id is equal to H5P_NO_CLASS, then set this +// property's id to H5P_DEFAULT, otherwise, to the given id. +// Note: someone else added this code without comments and this +// description was what I came up with from reading the code. +//-------------------------------------------------------------------------- PropList::PropList( const hid_t plist_id ) : IdComponent(0) { if (H5I_GENPROP_CLS == H5Iget_type(plist_id)) { @@ -65,7 +81,12 @@ PropList::PropList( const hid_t plist_id ) : IdComponent(0) } } -// Makes a copy of an existing property list +//-------------------------------------------------------------------------- +// Function: PropList::copy +///\brief Makes a copy of an existing property list +///\param like_plist - IN: Reference to the existing property list +///\exception H5::PropListIException +//-------------------------------------------------------------------------- void PropList::copy( const PropList& like_plist ) { // reset the identifier of this PropList - send 'this' in so that @@ -88,22 +109,29 @@ void PropList::copy( const PropList& like_plist ) } } -// Makes a copy of the property list on the right hand side and stores -// the new id in the left hand side object. +//-------------------------------------------------------------------------- +// Function: PropList::operator= +///\brief Assignment operator +///\param rhs - IN: Reference to the existing property list +/// +// Description +// Makes a copy of the property list on the right hand side +// and stores the new id in the left hand side object. +//-------------------------------------------------------------------------- PropList& PropList::operator=( const PropList& rhs ) { copy(rhs); return(*this); } -// Copies a property from one list or class to another -void PropList::copyProp( PropList& dest, PropList& src, const string& name ) -{ - copyProp( dest, src, name.c_str()); -} - -// Copies a property from one list or class to another -void PropList::copyProp( PropList& dest, PropList& src, const char *name ) +//-------------------------------------------------------------------------- +// Function: PropList::copyProp +///\brief Copies a property from one list or class to another +///\param dest - IN: Destination property list or class +///\param src - IN: Source property list or class +///\param name - IN: Name of the property to copy - \c char pointer +//-------------------------------------------------------------------------- +void PropList::copyProp( PropList& dest, PropList& src, const char *name ) const { hid_t dst_id = dest.getId(); hid_t src_id = src.getId(); @@ -112,7 +140,19 @@ void PropList::copyProp( PropList& dest, PropList& src, const char *name ) { throw PropListIException("PropList::copyProp", "H5Pcopy_prop failed"); } - +} +//-------------------------------------------------------------------------- +// Function: PropList::copyProp +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param dest - IN: Destination property list or class +///\param src - IN: Source property list or class +///\param name - IN: Name of the property to copy - \c std::string +//-------------------------------------------------------------------------- +void PropList::copyProp( PropList& dest, PropList& src, const string& name ) const +{ + copyProp( dest, src, name.c_str()); } // Closes the property list if it is not a default one @@ -128,7 +168,12 @@ void PropList::p_close() const } } -// Returns the class of this property list, i.e. H5P_FILE_CREATE... +//-------------------------------------------------------------------------- +// Function: PropList::getClass +///\brief Returns the class of this property list, i.e. \c H5P_FILE_CREATE... +///\return The property list class if it is not equal to \c H5P_NO_CLASS +///\exception H5::PropListIException +//-------------------------------------------------------------------------- hid_t PropList::getClass() const { hid_t plist_class = H5Pget_class( id ); @@ -140,8 +185,384 @@ hid_t PropList::getClass() const return( plist_class ); } -// The destructor of this instance calls the template resetIdComponent to -// reset its identifier +//-------------------------------------------------------------------------- +// Function: PropList::propExist +///\brief Query the existance of a property in a property object. +///\param name - IN: Name of property to check for - \c char pointer +///\return true if the property exists in the property object, and +/// false, otherwise. +///\exception H5::PropListIException +///\par Description +/// This routine checks if a property exists within a property +/// list or class. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +bool PropList::propExist(const char* name ) const +{ + // Calls C routine H5Pexist to determine whether a property exists + // within a property list or class. It returns a positive value, 0, + // or a negative value + htri_t ret_value = H5Pexist(id, name); + if( ret_value > 0 ) + return true; + else if( ret_value == 0 ) + return false; + else // Raise exception when H5Pexist returns a negative value + { + throw PropListIException("PropList::propExist", "H5Pexist failed"); + } +} +//-------------------------------------------------------------------------- +// Function: PropList::propExist +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to check for - \c std::string +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +bool PropList::propExist(const string& name ) const +{ + return( propExist( name.c_str()) ); +} + +//-------------------------------------------------------------------------- +// Function: PropList::closeClass +///\brief Close a property list class. +///\exception H5::PropListIException +///\par Description +/// Releases memory and de-attaches a class from the property +/// list class hierarchy. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::closeClass() const +{ + herr_t ret_value = H5Pclose_class(id); + if( ret_value < 0 ) + { + throw PropListIException("PropList::closeClass", "H5Pclose_class failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: PropList::getProperty +///\brief Query the value of a property in a property list. +///\param name - IN: Name of property to query - \c char pointer +///\param value - OUT: Pointer to the buffer for the property value +///\exception H5::PropListIException +///\par Description +/// Retrieves a copy of the value for a property in a property list. The +/// property name must exist or this routine will throw an exception. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::getProperty(const char* name, void* value) const +{ + herr_t ret_value = H5Pget(id, name, value); + if (ret_value < 0) + { + throw PropListIException("PropList::getProperty", "H5Pget failed"); + } +} +//-------------------------------------------------------------------------- +// Function: PropList::getProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c char pointer +///\return The property that is a \c std::string. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +string PropList::getProperty(const char* name) const +{ + size_t size = getPropSize(name); + char* prop_strg_C = new char[size+1]; // temporary C-string for C API + herr_t ret_value = H5Pget(id, name, prop_strg_C); // call C API + + // Throw exception if H5Pget returns failure + if (ret_value < 0) + { + throw PropListIException("PropList::getProperty", "H5Pget failed"); + } + + // Return propety value as a string after deleting temp C-string + string prop_strg = string(prop_strg_C); + delete prop_strg_C; + return (prop_strg); +} +//-------------------------------------------------------------------------- +// Function: PropList::getProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c str::string +///\param value - OUT: Pointer to the buffer for the property value +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::getProperty(const string& name, void* value) const +{ + getProperty(name.c_str(), value); +} +//-------------------------------------------------------------------------- +// Function: PropList::getProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c std::string +///\return The property that is a \c std::string. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +string PropList::getProperty(const string& name) const +{ + return (getProperty(name.c_str())); +} + +//-------------------------------------------------------------------------- +// Function: PropList::getPropSize +///\brief Query the size of a property in a property list or class. +///\param name - IN: Name of property to query +///\return Size of the property +///\exception H5::PropListIException +///\par Description +/// This routine retrieves the size of a property's value +/// in bytes. Zero-sized properties are allowed and the return +/// value will be of 0. This function works for both property +/// lists and classes. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +size_t PropList::getPropSize(const char *name) const +{ + size_t prop_size; + herr_t ret_value = H5Pget_size(id, name, &prop_size); + if (prop_size < 0) + { + throw PropListIException("PropList::getPropSize", "H5Pget_size failed"); + } + return(prop_size); +} +//-------------------------------------------------------------------------- +// Function: PropList::getPropSize +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to query - \c std::string +/// +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +size_t PropList::getPropSize(const string& name) const +{ + return (getPropSize(name.c_str())); +} + +//-------------------------------------------------------------------------- +// Function: PropList::getClassName +///\brief Return the name of a generic property list class +///\return A string containing the class name, if success, otherwise, +/// a NULL string. +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +string PropList::getClassName() const +{ + char* temp_str; + temp_str = H5Pget_class_name(id); + + if (temp_str != NULL) + { + string class_name = string(temp_str); + free(temp_str); + return(class_name); + } + else + return 0; +} +//-------------------------------------------------------------------------- +// Function: PropList::getNumProps +///\brief Returns the number of properties in this property list or class. +///\return Size of the property. +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +size_t PropList::getNumProps() const +{ + size_t nprops; + herr_t ret_value = H5Pget_nprops (id, &nprops); + if( nprops < 0 ) + { + throw PropListIException("PropList::getNumProps", "H5Pget_nprops failed"); + } + return (nprops); +} + +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief Set a property's value in a property list. +///\param name - IN: Name of property to set - \c char pointer +///\param value - IN: Void pointer to the value for the property +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::setProperty(const char* name, void* value) const +{ + herr_t ret_value = H5Pset(id, name, value); + if (ret_value < 0) + { + throw PropListIException("PropList::setProperty", "H5Pset failed"); + } +} +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c char pointer +///\param charptr - IN: Char pointer to the value for the property +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::setProperty(const char* name, const char* charptr) const +{ + herr_t ret_value = H5Pset(id, name, (void*) charptr); + if (ret_value < 0) + { + throw PropListIException("PropList::setProperty", "H5Pset failed"); + } +} +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c char pointer +///\param strg - IN: Value for the property is a \c std::string +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::setProperty(const char* name, string& strg) const +{ + setProperty(name, strg.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c std::string +///\param value - IN: Void pointer to the value for the property +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::setProperty(const string& name, void* value) const +{ + setProperty(name.c_str(), value); +} + +//-------------------------------------------------------------------------- +// Function: PropList::setProperty +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to set - \c std::string +///\param strg - IN: Value for the property is a \c std::string +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::setProperty(const string& name, string& strg) const +{ + setProperty(name.c_str(), strg.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: PropList::isAClass +///\brief Determines whether a property list is a certain class +///\param prop_class - IN: Property class to query +///\return true if the property list is a member of the property list +/// class, and false, otherwise. +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +bool PropList::isAClass(const PropList& prop_class) const +{ + htri_t ret_value = H5Pisa_class(id, prop_class.getId()); + if( ret_value > 0 ) + return true; + else if( ret_value == 0 ) + return false; + else // Raise exception when H5Pisa_class returns a negative value + { + throw PropListIException("PropList::isAClass", "H5Pisa_class failed"); + } + +} + +//-------------------------------------------------------------------------- +// Function: PropList::removeProp +///\brief Removes a property from a property list +///\param name - IN: Name of property to remove - \c char pointer +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::removeProp(const char *name) const +{ + herr_t ret_value = H5Premove(id, name); + if (ret_value < 0) + { + throw PropListIException("PropList::removeProp", "H5Premove failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: PropList::removeProp +///\brief This is an overloaded member function, provided for convenience. +/// It differs from the above function only in what arguments it +/// accepts. +///\param name - IN: Name of property to remove - \c std::string +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +void PropList::removeProp(const string& name) const +{ + removeProp(name.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: PropList::operator== +///\brief Compares this property list or class against the given list or class. +///\param rhs - IN: Reference to the property list to compare +///\return true if the property lists or classes are equal, and +/// false, otherwise. +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +bool PropList::operator==(const PropList& rhs) const +{ + htri_t ret_value = H5Pequal(id, rhs.getId()); + if( ret_value > 0 ) + return true; + else if( ret_value == 0 ) + return false; + else // Raise exception when H5Pequal returns a negative value + { + throw PropListIException("PropList::operator==", "H5Pequal failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: PropList::getClassParent +///\brief Returns the parent class of a generic property class +///\return The parent class of a property class +///\exception H5::PropListIException +// Programmer: Binh-Minh Ribler - April, 2004 +//-------------------------------------------------------------------------- +PropList PropList::getClassParent() const +{ + hid_t class_id = H5Pget_class_parent(id); + if (class_id <= 0) + { + throw PropListIException("PropList::getClassParent", "H5Pget_class_parent failed"); + } + PropList pclass(class_id); + return(pclass); +} + +//-------------------------------------------------------------------------- +// Function: PropList destructor +///\brief Properly terminates access to this property list. +// Programmer Binh-Minh Ribler - 2000 +//-------------------------------------------------------------------------- PropList::~PropList() { // The property list id will be closed properly diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index f796959..1c7d934 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -43,13 +43,46 @@ class H5_DLLCPP PropList : public IdComponent { PropList& operator=( const PropList& rhs ); // Copies a property from one property list or property class to another - void copyProp( PropList& dest, PropList& src, const string& name); - void copyProp( PropList& dest, PropList& src, const char* name); + void copyProp( PropList& dest, PropList& src, const string& name) const; + void copyProp( PropList& dest, PropList& src, const char* name) const; // Gets the class of this property list, i.e. H5P_FILE_CREATE, // H5P_FILE_ACCESS, ... hid_t getClass() const; + /// Query the existance of a property in a property object. + bool propExist(const char* name) const; + bool propExist(const string& name) const; + + void closeClass() const; + + void getProperty(const char* name, void* value) const; + string getProperty(const char* name) const; + void getProperty(const string& name, void* value) const; + string getProperty(const string& name) const; + + size_t getPropSize(const char *name) const; + size_t getPropSize(const string& name) const; + + string getClassName() const; + + size_t getNumProps() const; + + void setProperty(const char* name, void* charptr) const; + void setProperty(const char* name, const char* value) const; + void setProperty(const char* name, string& strg) const; + void setProperty(const string& name, void* value) const; + void setProperty(const string& name, string& strg) const; + + bool isAClass(const PropList& prop_class) const; + + void removeProp(const char *name) const; + void removeProp(const string& name) const; + + bool operator==(const PropList& rhs) const; + + PropList getClassParent() const; + // Used by the API to close the property list void p_close() const; |