summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2004-05-16 20:05:03 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2004-05-16 20:05:03 (GMT)
commitc56eb7f4a4e0ae5b41995850a4bcdb09adf73484 (patch)
tree2db091939eb6713b98123e7c20d12ce681b589bf
parent229cc3b8c064e6c63ba30587ff040e27e2073ac3 (diff)
downloadhdf5-c56eb7f4a4e0ae5b41995850a4bcdb09adf73484.zip
hdf5-c56eb7f4a4e0ae5b41995850a4bcdb09adf73484.tar.gz
hdf5-c56eb7f4a4e0ae5b41995850a4bcdb09adf73484.tar.bz2
[svn-r8532] Purpose:
Add more C++ wrappers and documentation - incrementally check-in Description: Added wrapper for: H5Tdetect_class Also, added Doxygen documentation to existing member functions of AtomType and DataType. Test for the new wrapper will follow in a few weeks. Some typos and small format changes are done in H5File.cpp. Platforms: SunOS 5.7 (arabica) Linux 2.4 (eirene) Windows 2000
-rw-r--r--c++/src/H5AtomType.cpp175
-rw-r--r--c++/src/H5AtomType.h5
-rw-r--r--c++/src/H5DataType.cpp320
-rw-r--r--c++/src/H5DataType.h3
-rw-r--r--c++/src/H5File.cpp66
5 files changed, 426 insertions, 143 deletions
diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp
index 0185960..d98f482 100644
--- a/c++/src/H5AtomType.cpp
+++ b/c++/src/H5AtomType.cpp
@@ -27,16 +27,36 @@
namespace H5 {
#endif
-// Default constructor
+//--------------------------------------------------------------------------
+// Function: AtomType default constructor
+///\brief Default constructor: Creates a stub datatype
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
AtomType::AtomType() : DataType() {}
-// Constructor that takes an existing id
+//--------------------------------------------------------------------------
+// Function: AtomType overloaded constructor
+///\brief Creates an AtomType object using an existing id.
+///\param existing_id - IN: Id of an existing datatype
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
AtomType::AtomType( const hid_t existing_id ) : DataType( existing_id ) {}
-// Copy constructor: makes a copy of the original AtomType object.
+//--------------------------------------------------------------------------
+// Function: AtomType copy constructor
+///\brief Copy constructor: makes a copy of the original AtomType object.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
AtomType::AtomType( const AtomType& original ) : DataType( original ) {}
-// Sets the total size for an atomic datatype.
+//--------------------------------------------------------------------------
+// Function: AtomType::setSize
+///\brief Sets the total size for an atomic datatype.
+///\param size - IN: Size to set
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
void AtomType::setSize( size_t size ) const
{
// Call C routine H5Tset_size to set the total size
@@ -47,7 +67,17 @@ void AtomType::setSize( size_t size ) const
}
}
-// Returns the byte order of an atomic datatype. Inheritance class???
+//--------------------------------------------------------------------------
+// Function: AtomType::getOrder
+///\brief Returns the byte order of an atomic datatype.
+///\param order_string - OUT: Text description of the returned byte order
+///\return Byte order, which can be:
+/// \li \c H5T_ORDER_LE
+/// \li \c H5T_ORDER_BE
+/// \li \c H5T_ORDER_VAX
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
H5T_order_t AtomType::getOrder( string& order_string ) const
{
// Call C routine to get the byte ordering
@@ -68,7 +98,16 @@ H5T_order_t AtomType::getOrder( string& order_string ) const
return( type_order );
}
-// Sets the byte ordering of an atomic datatype. Inheritance class???
+//--------------------------------------------------------------------------
+// Function: AtomType::setOrder
+///\brief Sets the byte ordering of an atomic datatype.
+///\param order - IN: Byte ordering constant, which can be:
+/// \li \c H5T_ORDER_LE
+/// \li \c H5T_ORDER_BE
+/// \li \c H5T_ORDER_VAX
+///\exception H5::DataTypeIException
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
void AtomType::setOrder( H5T_order_t order ) const
{
// Call C routine to set the byte ordering
@@ -79,7 +118,17 @@ void AtomType::setOrder( H5T_order_t order ) const
}
}
-// Returns the precision of an atomic datatype.
+//--------------------------------------------------------------------------
+// Function: AtomType::getPrecision
+///\brief Returns the precision of an atomic datatype.
+///\return Number of significant bits
+///\exception H5::DataTypeIException
+///\par Description
+/// The precision is the number of significant bits which,
+/// unless padding is present, is 8 times larger than the
+/// value returned by \c DataType::getSize().
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
size_t AtomType::getPrecision() const
{
size_t num_signi_bits = H5Tget_precision( id ); // C routine
@@ -93,7 +142,16 @@ size_t AtomType::getPrecision() const
return( num_signi_bits );
}
-// Sets the precision of an atomic datatype.
+//--------------------------------------------------------------------------
+// Function: AtomType::setPrecision
+///\brief Sets the precision of an atomic datatype.
+///\param precision - IN: Number of bits of precision
+///\exception H5::DataTypeIException
+///\par Description
+/// For information, please see C layer Reference Manuat at:
+/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5T.html#Datatype-SetPrecision
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
void AtomType::setPrecision( size_t precision ) const
{
// Call C routine to set the datatype precision
@@ -104,10 +162,20 @@ void AtomType::setPrecision( size_t precision ) const
}
}
-// Retrieves the bit offset of the first significant bit.
-// 12/05/00: due to C API change
-// - return type changed from size_t to int
-// - offset = -1 when failure occurs vs. 0
+//--------------------------------------------------------------------------
+// Function: AtomType::getOffset
+///\brief Retrieves the bit offset of the first significant bit.
+///\return Offset value
+///\exception H5::DataTypeIException
+///\par Description
+/// For information, please see C layer Reference Manuat at:
+/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5T.html#Datatype-GetOffset
+// Programmer Binh-Minh Ribler - 2000
+// Modification
+// 12/05/00: due to C API change
+// - return type changed from size_t to int
+// - offset = -1 when failure occurs vs. 0
+//--------------------------------------------------------------------------
int AtomType::getOffset() const
{
int offset = H5Tget_offset( id ); // C routine
@@ -121,7 +189,16 @@ int AtomType::getOffset() const
return( offset );
}
-// Sets the bit offset of the first significant bit.
+//--------------------------------------------------------------------------
+// Function: AtomType::setOffset
+///\brief Sets the bit offset of the first significant bit.
+///\param offset - IN: Offset of first significant bit
+///\exception H5::DataTypeIException
+///\par Description
+/// For information, please see C layer Reference Manuat at:
+/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5T.html#Datatype-SetOffset
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
void AtomType::setOffset( size_t offset ) const
{
// Call C routine to set the bit offset
@@ -132,30 +209,58 @@ void AtomType::setOffset( size_t offset ) const
}
}
-// Retrieves the padding type of the least and most-significant bit padding.
-// these two are for Opaque type
-//void AtomType::getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const
-//{
+//--------------------------------------------------------------------------
+// Function: AtomType::getPad
+///\brief Retrieves the padding type of the least and most-significant
+/// bit padding.
+///\param lsb - OUT: Least-significant bit padding type
+///\param msb - OUT: Most-significant bit padding type
+///\exception H5::DataTypeIException
+///\par Description
+/// Possible values for \a lsb and \a msb include:
+/// \li \c H5T_PAD_ZERO (0) - Set background to zeros.
+/// \li \c H5T_PAD_ONE (1) - Set background to ones.
+/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+void AtomType::getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const
+{
// Call C routine to get the padding type
- //herr_t ret_value = H5Tget_pad( id, &lsb, &msb );
- //if( ret_value < 0 )
- //{
- //throw DataTypeIException("AtomType::getPad", "H5Tget_pad failed");
- //}
-//}
-
-// Sets the least and most-significant bits padding types
-//void AtomType::setPad( H5T_pad_t lsb, H5T_pad_t msb ) const
-//{
+ herr_t ret_value = H5Tget_pad( id, &lsb, &msb );
+ if( ret_value < 0 )
+ {
+ throw DataTypeIException("AtomType::getPad", "H5Tget_pad failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: AtomType::getPad
+///\brief Sets the least and most-significant bits padding types.
+///\param lsb - IN: Least-significant bit padding type
+///\param msb - IN: Most-significant bit padding type
+///\exception H5::DataTypeIException
+///\par Description
+/// Valid values for \a lsb and \a msb include:
+/// \li \c H5T_PAD_ZERO (0) - Set background to zeros.
+/// \li \c H5T_PAD_ONE (1) - Set background to ones.
+/// \li \c H5T_PAD_BACKGROUND (2) - Leave background alone.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
+void AtomType::setPad( H5T_pad_t lsb, H5T_pad_t msb ) const
+{
// Call C routine to set the padding type
- //herr_t ret_value = H5Tset_pad( id, lsb, msb );
- //if( ret_value < 0 )
- //{
- //throw DataTypeIException("AtomType::setPad", "H5Tset_pad failed");
- //}
-//}
-
-// This destructor terminates access to the datatype; it calls ~DataType
+ herr_t ret_value = H5Tset_pad( id, lsb, msb );
+ if( ret_value < 0 )
+ {
+ throw DataTypeIException("AtomType::setPad", "H5Tset_pad failed");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: AtomType destructor
+///\brief Properly terminates access to this object.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
AtomType::~AtomType() {}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h
index 6217c8c..bb20bd3 100644
--- a/c++/src/H5AtomType.h
+++ b/c++/src/H5AtomType.h
@@ -48,12 +48,11 @@ class H5_DLLCPP AtomType : public DataType {
// Sets the bit offset of the first significant bit.
void setOffset( size_t offset ) const;
- // The followings will go into Opaque type when completed
// Retrieves the padding type of the least and most-significant bit padding.
- // void getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const;
+ void getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const;
// Sets the least and most-significant bits padding types
- // void setPad( H5T_pad_t lsb, H5T_pad_t msb ) const;
+ void setPad( H5T_pad_t lsb, H5T_pad_t msb ) const;
// Copy constructor - makes copy of the original object
AtomType( const AtomType& original );
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index b6249fe..dbe7801 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -35,14 +35,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 +70,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 +116,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
+///\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 +158,15 @@ 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 )
-//{
-//}
-
-// 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() );
-}
+//--------------------------------------------------------------------------
+// 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
+//--------------------------------------------------------------------------
void DataType::commit( H5Object& loc, const char* name ) const
{
hid_t loc_id = loc.getId(); // get location id for C API
@@ -142,7 +179,26 @@ void DataType::commit( H5Object& loc, const char* name ) const
}
}
-// Determines whether a datatype is a named type or a transient type.
+//--------------------------------------------------------------------------
+// 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() );
+}
+
+//--------------------------------------------------------------------------
+// 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 +213,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 +234,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
@@ -185,7 +262,19 @@ void DataType::convert( const DataType& dest, hsize_t nelmts, void *buf, void *b
}
}
-// 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
@@ -196,7 +285,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 );
@@ -210,7 +305,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
@@ -223,8 +324,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
@@ -244,11 +350,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
@@ -261,11 +378,31 @@ void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType&
}
}
-// 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
@@ -278,11 +415,26 @@ void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& de
}
}
-// 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.
@@ -293,7 +445,25 @@ void DataType::setTag( const char* tag ) const
}
}
-// Gets the tag associated with an opaque datatype.
+//--------------------------------------------------------------------------
+// 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());
+}
+
+//--------------------------------------------------------------------------
+// Function: DataType::setTag
+///\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 );
@@ -313,8 +483,34 @@ 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");
+ }
+}
+
+//--------------------------------------------------------------------------
// This private function calls the C API H5Tclose to close this datatype.
// Used by H5Object::p_reset.
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
void DataType::p_close() const
{
// If this datatype is not a predefined type, call H5Tclose on it.
@@ -328,11 +524,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 0fe462f..6d49f7b 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -81,6 +81,9 @@ class H5_DLLCPP DataType : public H5Object {
// Gets the tag associated with an opaque datatype.
string getTag() const;
+ // Checks whether this datatype contains (or is) a certain type class
+ bool detectClass(H5T_class_t cls) const;
+
// Creates a new variable-length datatype - not implemented yet
// Will be moved into a subclass when completed
//DataType vlenCreate( const DataType& base_type );
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index d46f628..fdf7561 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -47,8 +47,7 @@ namespace H5 {
///\brief Default constructor - Creates a stub hdf5 file object.
///\par Description
/// The id of this hdf5 file is set to 0.
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5File::H5File() : IdComponent() {}
@@ -77,8 +76,7 @@ H5File::H5File() : IdComponent() {}
/// please refer to the \b Special \b case section in the C layer
/// Reference Manual at:
/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5F.html#File-Create
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5File::H5File( const string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent()
{
@@ -97,18 +95,18 @@ H5File::H5File( const string& name, unsigned int flags, const FileCreatPropList&
///\param access_plist - IN: File access property list. Default to
/// FileCreatPropList::DEFAULT
///\param name - IN: Name of the file - \c std::string
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent()
{
getFile( name, flags, create_plist, access_plist );
}
+//--------------------------------------------------------------------------
// This function is private and contains common code between the
// constructors taking a string or a char*
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
+//--------------------------------------------------------------------------
void H5File::getFile( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist )
{
// These bits only set for creation, so if any of them are set,
@@ -140,8 +138,7 @@ void H5File::getFile( const char* name, unsigned int flags, const FileCreatPropL
// Function: Copy Constructor
///\brief Copy Constructor: Makes a copy of the original
/// H5File object
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5File::H5File( const H5File& original ) : IdComponent( original ) {}
@@ -151,8 +148,7 @@ H5File::H5File( const H5File& original ) : IdComponent( original ) {}
///\param name - IN: Name of the file
///\return true if the file is in HDF5 format, and false, otherwise
///\exception H5::FileIException
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
bool H5File::isHdf5(const char* name )
{
@@ -173,8 +169,7 @@ bool H5File::isHdf5(const char* name )
///\brief This is an overloaded member function, provided for convenience.
/// It takes an \c std::string for \a name.
///\param name - IN: Name of the file
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
bool H5File::isHdf5(const string& name )
{
@@ -187,8 +182,7 @@ bool H5File::isHdf5(const string& name )
// Description
// This function is a redefinition of CommonFG::getLocId. It
// is used by CommonFG member functions to get the file id.
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
hid_t H5File::getLocId() const
{
@@ -202,8 +196,7 @@ hid_t H5File::getLocId() const
// Description
// If this object has represented another HDF5 file, the previous
// HDF5 file need to be closed first.
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void H5File::reopen()
{
@@ -229,8 +222,7 @@ void H5File::reopen()
///\brief Returns the creation property list of this file
///\return FileCreatPropList object
///\exception H5::FileIException
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
FileCreatPropList H5File::getCreatePlist() const
{
@@ -254,8 +246,7 @@ FileCreatPropList H5File::getCreatePlist() const
///\brief Returns the access property list of this file
///\return FileAccPropList object
///\exception H5::FileIException
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
FileAccPropList H5File::getAccessPlist() const
{
@@ -279,8 +270,7 @@ FileAccPropList H5File::getAccessPlist() const
///\brief Returns the amount of free space in the file.
///\return Amount of free space
///\exception H5::FileIException
-// Programmer Binh-Minh Ribler
-// Date May 2004
+// Programmer Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
hssize_t H5File::getFreeSpace()
{
@@ -310,8 +300,7 @@ hssize_t H5File::getFreeSpace()
/// \li \c H5F_OBJ_ALL All of the above
/// \li \c (i.e., H5F_OBJ_FILE | H5F_OBJ_DATASET | H5F_OBJ_GROUP | H5F_OBJ_DATATYPE | H5F_OBJ_ATTR )
/// Multiple object types can be combined with the logical OR operator (|).
-// Programmer Binh-Minh Ribler
-// Date May 2004
+// Programmer Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
int H5File::getObjCount(unsigned types)
{
@@ -330,8 +319,7 @@ int H5File::getObjCount(unsigned types)
/// object types.
///\return Number of opened object IDs
///\exception H5::FileIException
-// Programmer Binh-Minh Ribler
-// Date May 2004
+// Programmer Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
int H5File::getObjCount()
{
@@ -364,8 +352,7 @@ int H5File::getObjCount()
/// Multiple object types can be combined with the logical OR operator (|).
//
// Notes: will do the overload for this one after hearing from Quincey???
-// Programmer Binh-Minh Ribler
-// Date May 2004
+// Programmer Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
void H5File::getObjIDs(unsigned types, int max_objs, hid_t *oid_list)
{
@@ -393,8 +380,7 @@ void H5File::getObjIDs(unsigned types, int max_objs, hid_t *oid_list)
/// The obtained file handle is dynamic and is valid only while
/// the file remains open; it will be invalid if the file is
/// closed and reopened or opened during a subsequent session.
-// Programmer Binh-Minh Ribler
-// Date May 2004
+// Programmer Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle)
{
@@ -414,8 +400,7 @@ void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle)
///\param file_handle - Pointer to the file handle being used by
/// the low-level virtual file driver
///\exception H5::FileIException
-// Programmer Binh-Minh Ribler
-// Date May 2004
+// Programmer Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
void H5File::getVFDHandle(void **file_handle)
{
@@ -448,8 +433,7 @@ void H5File::p_close() const
// argument func_name is a member of CommonFG and "H5File::"
// will be inserted to indicate the function called is an
// implementation of H5File.
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void H5File::throwException(const string func_name, const string msg) const
{
@@ -459,13 +443,9 @@ void H5File::throwException(const string func_name, const string msg) const
}
//--------------------------------------------------------------------------
-// Function: H5File::getVFDHandle
-///\brief This is an overloaded member function, provided for convenience.
-/// It differs from the above function only in what arguments it
-/// accepts.
-///\exception H5::FileIException
-// Programmer Binh-Minh Ribler
-// Date 2000
+// Function: H5File destructor
+///\brief Properly terminates access to this file.
+// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
H5File::~H5File()
{