casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::HDF5DataType Class Reference

A class representing an HDF5 data type. More...

#include <HDF5DataType.h>

Public Member Functions

 HDF5DataType ()
 The default constructor makes an invalid object. More...
 
 HDF5DataType (const Bool *)
 Create an HDF5 datatype object for the given fixed length type. More...
 
 HDF5DataType (const uChar *)
 
 HDF5DataType (const Short *)
 
 HDF5DataType (const uShort *)
 
 HDF5DataType (const Int *)
 
 HDF5DataType (const uInt *)
 
 HDF5DataType (const Int64 *)
 
 HDF5DataType (const Float *)
 
 HDF5DataType (const Double *)
 
 HDF5DataType (const Complex *)
 
 HDF5DataType (const DComplex *)
 
 HDF5DataType (const String *)
 
 HDF5DataType (const String &value)
 Create an HDF5 datatype object for a scalar string. More...
 
 HDF5DataType (Int, Int)
 Create an HDF5 datatype object for an empty array. More...
 
 HDF5DataType (const std::vector< String > &names, const std::vector< HDF5DataType > &types)
 Define a compound data type consisting of the given fields and types. More...
 
 HDF5DataType (const HDF5DataType &, const IPosition &shape)
 Create an array of the given data type. More...
 
 HDF5DataType (const HDF5DataType &that)
 The copy constructor makes a deep copy. More...
 
 ~HDF5DataType ()
 The destructor closes the HDF5 data type object. More...
 
HDF5DataTypeoperator= (const HDF5DataType &that)
 Assignment makes a deep copy. More...
 
hid_t getHidMem () const
 Get the HID for the data type in memory. More...
 
hid_t getHidFile () const
 Get the HID for the data type in the file. More...
 
uInt size () const
 Get the size in bytes of the data type (in memory). More...
 

Static Public Member Functions

static DataType getDataType (hid_t)
 Get the Casacore data type for the given HDF5 data type. More...
 
static Bool isComplex (hid_t dtid)
 Test if the data type is Complex or DComplex. More...
 
static Bool isEmptyArray (hid_t dtid)
 Test if the data type is an empty array. More...
 
static IPosition getShape (hid_t dtid)
 Get the shape of an array data type. More...
 
static Block< hsize_tfromShape (const IPosition &shape)
 Helper functions to convert shapes. More...
 
static IPosition toShape (const Block< hsize_t > &b)
 

Private Member Functions

void addToCompound (const char *name, uInt offset, const HDF5DataType &dtype)
 Add a field to a compound data type. More...
 

Private Attributes

HDF5HidDataType itsHidMem
 
HDF5HidDataType itsHidFile
 
uInt itsSize
 

Detailed Description

A class representing an HDF5 data type.

Intended use:

Internal

Review Status

Test programs:
tHDF5DataType

Prerequisite

Synopsis

This class wraps the HDF5 functions to create a data type for the data in memory and for the file. The HDF5 file data type order is set to LittleEndian.
The basic constructors define a scalar of a basic data type or data type Complex and DComplex. Strings are also supported. However, it is also possible to define a fixed shaped array for any HDF5DataType. Furthermore, it is possible to define a compound data type consisting of named fields of any HDF5DataType with a fixed size. Arrays and/or compounds can be nested at will.
Variable length strings are supported, but cannot be used in compounds.
Older HDF5 versions did not support empty arrays. Therefore they are represented as a compound with 3 fields. Also they did not support boolean values; they are represented as a signed char. HDF5 does not support complex values either. They are represented as a compound with fields 're' and 'im'.

Motivation

The HDF5 C++ interface only supports the HDF5 C functionality and resembles that to much. For instance, it does not use STL containers. It does not support non-basic data types, in particular Complex.

Definition at line 86 of file HDF5DataType.h.

Constructor & Destructor Documentation

casacore::HDF5DataType::HDF5DataType ( )
inline

The default constructor makes an invalid object.

It is needed to make a vector of objects.

Definition at line 91 of file HDF5DataType.h.

casacore::HDF5DataType::HDF5DataType ( const Bool )
explicit

Create an HDF5 datatype object for the given fixed length type.

It uses the corresponding native HDF5 data type. Only for Bool it uses a uchar, because the HDF5 bool type is a uint. For the complex types it makes a compound HDF5 data type. The String type is meant for an array of strings.

casacore::HDF5DataType::HDF5DataType ( const uChar )
explicit
casacore::HDF5DataType::HDF5DataType ( const Short )
explicit
casacore::HDF5DataType::HDF5DataType ( const uShort )
explicit
casacore::HDF5DataType::HDF5DataType ( const Int )
explicit
casacore::HDF5DataType::HDF5DataType ( const uInt )
explicit
casacore::HDF5DataType::HDF5DataType ( const Int64 )
explicit
casacore::HDF5DataType::HDF5DataType ( const Float )
explicit
casacore::HDF5DataType::HDF5DataType ( const Double )
explicit
casacore::HDF5DataType::HDF5DataType ( const Complex *  )
explicit
casacore::HDF5DataType::HDF5DataType ( const DComplex *  )
explicit
casacore::HDF5DataType::HDF5DataType ( const String )
explicit
casacore::HDF5DataType::HDF5DataType ( const String value)
explicit

Create an HDF5 datatype object for a scalar string.

The length of the string is part of the type.

casacore::HDF5DataType::HDF5DataType ( Int  ,
Int   
)

Create an HDF5 datatype object for an empty array.

Both arguments are dummy (needed to distinguish the constructor). An empty array as represented as a compound data type with integer field names emptyarray, rank and casatype.

casacore::HDF5DataType::HDF5DataType ( const std::vector< String > &  names,
const std::vector< HDF5DataType > &  types 
)

Define a compound data type consisting of the given fields and types.

An exception is thrown if the vectors are empty or have mismatching sizes.

casacore::HDF5DataType::HDF5DataType ( const HDF5DataType ,
const IPosition shape 
)

Create an array of the given data type.

An exception is thrown if the shape is empty.

casacore::HDF5DataType::HDF5DataType ( const HDF5DataType that)

The copy constructor makes a deep copy.

casacore::HDF5DataType::~HDF5DataType ( )

The destructor closes the HDF5 data type object.

Member Function Documentation

void casacore::HDF5DataType::addToCompound ( const char *  name,
uInt  offset,
const HDF5DataType dtype 
)
private

Add a field to a compound data type.

It does it for the memory and file data type.

static Block<hsize_t> casacore::HDF5DataType::fromShape ( const IPosition shape)
static

Helper functions to convert shapes.

It reverses the axes, because HDF5 uses C-order.

static DataType casacore::HDF5DataType::getDataType ( hid_t  )
static

Get the Casacore data type for the given HDF5 data type.

TpRecord is returned for a compound data type.

hid_t casacore::HDF5DataType::getHidFile ( ) const
inline

Get the HID for the data type in the file.

Definition at line 153 of file HDF5DataType.h.

References itsHidFile.

hid_t casacore::HDF5DataType::getHidMem ( ) const
inline

Get the HID for the data type in memory.

Definition at line 149 of file HDF5DataType.h.

References itsHidMem.

static IPosition casacore::HDF5DataType::getShape ( hid_t  dtid)
static

Get the shape of an array data type.

It returns an empty IPosition for non-arrays.

static Bool casacore::HDF5DataType::isComplex ( hid_t  dtid)
static

Test if the data type is Complex or DComplex.

static Bool casacore::HDF5DataType::isEmptyArray ( hid_t  dtid)
static

Test if the data type is an empty array.

HDF5DataType& casacore::HDF5DataType::operator= ( const HDF5DataType that)

Assignment makes a deep copy.

uInt casacore::HDF5DataType::size ( ) const
inline

Get the size in bytes of the data type (in memory).

Note that the size of a string is variable, thus 0.

Definition at line 158 of file HDF5DataType.h.

References itsSize.

static IPosition casacore::HDF5DataType::toShape ( const Block< hsize_t > &  b)
static

Member Data Documentation

HDF5HidDataType casacore::HDF5DataType::itsHidFile
private

Definition at line 187 of file HDF5DataType.h.

Referenced by getHidFile().

HDF5HidDataType casacore::HDF5DataType::itsHidMem
private

Definition at line 186 of file HDF5DataType.h.

Referenced by getHidMem().

uInt casacore::HDF5DataType::itsSize
private

Definition at line 188 of file HDF5DataType.h.

Referenced by size().


The documentation for this class was generated from the following file: