HDF5Serie

Project Page
Public Member Functions
H5::StructSerie< S > Class Template Reference

Serie of structs (compount datas). More...

#include <structserie.h>

List of all members.

Public Member Functions

 StructSerie ()
 A stub constructor.
void registerMember (const S &s, const CTYPE &e, const std::string name)
 Register a scalar member of the struct.
void registerMember (const S &s, const std::vector< CTYPE > &e, unsigned int N, const std::string name)
 Register a vector member of the struct.
void create (const CommonFG &parent, const std::string &name, int compression=FileSerie::getDefaultCompression(), int chunkSize=FileSerie::getDefaultChunkSize())
 Creating a dataset.
void open (const CommonFG &parent, const std::string &name)
 Open a dataset.
void setDescription (const std::string &desc)
 Sets a description for the dataset.
std::string getDescription ()
 Return the description for the dataset.
void append (const S &data)
 Append a data struct.
int getRows ()
 Returns the number of elements in the dataset.
unsigned int getMembers ()
 Returns the number of members in the struct.
S getRow (const int row)
 Returns the data struct at element row.
std::vector< std::string > getMemberLabel ()
 Returns the member labels.
void extend (const hsize_t *size)

Detailed Description

template<class S>
class H5::StructSerie< S >

Serie of structs (compount datas).

A HDF5 dataset for reading and writing a serie of structs (compount datas). The type of each data of the struct can be of:

Or a vector of fixed lenght of this type.

The data is stored as a 1D array in the HDF5 file. Each element in the array is one struct.


Constructor & Destructor Documentation

template<class S >
H5::StructSerie< S >::StructSerie ( )

A stub constructor.

Creates a empty object.


Member Function Documentation

template<class S >
void H5::StructSerie< S >::append ( const S &  data)

Append a data struct.

Appends the data struct data at the end of the dataset. The number of elements of the HDF5 array will be incremented by this operation.

template<class S >
void H5::StructSerie< S >::create ( const CommonFG &  parent,
const std::string &  name,
int  compression = FileSerie::getDefaultCompression(),
int  chunkSize = FileSerie::getDefaultChunkSize() 
)

Creating a dataset.

Creates a dataset named name as a child of position parent. By default the dataset is compressed using deflate (gzip) with compression level FileSerie::defaultCompression. Use compression to adjuste the compression level [1-9] or 0 to disable compression. NOTE that the object can not be created before the members of the struct are registered using registerMember(const S& s, const CTYPE& e, const std::string name) or registerMember(const S& s, const std::vector<CTYPE>& e, unsigned int N, const std::string name)

template<class S >
std::string H5::StructSerie< S >::getDescription ( )

Return the description for the dataset.

Returns the value of the string attribute named Description of the dataset.

template<class S >
std::vector< std::string > H5::StructSerie< S >::getMemberLabel ( )

Returns the member labels.

Returns the value of the string vector of all member labels in the dataset.

template<class S >
S H5::StructSerie< S >::getRow ( const int  row)

Returns the data struct at element row.

The first element is 0. The last avaliable element ist getRows()-1.

template<class S >
void H5::StructSerie< S >::open ( const CommonFG &  parent,
const std::string &  name 
)

Open a dataset.

Opens the dataset named name as a child of position parent. NOTE that the object can not be opened before the members of the struct are registered using registerMember(const S& s, const CTYPE& e, const std::string name) or registerMember(const S& s, const std::vector<CTYPE>& e, unsigned int N, const std::string name)

template<class S >
void H5::StructSerie< S >::registerMember ( const S &  s,
const CTYPE &  e,
const std::string  name 
)

Register a scalar member of the struct.

Register a scalar member of type CTYPE of the struct S and set the corrospondending member label to name. The type CTYPE can be one of the types defined in the class description.

Example:

struct S {
  int i;
  std::string s;
  std::vector<double> vd;
}
StructSerie<S> serie;
S s;
serie.registerMember(s, s.i, "Integer Value");
serie.registerMember(s, s.s, "String Value");
serie.registerMember(s, s.vd, 3, "Vector of 3 doubles");
serie.create(parent, "mystructserie");
template<class S >
void H5::StructSerie< S >::registerMember ( const S &  s,
const std::vector< CTYPE > &  e,
unsigned int  N,
const std::string  name 
)

Register a vector member of the struct.

Register a vector member of lenght N of type std::vector<CTYPE> of the struct S and set the corrospondending member label to name. Also see registerMember(const S& s, const CTYPE& e, const std::string name);

template<class S >
void H5::StructSerie< S >::setDescription ( const std::string &  desc)

Sets a description for the dataset.

The value of desc is stored as an string attribute named Description in the dataset.


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