[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
This commit is contained in:
Binh-Minh Ribler 2004-05-16 15:05:03 -05:00
parent 229cc3b8c0
commit c56eb7f4a4
5 changed files with 422 additions and 139 deletions

View File

@ -27,16 +27,36 @@
namespace H5 { namespace H5 {
#endif #endif
// Default constructor //--------------------------------------------------------------------------
// Function: AtomType default constructor
///\brief Default constructor: Creates a stub datatype
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
AtomType::AtomType() : DataType() {} 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 ) {} 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 ) {} 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 void AtomType::setSize( size_t size ) const
{ {
// Call C routine H5Tset_size to set the total size // 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 H5T_order_t AtomType::getOrder( string& order_string ) const
{ {
// Call C routine to get the byte ordering // Call C routine to get the byte ordering
@ -68,7 +98,16 @@ H5T_order_t AtomType::getOrder( string& order_string ) const
return( type_order ); 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 void AtomType::setOrder( H5T_order_t order ) const
{ {
// Call C routine to set the byte ordering // 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 AtomType::getPrecision() const
{ {
size_t num_signi_bits = H5Tget_precision( id ); // C routine size_t num_signi_bits = H5Tget_precision( id ); // C routine
@ -93,7 +142,16 @@ size_t AtomType::getPrecision() const
return( num_signi_bits ); 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 void AtomType::setPrecision( size_t precision ) const
{ {
// Call C routine to set the datatype precision // 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 // Function: AtomType::getOffset
// - return type changed from size_t to int ///\brief Retrieves the bit offset of the first significant bit.
// - offset = -1 when failure occurs vs. 0 ///\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 AtomType::getOffset() const
{ {
int offset = H5Tget_offset( id ); // C routine int offset = H5Tget_offset( id ); // C routine
@ -121,7 +189,16 @@ int AtomType::getOffset() const
return( offset ); 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 void AtomType::setOffset( size_t offset ) const
{ {
// Call C routine to set the bit offset // 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 // Function: AtomType::getPad
//void AtomType::getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const ///\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 // Call C routine to get the padding type
//herr_t ret_value = H5Tget_pad( id, &lsb, &msb ); herr_t ret_value = H5Tget_pad( id, &lsb, &msb );
//if( ret_value < 0 ) if( ret_value < 0 )
//{ {
//throw DataTypeIException("AtomType::getPad", "H5Tget_pad failed"); 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 // 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 // Call C routine to set the padding type
//herr_t ret_value = H5Tset_pad( id, lsb, msb ); herr_t ret_value = H5Tset_pad( id, lsb, msb );
//if( ret_value < 0 ) if( ret_value < 0 )
//{ {
//throw DataTypeIException("AtomType::setPad", "H5Tset_pad failed"); throw DataTypeIException("AtomType::setPad", "H5Tset_pad failed");
//} }
//} }
// This destructor terminates access to the datatype; it calls ~DataType //--------------------------------------------------------------------------
// Function: AtomType destructor
///\brief Properly terminates access to this object.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
AtomType::~AtomType() {} AtomType::~AtomType() {}
#ifndef H5_NO_NAMESPACE #ifndef H5_NO_NAMESPACE

View File

@ -48,12 +48,11 @@ class H5_DLLCPP AtomType : public DataType {
// Sets the bit offset of the first significant bit. // Sets the bit offset of the first significant bit.
void setOffset( size_t offset ) const; 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. // 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 // 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 // Copy constructor - makes copy of the original object
AtomType( const AtomType& original ); AtomType( const AtomType& original );

View File

@ -35,14 +35,31 @@
namespace H5 { namespace H5 {
#endif #endif
// Constructor creates a copy of an existing DataType using its id. //--------------------------------------------------------------------------
// 'predefined' is default to false; when a default datatype is // Function: DataType overloaded constructor
// created, this argument is set to true so H5Tclose will not be ///\brief Creates a datatype using an existing datatype's id
// called on it later. ///\param existing_id - IN: Id of the existing datatype
DataType::DataType( const hid_t existing_id, bool predefined ) : H5Object( existing_id ), is_predtype( predefined ) { ///\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) {}
// Creates a datatype given its class and size //--------------------------------------------------------------------------
// 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 ) DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object(), is_predtype( false )
{ {
// Call C routine to create the new datatype // 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 ) // Function: DataType default constructor
{ ///\brief Default constructor: Creates a stub datatype
} // Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
DataType::DataType() : H5Object(), is_predtype( false ) {}
// Copy constructor: makes a copy of this DataType object. //--------------------------------------------------------------------------
DataType::DataType( const DataType& original ) : H5Object( original ) // 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 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 ) void DataType::copy( const DataType& like_type )
{ {
// reset the identifier of this instance, H5Tclose will be called // 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 ) DataType& DataType::operator=( const DataType& rhs )
{ {
copy(rhs); copy(rhs);
return(*this); 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 bool DataType::operator==(const DataType& compared_type ) const
{ {
// Call C routine H5Tequal to determines whether two datatype // 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 // Function: DataType::commit
// the parameter list??? - work in progress ///\brief Commits a transient datatype to a file, creating a new
//int DataType::iterate( unsigned * idx, H5A_operator_t op, void *op_data ) /// named datatype
//{ ///\param loc - IN: Either a file or a group
//} ///\param name - IN: Name of the datatype
///\exception H5::DataTypeIException
// Creates a new variable-length datatype - Note: should use inheritance - // Programmer Binh-Minh Ribler - 2000
// 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() );
}
void DataType::commit( H5Object& loc, const char* name ) const void DataType::commit( H5Object& loc, const char* name ) const
{ {
hid_t loc_id = loc.getId(); // get location id for C API 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 bool DataType::committed() const
{ {
// Call C function to determine if a datatype is a named one // 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 H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const
{ {
// Call C routine to find the conversion function // 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 ); 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 void DataType::convert( const DataType& dest, hsize_t nelmts, void *buf, void *background, PropList& plist ) const
{ {
// Get identifiers for C API // 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 void DataType::lock() const
{ {
// Call C routine to lock the datatype // 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 DataType::getClass() const
{ {
H5T_class_t type_class = H5Tget_class( id ); H5T_class_t type_class = H5Tget_class( id );
@ -210,7 +305,13 @@ H5T_class_t DataType::getClass() const
return( type_class ); 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 size_t DataType::getSize() const
{ {
// Call C routine to get the datatype size // Call C routine to get the datatype size
@ -223,8 +324,13 @@ size_t DataType::getSize() const
return( type_size ); 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 DataType DataType::getSuper() const
{ {
// Call C routine to get the base datatype from which the specified // 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 // Function: DataType::registerFunc
{ ///\brief Registers the specified conversion function.
registerFunc( pers, name.c_str(), dest, func ); ///\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 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 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 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 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 void DataType::setTag( const char* tag ) const
{ {
// Call C routine H5Tset_tag to tag an opaque datatype. // 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 string DataType::getTag() const
{ {
char* tag_Cstr = H5Tget_tag( id ); 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. // This private function calls the C API H5Tclose to close this datatype.
// Used by H5Object::p_reset. // Used by H5Object::p_reset.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
void DataType::p_close() const void DataType::p_close() const
{ {
// If this datatype is not a predefined type, call H5Tclose on it. // 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 // Function: DataType destructor
// Older compilers (baldric) don't support template member functions ///\brief Properly terminates access to this datatype.
// and IdComponent::reset is one; so at this time, the resetId is not // Programmer Binh-Minh Ribler - 2000
// a member function so it can be template to work around that problem. //--------------------------------------------------------------------------
DataType::~DataType() DataType::~DataType()
{ {
// The datatype id will be closed properly // The datatype id will be closed properly

View File

@ -81,6 +81,9 @@ class H5_DLLCPP DataType : public H5Object {
// Gets the tag associated with an opaque datatype. // Gets the tag associated with an opaque datatype.
string getTag() const; 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 // Creates a new variable-length datatype - not implemented yet
// Will be moved into a subclass when completed // Will be moved into a subclass when completed
//DataType vlenCreate( const DataType& base_type ); //DataType vlenCreate( const DataType& base_type );

View File

@ -47,8 +47,7 @@ namespace H5 {
///\brief Default constructor - Creates a stub hdf5 file object. ///\brief Default constructor - Creates a stub hdf5 file object.
///\par Description ///\par Description
/// The id of this hdf5 file is set to 0. /// The id of this hdf5 file is set to 0.
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
H5File::H5File() : IdComponent() {} H5File::H5File() : IdComponent() {}
@ -77,8 +76,7 @@ H5File::H5File() : IdComponent() {}
/// please refer to the \b Special \b case section in the C layer /// please refer to the \b Special \b case section in the C layer
/// Reference Manual at: /// Reference Manual at:
/// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5F.html#File-Create /// http://hdf.ncsa.uiuc.edu/HDF5/doc/RM_H5F.html#File-Create
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
H5File::H5File( const string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent() 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 ///\param access_plist - IN: File access property list. Default to
/// FileCreatPropList::DEFAULT /// FileCreatPropList::DEFAULT
///\param name - IN: Name of the file - \c std::string ///\param name - IN: Name of the file - \c std::string
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent() H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : IdComponent()
{ {
getFile( name, flags, create_plist, access_plist ); getFile( name, flags, create_plist, access_plist );
} }
//--------------------------------------------------------------------------
// This function is private and contains common code between the // This function is private and contains common code between the
// constructors taking a string or a char* // constructors taking a string or a char*
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000 //--------------------------------------------------------------------------
void H5File::getFile( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) 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, // 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 // Function: Copy Constructor
///\brief Copy Constructor: Makes a copy of the original ///\brief Copy Constructor: Makes a copy of the original
/// H5File object /// H5File object
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
H5File::H5File( const H5File& original ) : IdComponent( original ) {} 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 ///\param name - IN: Name of the file
///\return true if the file is in HDF5 format, and false, otherwise ///\return true if the file is in HDF5 format, and false, otherwise
///\exception H5::FileIException ///\exception H5::FileIException
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
bool H5File::isHdf5(const char* name ) 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. ///\brief This is an overloaded member function, provided for convenience.
/// It takes an \c std::string for \a name. /// It takes an \c std::string for \a name.
///\param name - IN: Name of the file ///\param name - IN: Name of the file
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
bool H5File::isHdf5(const string& name ) bool H5File::isHdf5(const string& name )
{ {
@ -187,8 +182,7 @@ bool H5File::isHdf5(const string& name )
// Description // Description
// This function is a redefinition of CommonFG::getLocId. It // This function is a redefinition of CommonFG::getLocId. It
// is used by CommonFG member functions to get the file id. // is used by CommonFG member functions to get the file id.
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
hid_t H5File::getLocId() const hid_t H5File::getLocId() const
{ {
@ -202,8 +196,7 @@ hid_t H5File::getLocId() const
// Description // Description
// If this object has represented another HDF5 file, the previous // If this object has represented another HDF5 file, the previous
// HDF5 file need to be closed first. // HDF5 file need to be closed first.
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void H5File::reopen() void H5File::reopen()
{ {
@ -229,8 +222,7 @@ void H5File::reopen()
///\brief Returns the creation property list of this file ///\brief Returns the creation property list of this file
///\return FileCreatPropList object ///\return FileCreatPropList object
///\exception H5::FileIException ///\exception H5::FileIException
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
FileCreatPropList H5File::getCreatePlist() const FileCreatPropList H5File::getCreatePlist() const
{ {
@ -254,8 +246,7 @@ FileCreatPropList H5File::getCreatePlist() const
///\brief Returns the access property list of this file ///\brief Returns the access property list of this file
///\return FileAccPropList object ///\return FileAccPropList object
///\exception H5::FileIException ///\exception H5::FileIException
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
FileAccPropList H5File::getAccessPlist() const FileAccPropList H5File::getAccessPlist() const
{ {
@ -279,8 +270,7 @@ FileAccPropList H5File::getAccessPlist() const
///\brief Returns the amount of free space in the file. ///\brief Returns the amount of free space in the file.
///\return Amount of free space ///\return Amount of free space
///\exception H5::FileIException ///\exception H5::FileIException
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - May 2004
// Date May 2004
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
hssize_t H5File::getFreeSpace() hssize_t H5File::getFreeSpace()
{ {
@ -310,8 +300,7 @@ hssize_t H5File::getFreeSpace()
/// \li \c H5F_OBJ_ALL All of the above /// \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 ) /// \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 (|). /// Multiple object types can be combined with the logical OR operator (|).
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - May 2004
// Date May 2004
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
int H5File::getObjCount(unsigned types) int H5File::getObjCount(unsigned types)
{ {
@ -330,8 +319,7 @@ int H5File::getObjCount(unsigned types)
/// object types. /// object types.
///\return Number of opened object IDs ///\return Number of opened object IDs
///\exception H5::FileIException ///\exception H5::FileIException
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - May 2004
// Date May 2004
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
int H5File::getObjCount() int H5File::getObjCount()
{ {
@ -364,8 +352,7 @@ int H5File::getObjCount()
/// Multiple object types can be combined with the logical OR operator (|). /// Multiple object types can be combined with the logical OR operator (|).
// //
// Notes: will do the overload for this one after hearing from Quincey??? // Notes: will do the overload for this one after hearing from Quincey???
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - May 2004
// Date May 2004
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void H5File::getObjIDs(unsigned types, int max_objs, hid_t *oid_list) 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 obtained file handle is dynamic and is valid only while
/// the file remains open; it will be invalid if the file is /// the file remains open; it will be invalid if the file is
/// closed and reopened or opened during a subsequent session. /// closed and reopened or opened during a subsequent session.
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - May 2004
// Date May 2004
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void H5File::getVFDHandle(FileAccPropList& fapl, void **file_handle) 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 ///\param file_handle - Pointer to the file handle being used by
/// the low-level virtual file driver /// the low-level virtual file driver
///\exception H5::FileIException ///\exception H5::FileIException
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - May 2004
// Date May 2004
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void H5File::getVFDHandle(void **file_handle) 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::" // argument func_name is a member of CommonFG and "H5File::"
// will be inserted to indicate the function called is an // will be inserted to indicate the function called is an
// implementation of H5File. // implementation of H5File.
// Programmer Binh-Minh Ribler // Programmer Binh-Minh Ribler - 2000
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
void H5File::throwException(const string func_name, const string msg) const 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 // Function: H5File destructor
///\brief This is an overloaded member function, provided for convenience. ///\brief Properly terminates access to this file.
/// It differs from the above function only in what arguments it // Programmer Binh-Minh Ribler - 2000
/// accepts.
///\exception H5::FileIException
// Programmer Binh-Minh Ribler
// Date 2000
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
H5File::~H5File() H5File::~H5File()
{ {