Loading...
Searching...
No Matches
casacore::HDF5Record Class Reference
casa package (libcasa_casa) » HDF5_module

More...

`#include <HDF5Record.h>`

## Static Public Member Functions

static Record | readRecord (const HDF5Object &parentHid, const String &groupName)
| Read a record from the attributes of the given group.
static void | writeRecord (const HDF5Object &parentHid, const String &recordName, const RecordInterface &rec)
| Write the record as attributes of a group of the given parent.
static void | remove (const HDF5Object &parentHid, const String &recordName)
| Remove the record (i.e.
static Record | doReadRecord (hid_t parentHid)
| Read the (possibly nested) record values from the given group hid.
static void | doWriteRecord (const HDF5Object &groupHid, const RecordInterface &rec)
| Write the (possibly nested) record values into the given group hid.

## Static Private Member Functions

static void | readScalar (hid_t attrId, hid_t dtid, const String &name, RecordInterface &rec)
| Read a scalar value and add it to the record.
static void | readArray (hid_t attrId, hid_t dtid, const IPosition &, const String &name, RecordInterface &rec)
| Read an array value and add it to the record.
static void | readScaString (hid_t attrId, Int sz, const String &name, RecordInterface &rec)
| Read a scalar string from an attribute and add it to the record.
static void | readArrString (hid_t attrId, const IPosition &, const String &name, RecordInterface &rec)
| Read a array of strings from an atrribute and add it to the record.
static void | readEmptyArray (hid_t attrId, const String &name, RecordInterface &rec)
| Read a field containing an empty array.
template<typename T>
static void | readSca (hid_t attrId, const String &name, RecordInterface &rec)
| Read a field containing a scalar of fixed length.
template<typename T>
static void | readArr (hid_t attrId, const IPosition &shape, const String &name, RecordInterface &rec)
| Read a field containing an array of fixed length elements.
static void | read (hid_t attrId, void *value, const HDF5DataType &dtype)
| Read fixed length values from an attribute (scalar and array).
static void | writeScalar (hid_t parentHid, const String &name, const void *value, const HDF5DataType &dtype)
| Write a fixed length scalar value as attribute.
static void | writeArray (hid_t parentHid, const String &name, const void *value, const IPosition &shape, const HDF5DataType &dtype)
| Write an array of fixed length values as attribute.
static void | writeScaString (hid_t parentHid, const String &name, const String &value)
| Write a scalar string as attribute.
static void | writeArrString (hid_t parentHid, const String &name, const Array< String > &value)
| Write an array of strings as attribute.
static void | writeEmptyArray (hid_t groupHid, const String &name, Int rank, DataType dtype)
| Write a field containing an empty array.
template<typename T>
static void | writeSca (hid_t parentHid, const String &name, const RecordInterface &rec, Int i)
| Write a field containing a fixed length scalar value.
template<typename T>
static void | writeArr (hid_t parentHid, const String &name, const RecordInterface &rec, Int i)
| Write a field containing an array of fixed length elements.

## Detailed Description

A class to write/read a record into HDF5.

### Intended use:

Public interface

### Review Status

Test programs:
  tHDF5Record

### Prerequisite

- HDF5 system
- class Record

### Synopsis

This class has a static function to write a Record (or TableRecord) into an HDF5 file by storing it as attributes for the given group. Another static function can read back the Record. It can handle all types of fields in a record.
A few remarks:

- When writing the record, it first deletes all attributes of the group to be sure that the group's attributes only contain the record.
- A Casacore Record is a recursive structure, so it is written as nested groups. The name of a subgroup is the name of the subrecord.
- HDF5 cannot deal with empty arrays. Therefore they are written as a special compound type holding the rank and type of the empty array.
- HDF5 cannot hold empty fixed length strings. This is solved by storing an empty string with the special value empty.

### Motivation

Record is a very important class in Casacore images, so it has to be possible to read and write them from/to HDF5.

Definition at line 75 of file HDF5Record.h.

## Member Function Documentation

## doReadRecord()

Record casacore::HDF5Record::doReadRecord | ( | hid_t | parentHid | ) |

static

Read the (possibly nested) record values from the given group hid.

References casacore::Record().

## doWriteRecord()

void casacore::HDF5Record::doWriteRecord | ( | const HDF5Object & | groupHid,
|  | const RecordInterface & | rec )

static

Write the (possibly nested) record values into the given group hid.

References casacore::RecordInterface().

## read()

void casacore::HDF5Record::read | ( | hid_t | attrId,
|  | void * | value,
|  | const HDF5DataType & | dtype )

static private

Read fixed length values from an attribute (scalar and array).

References casacore::NewDelAllocator< T >::value.

## readArr()

template<typename T>

void casacore::HDF5Record::readArr | ( | hid_t | attrId,
|  | const IPosition & | shape,
|  | const String & | name,
|  | RecordInterface & | rec )

inline static private

Read a field containing an array of fixed length elements.

Definition at line 137 of file HDF5Record.h.

References casacore::name(), casacore::NewDelAllocator< T >::value, casacore::read(), casacore::RecordInterface(), and casacore::shape().

## readArray()

void casacore::HDF5Record::readArray | ( | hid_t | attrId,
|  | hid_t | dtid,
|  | const IPosition & | ,
|  | const String & | name,
|  | RecordInterface & | rec )

static private

Read an array value and add it to the record.

References casacore::name(), and casacore::RecordInterface().

## readArrString()

void casacore::HDF5Record::readArrString | ( | hid_t | attrId,
|  | const IPosition & | ,
|  | const String & | name,
|  | RecordInterface & | rec )

static private

Read a array of strings from an atrribute and add it to the record.

References casacore::name(), and casacore::RecordInterface().

## readEmptyArray()

void casacore::HDF5Record::readEmptyArray | ( | hid_t | attrId,
|  | const String & | name,
|  | RecordInterface & | rec )

static private

Read a field containing an empty array.

References casacore::name(), and casacore::RecordInterface().

## readRecord()

Record casacore::HDF5Record::readRecord | ( | const HDF5Object & | parentHid,
|  | const String & | groupName )

static

Read a record from the attributes of the given group.

Nested records are read back correctly. An empty record is returned if the group does not exist.

References casacore::Record().

## readSca()

template<typename T>

void casacore::HDF5Record::readSca | ( | hid_t | attrId,
|  | const String & | name,
|  | RecordInterface & | rec )

inline static private

Read a field containing a scalar of fixed length.

Definition at line 126 of file HDF5Record.h.

References casacore::name(), casacore::NewDelAllocator< T >::value, casacore::read(), and casacore::RecordInterface().

## readScalar()

void casacore::HDF5Record::readScalar | ( | hid_t | attrId,
|  | hid_t | dtid,
|  | const String & | name,
|  | RecordInterface & | rec )

static private

Read a scalar value and add it to the record.

References casacore::name(), and casacore::RecordInterface().

## readScaString()

void casacore::HDF5Record::readScaString | ( | hid_t | attrId,
|  | Int | sz,
|  | const String & | name,
|  | RecordInterface & | rec )

static private

Read a scalar string from an attribute and add it to the record.

References casacore::name(), and casacore::RecordInterface().

## remove()

void casacore::HDF5Record::remove | ( | const HDF5Object & | parentHid,
|  | const String & | recordName )

static

Remove the record (i.e.

group) from the given parent. Nothing is done if the record does not exist.

## writeArr()

template<typename T>

void casacore::HDF5Record::writeArr | ( | hid_t | parentHid,
|  | const String & | name,
|  | const RecordInterface & | rec,
|  | Int | i )

inline static private

Write a field containing an array of fixed length elements.

Definition at line 190 of file HDF5Record.h.

References casacore::name(), casacore::NewDelAllocator< T >::value, casacore::RecordInterface(), and writeArray().

## writeArray()

void casacore::HDF5Record::writeArray | ( | hid_t | parentHid,
|  | const String & | name,
|  | const void * | value,
|  | const IPosition & | shape,
|  | const HDF5DataType & | dtype )

static private

Write an array of fixed length values as attribute.

References casacore::name(), casacore::NewDelAllocator< T >::value, and casacore::shape().

Referenced by writeArr().

## writeArrString()

void casacore::HDF5Record::writeArrString | ( | hid_t | parentHid,
|  | const String & | name,
|  | const Array< String > & | value )

static private

Write an array of strings as attribute.

HDF5 cannot handle empty strings, so for empty strings a special value is written.

References casacore::name(), and casacore::NewDelAllocator< T >::value.

## writeEmptyArray()

void casacore::HDF5Record::writeEmptyArray | ( | hid_t | groupHid,
|  | const String & | name,
|  | Int | rank,
|  | DataType | dtype )

static private

Write a field containing an empty array.

References casacore::name().

## writeRecord()

void casacore::HDF5Record::writeRecord | ( | const HDF5Object & | parentHid,
|  | const String & | recordName,
|  | const RecordInterface & | rec )

static

Write the record as attributes of a group of the given parent.

Nested records are written as nested groups. The group is deleted first if it already exists.

References casacore::RecordInterface().

## writeSca()

template<typename T>

void casacore::HDF5Record::writeSca | ( | hid_t | parentHid,
|  | const String & | name,
|  | const RecordInterface & | rec,
|  | Int | i )

inline static private

Write a field containing a fixed length scalar value.

Definition at line 179 of file HDF5Record.h.

References casacore::name(), casacore::NewDelAllocator< T >::value, casacore::RecordInterface(), and writeScalar().

## writeScalar()

void casacore::HDF5Record::writeScalar | ( | hid_t | parentHid,
|  | const String & | name,
|  | const void * | value,
|  | const HDF5DataType & | dtype )

static private

Write a fixed length scalar value as attribute.

References casacore::name(), and casacore::NewDelAllocator< T >::value.

Referenced by writeSca().

## writeScaString()

void casacore::HDF5Record::writeScaString | ( | hid_t | parentHid,
|  | const String & | name,
|  | const String & | value )

static private

Write a scalar string as attribute.

HDF5 cannot handle empty strings, so for empty strings a special value is written.

References casacore::name(), and casacore::NewDelAllocator< T >::value.

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

- casa/HDF5/HDF5Record.h