H5T: Datatype Interface
Datatype Object API Functions
These functions create and manipulate the datatype which describes elements
of a dataset.
- Name: H5Tcreate
- Signature:
- hid_t
H5Tcreate
(H5T_class_t class
,
size_tsize
)
- Description:
- This function creates a new dataype of the specified class with the
specified number of bytes. Currently, only the
H5T_COMPOUND
datatype class is supported with this function, use H5Tcopy
to create integer or floating-point datatypes. The datatype ID
returned from this function should be released with H5Tclose or resource
leaks will result.
- Parameters:
- H5T_class_t
class
- Class of datatype to create.
- size_t
size
- The number of bytes in the datatype to create.
- Returns:
- Datatype ID on success, negative on failure.
- Name: H5Tcopy
- Signature:
- hid_t
H5Tcopy
(hid_t type_id
)
- Description:
- This function copies an existing datatype. The datatype ID returned
should be released with H5Tclose or resource leaks will occur. Native
datatypes supported by the library are:
- H5T_NATIVE_CHAR
- Native character type, declare dataset array as 'char'
- H5T_NATIVE_UCHAR
- Native unsigned character type, declare dataset array as 'unsigned char'
- H5T_NATIVE_SHORT
- Native short type, declare dataset array as 'short'
- H5T_NATIVE_USHORT
- Native unsigned short type, declare dataset array as 'unsigned short'
- H5T_NATIVE_INT
- Native int type, declare dataset array as 'int'
- H5T_NATIVE_UINT
- Native unsigned int type, declare dataset array as 'unsigned int'
- H5T_NATIVE_LONG
- Native long type, declare dataset array as 'unsigned long'
- H5T_NATIVE_ULONG
- Native unsigned long type, declare dataset array as 'unsigned long'
- H5T_NATIVE_LLONG
- Native long long type, declare dataset array as 'unsigned long long'
- H5T_NATIVE_ULLONG
- Native unsigned long long type, declare dataset array as 'unsigned long long'
- H5T_NATIVE_INT8
- Native signed 8-bit type, declare dataset array as 'int8'
- H5T_NATIVE_UINT8
- Native unsigned 8-bit type, declare dataset array as 'uint8'
- H5T_NATIVE_INT16
- Native signed 16-bit type, declare dataset array as 'int16'
- H5T_NATIVE_UINT16
- Native unsigned 16-bit type, declare dataset array as 'uint16'
- H5T_NATIVE_INT32
- Native signed 32-bit type, declare dataset array as 'int32'
- H5T_NATIVE_UINT32
- Native unsigned 32-bit type, declare dataset array as 'uint32'
- H5T_NATIVE_INT64
- Native signed 64-bit type, declare dataset array as 'uint64'
- H5T_NATIVE_UINT64
- Native unsigned 64-bit type, declare dataset array as 'uint64'
- H5T_NATIVE_FLOAT
- Native single-precision float type, declare dataset array as 'float'
- H5T_NATIVE_DOUBLE
- Native double-precision float type, declare dataset array as 'double'
- Parameters:
- hid_t
type_id
- ID of datatype to copy.
- Returns:
- Datatype ID on success, negative on failure.
- Name: H5Tequal
- Signature:
- hbool_t
H5Tequal
(hid_t type_id1
,
hid_ttype_id2
)
- Description:
- This function determines if two datatype IDs refer to the same
datatype.
- Parameters:
- hid_t
type_id1
- ID of datatype to compare.
- hid_t
type_id2
- ID of datatype to compare.
- Returns:
- TRUE/FALSE/negative
- Name: H5Tlock
- Signature:
- herr_t
H5Tlock
(hid_t type_id
)
- Description:
- This function locks a type, making it read-only and non-destrucible.
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.
- Parameters:
- hid_t
type_id
- ID of datatype to lock.
- Returns:
- zero/negative
- Name: H5Tget_class
- Signature:
- H5T_class_t
H5Tget_class
(hid_t type_id
)
- Description:
- This function returns the base class of a datatype.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Non-negative type class on success, negative on failure.
- Name: H5Tget_size
- Signature:
- size_t
H5Tget_size
(hid_t type_id
)
- Description:
- This function returns the size of a datatype in bytes.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Positve size in bytes on success, 0 on failure.
- Name: H5Tset_size
- Signature:
- herr_t
H5Tset_size
(hid_t type_id
,
size_tsize
)
- Description:
- This function sets the total size in bytes for an atomic data type (this
operation is not permitted on compound data types). If the size is
decreased so that the significant bits of the data type extend beyond
the edge of the new size, then the `offset' property is decreased
toward zero. If the `offset' becomes zero and the significant
bits of the data type still hang over the edge of the new size, then
the number of significant bits is decreased.
Adjusting the size of an H5T_STRING automatically sets the precision
to 8*size. All data types have a positive size.
- Parameters:
- hid_t
type_id
- ID of datatype to change size.
- size_t
size
- Size in bytes to modify datatype.
- Returns:
- zero/negative
- Name: H5Tget_order
- Signature:
- H5T_order_t
H5Tget_order
(hid_t type_id
)
- Description:
- This function returns the byte order of an atomic datatype.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Byte order constant on success, negative on failure
- Name: H5Tset_order
- Signature:
- herr_t
H5Tset_order
(hid_t type_id
,
H5T_order_torder
)
- Description:
- This function sets the byte ordering of an atomic datatype.
Byte orderings currently supported are:
- H5T_ORDER_LE
- Little-endian byte ordering (default)
- H5T_ORDER_BE
- Big-endian byte ordering
- H5T_ORDER_Vax
- VAX-endianness byte ordering (not currently supported)
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- H5T_order_t
order
- Byte ordering constant.
- Returns:
- zero/negative
- Name: H5Tget_precision
- Signature:
- size_t
H5Tget_precision
(hid_t type_id
)
- Description:
- This function returns the precision of an atomic data type. The
precision is the number of significant bits which, unless padding is
present, is 8 times larger than the value returned by H5Tget_size().
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Number of significant bits on success, 0 on failure
- Name: H5Tset_precision
- Signature:
- herr_t
H5Tset_precision
(hid_t type_id
,
size_tprecision
)
- Description:
- This function sets the precision of an atomic data type. The precision
is the number of significant bits which, unless padding is present, is 8
times larger than the value returned by H5Tget_size().
If the precision is increased then the offset is decreased and then
the size is increased to insure that significant bits do not "hang
over" the edge of the data type.
Changing the precision of an H5T_STRING automatically changes the
size as well. The precision must be a multiple of 8.
When decreasing the precision of a floating point type, set the
locations and sizes of the sign, mantissa, and exponent fields
first.
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- size_t
precision
- Number of bits of precision for datatype.
- Returns:
- zero/negative
- Name: H5Tget_offset
- Signature:
- size_t
H5Tget_offset
(hid_t type_id
)
- Description:
- This function retrieves the bit offset of the first significant bit.
The signficant bits of an atomic datum can be offset from the beginning
of the memory for that datum by an amount of padding. The `offset'
property specifies the number of bits of padding that appear to the
"right of" the value. That is, if we have a 32-bit datum with 16-bits
of precision having the value 0x1122 then it will be layed out in
memory as (from small byte address toward larger byte addresses):
Byte Position |
Big-Endian Offset=0 |
Big-Endian Offset=16 |
Little-Endian Offset=0 |
Little-Endian Offset=16 |
0: |
[ pad] |
[0x11] |
[0x22] |
[ pad] |
1: |
[ pad] |
[0x22] |
[0x11] |
[ pad] |
2: |
[0x11] |
[ pad] |
[ pad] |
[0x22] |
3: |
[0x22] |
[ pad] |
[ pad] |
[0x11] |
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Positive offset value on success, 0 on failure.
- Name: H5Tset_offset
- Signature:
- herr_t
H5Tset_offset
(hid_t type_id
,
size_t offset
)
- Description:
- This function sets the bit offset of the first significant bit. The
signficant bits of an atomic datum can be offset from the beginning of
the memory for that datum by an amount of padding. The `offset'
property specifies the number of bits of padding that appear to the
"right of" the value. That is, if we have a 32-bit datum with 16-bits
of precision having the value 0x1122 then it will be layed out in
memory as (from small byte address toward larger byte addresses):
Byte Position |
Big-Endian Offset=0 |
Big-Endian Offset=16 |
Little-Endian Offset=0 |
Little-Endian Offset=16 |
0: |
[ pad] |
[0x11] |
[0x22] |
[ pad] |
1: |
[ pad] |
[0x22] |
[0x11] |
[ pad] |
2: |
[0x11] |
[ pad] |
[ pad] |
[0x22] |
3: |
[0x22] |
[ pad] |
[ pad] |
[0x11] |
If the offset is incremented then the total size is
incremented also if necessary to prevent significant bits of
the value from hanging over the edge of the data type.
The offset of an H5T_STRING cannot be set to anything but
zero.
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- size_t
offset
- Offset of first significant bit.
- Returns:
- zero/negative
- Name: H5Tget_pad
- Signature:
- herr_t
H5Tget_pad
(hid_t type_id
,
H5T_pad_t * lsb
,
H5T_pad_t * msb
)
- Description:
- This function retrieves the padding type of the least and most-significant
bit padding. Valid types are:
- H5T_PAD_ZERO
- Set background to zeros.
- H5T_PAD_ONE
- Set background to ones.
- H5T_PAD_BACKGROUND
- Leave background alone.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- H5T_pad_t *
lsb
- Pointer to location to return least-significant bit padding type.
- H5T_pad_t *
msb
- Pointer to location to return most-significant bit padding type.
- Returns:
- zero/negative
- Name: H5Tset_pad
- Signature:
- herr_t
H5Tset_pad
(hid_t type_id
,
H5T_pad_t lsb
,
H5T_pad_t msb
)
- Description:
- This function sets the least and most-significant bits padding types.
- H5T_PAD_ZERO
- Set background to zeros.
- H5T_PAD_ONE
- Set background to ones.
- H5T_PAD_BACKGROUND
- Leave background alone.
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- H5T_pad_t
lsb
- Padding type for least-significant bits.
- H5T_pad_t
msb
- Padding type for most-significant bits.
- Returns:
- zero/negative
- Name: H5Tget_sign
- Signature:
- H5T_sign_t
H5Tget_sign
(hid_t type_id
)
- Description:
- This function retrieves the sign type for an integer type.
Valid types are:
- H5T_SGN_NONE
- Unsigned integer type.
- H5T_SGN_2
- Two's complement signed integer type.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Non-negative sign type on success, negative on failure
- Name: H5Tset_sign
- Signature:
- herr_t
H5Tset_sign
(hid_t type_id
,
H5T_sign_t sign
)
- Description:
- This function sets the sign proprety for an integer type.
- H5T_SGN_NONE
- Unsigned integer type.
- H5T_SGN_2
- Two's complement signed integer type.
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- H5T_sign_t
sign
- Sign type.
- Returns:
- zero/negative
- Name: H5Tget_fields
- Signature:
- herr_t
H5Tget_fields
(hid_t type_id
,
size_t * epos
,
size_t * esize
,
size_t * mpos
,
size_t * msize
)
- Description:
- This function retrieves information about the locations of the various
bit fields of a floating point data type. The field positions are bit
positions in the significant region of the data type. Bits are
numbered with the least significant bit number zero.
Any (or even all) of the arguments can be null pointers.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- size_t *
epos
- Pointer to location to return exponent bit-position.
- size_t *
esize
- Pointer to location to return size of exponent in bits.
- size_t *
mpos
- Pointer to location to return mantissa bit-position.
- size_t *
msize
- Pointer to location to return size of mantissa in bits.
- Returns:
- zero/negative
- Name: H5Tset_fields
- Signature:
- herr_t
H5Tset_fields
(hid_t type_id
,
size_t epos
,
size_t esize
,
size_t mpos
,
size_t msize
)
- Description:
- This function sets the locations and sizes of the various floating
point bit fields. The field positions are bit positions in the
significant region of the data type. Bits are numbered with the least
significant bit number zero.
Fields are not allowed to extend beyond the number of bits of
precision, nor are they allowed to overlap with one another.
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- size_t
epos
- Exponent bit position.
- size_t
esize
- Size of exponent in bits.
- size_t
mpos
- Mantissa bit position.
- size_t
msize
- Size of mantissa in bits.
- Returns:
- zero/negative
- Name: H5Tget_ebias
- Signature:
- size_t
H5Tget_ebias
(hid_t type_id
)
- Description:
- This function retrieves the exponent bias of a floating-point type.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Positive value on success, 0 on failure.
- Name: H5Tset_ebias
- Signature:
- herr_t
H5Tset_ebias
(hid_t type_id
,
size_t ebias
)
- Description:
- This function sets the exponent bias of a floating-point type.
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- size_t
ebias
- Exponent bias value.
- Returns:
- zero/negative
- Name: H5Tget_norm
- Signature:
- H5T_norm_t
H5Tget_norm
(hid_t type_id
)
- Description:
- This function retrieves the mantissa normalization of a floating-point
datatype. Valid normalization values are:
- H5T_NORM_IMPLIED
- MSB of mantissa isn't stored, always 1
- H5T_NORM_MSBSET
- MSB of mantissa is always 1
- H5T_NORM_NONE
- Mantissa is not normalized
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Non-negative normalization type on success, negative on failure
- Name: H5Tset_norm
- Signature:
- herr_t
H5Tset_norm
(hid_t type_id
,
H5T_norm_t norm
)
- Description:
- This function sets the mantissa normalization of a floating-point
datatype. Valid normalization values are:
- H5T_NORM_IMPLIED
- MSB of mantissa isn't stored, always 1
- H5T_NORM_MSBSET
- MSB of mantissa is always 1
- H5T_NORM_NONE
- Mantissa is not normalized
- Parameters:
- hid_t
type_id
- ID of datatype to set.
- H5T_norm_t
norm
- Mantissa normalization type.
- Returns:
- zero/negative
- Name: H5Tget_inpad
- Signature:
- H5T_pad_t
H5Tget_inpad
(hid_t type_id
)
- Description:
- This function retrieves the internal padding type for unused bits in
floating-point datatypes.
Valid padding values are:
- H5T_PAD_ZERO
- Set background to zeros.
- H5T_PAD_ONE
- Set background to ones.
- H5T_PAD_BACKGROUND
- Leave background alone.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Non-negative padding type on success, negative on failure
- Name: H5Tset_inpad
- Signature:
- herr_t
H5Tset_inpad
(hid_t type_id
,
H5T_pad_t inpad
)
- Description:
- If any internal bits of a floating point type are unused
(that is, those significant bits which are not part of the
sign, exponent, or mantissa) then they will be filled
according to the value of this property.
Valid padding values are:
- H5T_PAD_ZERO
- Set background to zeros.
- H5T_PAD_ONE
- Set background to ones.
- H5T_PAD_BACKGROUND
- Leave background alone.
- Parameters:
- hid_t
type_id
- ID of datatype to modify.
- H5T_pad_t
pad
- Padding type.
- Returns:
- zero/negative
- Name: H5Tget_cset
- Signature:
- H5T_cset_t
H5Tget_cset
(hid_t type_id
)
- Description:
- This function retrieves the character set type of a string datatype.
Valid character set values are:
- H5T_CSET_ASCII
- Character set is US ASCII
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Non-negative character set type on success, negative on failure
- Name: H5Tset_cset
- Signature:
- herr_t
H5Tset_cset
(hid_t type_id
,
H5T_cset_t cset
)
- Description:
- HDF5 is able to distinguish between character sets of different
nationalities and to convert between them to the extent possible.
Valid character set values are:
- H5T_CSET_ASCII
- Character set is US ASCII
- Parameters:
- hid_t
type_id
- ID of datatype to modify.
- H5T_cset_t
cset
- Character set type.
- Returns:
- zero/negative
- Name: H5Tget_strpad
- Signature:
- H5T_str_t
H5Tget_strpad
(hid_t type_id
)
- Description:
- This function retrieves the string padding method for a string datatype.
Valid string padding values are:
- H5T_STR_NULL
- Pad with zeros (as C does)
- H5T_STR_SPACE
- Pad with spaces (as FORTRAN does)
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Non-negative string padding type on success, negative on failure
- Name: H5Tset_strpad
- Signature:
- herr_t
H5Tset_strpad
(hid_t type_id
,
H5T_str_t strpad
)
- Description:
- The method used to store character strings differs with the programming
language: C usually null terminates strings while Fortran
left-justifies and space-pads strings. This property defines the
storage mechanism for the string.
Valid string padding values are:
- H5T_STR_NULL
- Pad with zeros (as C does)
- H5T_STR_SPACE
- Pad with spaces (as FORTRAN does)
- Parameters:
- hid_t
type_id
- ID of datatype to modify.
- H5T_str_t
strpad
- String padding type.
- Returns:
- zero/negative
- Name: H5Tget_nmembers
- Signature:
- intn
H5Tget_nmembers
(hid_t type_id
)
- Description:
- This function retrieves the number of fields a compound datatype has.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- Returns:
- Number of members datatype has on success, negative on failure
- Name: H5Tget_member_name
- Signature:
- char *
H5Tget_member_name
(hid_t type_id
,
intn fieldno
)
- Description:
- This function retrieves the name of a field of a compound data type.
Fields are stored in no particular order with numbers 0 through N-1
where N is the value returned by H5Tget_nmembers(). The name of the
field is allocated with malloc() and the caller is responsible for
freeing the memory used by the name.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- intn
fieldno
- Field number (indexed from 0) of the field name to retrieve.
- Returns:
- Valid pointer on success, NULL on failure
- Name: H5Tget_member_dims
- Signature:
- int
H5Tget_member_dims
(hid_t type_id
,
intn fieldno
,
size_t * dims
,
int * perm
)
- Description:
- This function returns the dimensionality of the field. The dimensions
and permuation vector are returned through arguments
dims
and perm
, both arrays of at least four elements. Either
(or even both) may be null pointers.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- intn
fieldno
- Field number (indexed from 0) of the field dims to retrieve.
- size_t *
dims
- Pointer to buffer to store the dimensions of the field.
- int *
perm
- Pointer to buffer to store the permutation vector of the field.
- Returns:
- Number of dimensions on success, negative on failure.
- Name: H5Tget_member_type
- Signature:
- hid_t
H5Tget_member_type
(hid_t type_id
,
intn fieldno
)
- Description:
- This function returns the data type of the specified member. The caller
should invoke H5Tclose() to release resources associated with the type.
- Parameters:
- hid_t
type_id
- ID of datatype to query.
- intn
fieldno
- Field number (indexed from 0) of the field type to retrieve.
- Returns:
- The ID of a copy of the datatype of the field, negative on failure.
- Name: H5Tinsert
- Signature:
- herr_t
H5Tinsert
(hid_t type_id
,
const char * name
,
off_t offset
,
hid_t field_id
)
- Description:
- This function adds another member to the compound data type
type_id
. The new member has a name
which
must be unique within the compound data type. The offset
argument defines the start of the member in an instance of the compound
data type, and field_id
is the type of the new member.
Note: All members of a compound data type must be atomic; a
compound data type cannot have a member which is a compound data
type.
- Parameters:
- hid_t
type_id
- ID of compound datatype to modify.
- const char *
name
- Name of the field to insert.
- off_t
offset
- Offset in memory structure of the field to insert.
- hid_t
field_id
- Datatype ID of the field to insert.
- Returns:
- zero/negative
- Name: H5Tpack
- Signature:
- herr_t
H5Tpack
(hid_t type_id
)
- Description:
- This function recursively removes padding from within a compound
datatype to make it more efficient (space-wise) to store that data.
- Parameters:
- hid_t
type_id
- ID of datatype to modify.
- Returns:
- zero/negative
- Name: H5Tregister_hard
- Signature:
- herr_t
H5Tregister_hard
(const char
* name
, hid_t src_id
,
hid_t dst_id
,
H5T_conv_t func
)
- Description:
- This function registers a hard conversion function for a data type
conversion path. The path is specified by the source and destination
datatypes
src_id
and dst_id
. A conversion
path can only have one hard function, so func
replaces any
previous hard function.
If func
is the null pointer then any hard function
registered for this path is removed from this path. The soft functions
are then used when determining which conversion function is appropriate
for this path. The name
argument is used only
for debugging and should be a short identifier for the function.
The type of the conversion function pointer is declared as:
typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t nelmts, void *buf, void *bkg);
- Parameters:
- const char *
name
- Name displayed in diagnostic output.
- hid_t
src_id
- ID of source datatype.
- hid_t
dst_id
- ID of destination datatype.
- H5T_conv_t
func
- Function to convert between source and destination datatypes.
- Returns:
- zero/negative
- Name: H5Tregister_soft
- Signature:
- herr_t
H5Tregister_soft
(const char
* name
, hid_t src_id
,
hid_t dst_id
,
H5T_conv_t func
)
- Description:
- This function registers a soft conversion function by adding it to the
end of the master soft list and replacing the soft function in all
applicable existing conversion paths. The
name
is used only for debugging and should be a short identifier
for the function.
The type of the conversion function pointer is declared as:
typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t nelmts, void *buf, void *bkg);
- Parameters:
- const char *
name
- Name displayed in diagnostic output.
- hid_t
src_id
- ID of source datatype.
- hid_t
dst_id
- ID of destination datatype.
- H5T_conv_t
func
- Function to convert between source and destination datatypes.
- Returns:
- zero/negative
- Name: H5Tunregister
- Signature:
- herr_t
H5Tunregister
(H5T_conv_t func
)
- Description:
- This function removes a conversion function from all conversion paths.
The type of the conversion function pointer is declared as:
typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t nelmts, void *buf, void *bkg);
- Parameters:
- H5T_conv_t
func
- Function to remove from conversion paths.
- Returns:
- zero/negative
- Name: H5Tclose
- Signature:
- herr_t
H5Tclose
(hid_t type_id
)
- Description:
- This function releases a datatype. Further access through the datatype
ID is illegal. Failure to release a datatype with this call will
result in resource leaks.
- Parameters:
- hid_t
type_id
- ID of datatype to release.
- Returns:
- zero/negative
UNUSED PORTIONS OF EMAIL NOTES.
....
in left margin indicates where material was
pulled out for inclusion above.
Elena> Datatype Interface:
Elena> Do we have description of the named datatypes somewhere?
>From Datatypes.html...
html> 7. Sharing Data Types among Datasets
html>
html> If a file has lots of datasets which have a common data type
html> then the file could be made smaller by having all the datasets
html> share a single data type. Instead of storing a copy of the data
html> type in each dataset object header, a single data type is stored
html> and the object headers point to it. The space savings is
html> probably only significant for datasets with a compound data type
html> since the simple data types can be described with just a few
html> bytes anyway.
html>
html> To create a bunch of datasets that share a single data type just
html> create the datasets with a committed (named) data type.
html>
html> To create two datasets that share a common data type one just
html> commits the data type, giving it a name, and then uses that
html> data type to create the datasets.
html>
html> hid_t t1 = ...some transient type...;
html> H5Tcommit (file, "shared_type", t1);
html> hid_t dset1 = H5Dcreate (file, "dset1", t1, space, H5P_DEFAULT);
html> hid_t dset2 = H5Dcreate (file, "dset2", t1, space, H5P_DEFAULT);
html>
html>
html> And to create two additional datasets later which share the
html> same type as the first two datasets:
html>
html> hid_t dset1 = H5Dopen (file, "dset1");
html> hid_t t2 = H5Dget_type (dset1);
html> hid_t dset3 = H5Dcreate (file, "dset3", t2, space, H5P_DEFAULT);
html> hid_t dset4 = H5Dcreate (file, "dset4", t2, space, H5P_DEFAULT);
html>
html>
html> Example: Shared Types
Mail from Quincey summarizing shared data types:
Quincey> Hi Robb,
Quincey> Everything looks good, I just have a couple of minor comments below:
Quincey>
Quincey> > A very quick data types summary (so I can remember it next week :-)
Quincey> >
Quincey> > * Handles to named types are immutable.
Quincey> >
Quincey> > * A transient type handle can be converted to a named type handle
Quincey> > by calling H5Tcommit(). This can only be called for transient
Quincey> > types which are not locked or predefined.
Quincey> >
Quincey> > * H5Topen() returns a handle to a named immutable type.
Quincey> >
Quincey> > * H5Tcopy() returns a handle to a transient type.
Quincey> H5Tcreate also returns a handle to a transient type.
Quincey>
Quincey> > * Using a named type in H5Dcreate() causes the dataset object
Quincey> > header to point to the named type (shared). The link count on
Quincey> > the named type is incremented.
Quincey> >
Quincey> > * Using a transient type in H5Dcreate() causes the type to be
Quincey> > copied and stored in the dataset header (unshared).
Quincey> >
Quincey> > * Type handles returned from H5Dget_type() are immutable.
Quincey> >
Quincey> > * If the dataset is using a shared type (dataset object header
Quincey> > points to some other object header with a type message, e.g., a
Quincey> > named type) then H5Dget_type() returns a handle to that named
Quincey> > type.
Quincey> >
Quincey> > * If the dataset has a private type (data type is stored in the
Quincey> > dataset object header) then H5Dget_type() returns a handle to a
Quincey> > transient immutable type.
Quincey> >
Quincey> > * The name of a data type can be removed from a group, but unless
Quincey> > the reference count becomes zero the type continues to exist.
Quincey> > (Other objects work this way too).
Quincey> >
Quincey> > * H5Tcopy() applied to a dataset returns a transient, modifiable
Quincey> > copy of that dataset's data type.
Quincey> >
Quincey> > * H5Topen() applied to a dataset returns either a transient
Quincey> > immutable or named immutable data type depending on whether the
Quincey> > dataset has a shared data type.
Quincey> Hmm, do we want to allow this? It makes a certain amount of sense, but
Quincey> is a little unusual... :-)
Quincey>
Elena, we decided not not to allow H5Topen() on a dataset.
Quincey>
Quincey> > * The H5Tshare() and H5Tis_shared() will be removed. Data types
Quincey> > will not be stored in the global heap. A new type of shared
Quincey> > message header will be added to the object headers that points to
Quincey> > another object header instead of the global heap
Quincey>
Quincey> > * Still to discuss: Attributes on named data types?
Quincey> I think we should all them.
Quincey>
Elena, attributes work for named data types just like they do for
datasets.
Quincey>
Quincey> > * Still to discuss: compound types whose members point to other types.
Quincey> I like this concept a lot and this we should figure out a way to do it.
Quincey> This allows the "is a" relationship to be used very nicely for named datatypes.
Quincey>
Quincey> > * Still to discuss: datasets that point to data types in other
Quincey> > files by symbolic link.
Quincey> Probably a good idea also, just ugly to implement.
Quincey>
Frank Baker
HDF5 Documentation
Last modified: 29 June 1998