Particle Identification and Tracking
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
utilities::Generic_wrapper_hdf Class Reference

generic_wrapper for writing to hdf files More...

#include <generic_wrapper_hdf.h>

+ Inheritance diagram for utilities::Generic_wrapper_hdf:
+ Collaboration diagram for utilities::Generic_wrapper_hdf:

Public Types

enum  F_TYPE { F_DISK_RDWR = 0, F_DISK_EXCL, F_DISK_TRUNC, F_MEM }
 Enum for determining hdf file creation behavior. More...
 
typedef enum
utilities::Generic_wrapper_hdf::F_TYPE 
F_TYPE
 Enum for determining hdf file creation behavior. More...
 

Public Member Functions

 ~Generic_wrapper_hdf ()
 
 Generic_wrapper_hdf (std::string fname, F_TYPE f_type=F_DISK_RDWR)
 Constructor. More...
 
template<class T >
void get_dset_priv (vector< T > &data, std::vector< unsigned int > &dims, const std::string &dset_name, const DataType &mtype) const
 
Wrapper state

Change and query the top level wrapper state

void open_wrapper ()
 Initializes the wrapper. More...
 
void close_wrapper ()
 closes and cleans up the wrapper More...
 
bool is_open () const
 Returns if the wrapper is open or not. More...
 
Group state

Change and query the wrapper current group state

void open_group (const std::string &name="none")
 Opens a group in the wrapper, ie a group in hdf or a cell in matlab. More...
 
void close_group ()
 closes the current group More...
 
Data

get and set data

void add_dset (int rank, const unsigned int *dims, V_TYPE, const void *, const std::string &name)
 Adds data to the wrapper, must be the right size and type specified. More...
 
void get_dset (std::vector< int > &data, std::vector< unsigned int > &dims, const std::string &dset_name) const
 Gets data from the wrapper. More...
 
void get_dset (std::vector< unsigned int > &data, std::vector< unsigned int > &dims, const std::string &dset_name) const
 Gets data from the wrapper. More...
 
void get_dset (std::vector< float > &data, std::vector< unsigned int > &dims, const std::string &dset_name) const
 Gets data from the wrapper. More...
 
void get_dset_info (std::vector< int > &dims, V_TYPE &vt, const std::string &dset_name) const
 Get dset size. More...
 
Group Level Metadata

getter and setter functions for metadata for the currently open group.

void add_meta_data (const std::string &key, float val)
 Adds a float meta-data. More...
 
void add_meta_data (const std::string &key, const Tuple< float, 3 > &val)
 Adds a Triple meta-data. More...
 
void add_meta_data (const std::string &key, const Tuple< float, 2 > &val)
 Adds a Pair meta-data. More...
 
void add_meta_data (const std::string &key, const std::string &val)
 Adds a string meta-data. More...
 
void add_meta_data (const std::string &key, int val)
 Adds an integer meta-data. More...
 
void add_meta_data (const std::string &key, unsigned int val)
 Adds an unsigned integer meta-data. More...
 
void add_meta_data (const Md_store *md_store)
 Adds all the meta data in a Md_store at the group level. More...
 
float get_meta_data (const std::string &key, float &val)
 Gets a float meta-data. More...
 
Tuple< float, 3 > get_meta_data (const std::string &key, Tuple< float, 3 > &val)
 Gets a Triple meta-data. More...
 
Tuple< float, 2 > get_meta_data (const std::string &key, Tuple< float, 2 > &val)
 Gets a Pair meta-data. More...
 
std::string get_meta_data (const std::string &key, std::string &val)
 Gets a string meta-data. More...
 
int get_meta_data (const std::string &key, int &val)
 Gets an integer meta-data. More...
 
unsigned int get_meta_data (const std::string &key, unsigned int &val)
 Gets an unsigned integer meta-data. More...
 
Md_storeget_meta_data (Md_store &md_store)
 Gets all the meta data in a Md_store at the group level. More...
 
Dataset Level Metadata

getter and setter functions for metadata for the named dataset.

void add_meta_data (const std::string &key, float val, const std::string &dset_name)
 Adds a float meta-data for a data set. More...
 
void add_meta_data (const std::string &key, const Tuple< float, 3 > &val, const std::string &dset_name)
 Adds a Triple meta-data for a data set. More...
 
void add_meta_data (const std::string &key, const Tuple< float, 2 > &val, const std::string &dset_name)
 Adds a Pair meta-data for a data set. More...
 
void add_meta_data (const std::string &key, const std::string &val, const std::string &dset_name)
 Adds a string meta-data for a data set. More...
 
void add_meta_data (const std::string &key, int val, const std::string &dset_name)
 Adds an integer meta-data for a data set. More...
 
void add_meta_data (const std::string &key, unsigned int val, const std::string &dset_name)
 Adds an unsigned integer meta-data for a data set. More...
 
void add_meta_data (const Md_store *md_store, const std::string &dset_name)
 Adds all the meta data in a Md_store at the dset level. More...
 
float get_meta_data (const std::string &key, float &val, const std::string &dset_name)
 Gets a float meta-data for a data set. More...
 
Tuple< float, 3 > get_meta_data (const std::string &key, Tuple< float, 3 > &val, const std::string &dset_name)
 Gets a Triple meta-data for a data set. More...
 
Tuple< float, 2 > get_meta_data (const std::string &key, Tuple< float, 2 > &val, const std::string &dset_name)
 Gets a Pair meta-data for a data set. More...
 
std::string get_meta_data (const std::string &key, std::string &val, const std::string &dset_name)
 Gets a string meta-data for a data set. More...
 
int get_meta_data (const std::string &key, int &val, const std::string &dset_name)
 Gets an integer meta-data for a data set. More...
 
Md_storeget_meta_data (Md_store &md_store, const std::string &dset_name)
 Gets all the meta data in a Md_store at the dset level. More...
 

Private Member Functions

template<class T >
void add_meta_data_priv (const std::string &key, const T &val, const std::string &dset_name)
 Private function to add meta-data to datasets. More...
 
template<class T >
void add_meta_data_priv (const std::string &key, const T &val)
 Private function to add meta-data to the current group. More...
 
template<class T >
get_meta_data_priv (const std::string &key, T &val, const std::string &dset_name)
 Private function to get meta data from datasets. More...
 
template<class T >
get_meta_data_priv (const std::string &key, T &val)
 Private function to get meta data from the current group. More...
 
template<class T >
void get_dset_priv (std::vector< T > &data, std::vector< unsigned int > &dims, const std::string &dset_name, const H5::DataType &mtype) const
 Private function to get dset data out. More...
 

Private Attributes

std::string file_name_
 
bool wrapper_open_
 
bool group_open_
 
bool dset_open_
 
F_TYPE f_type_
 
H5::H5File * file_
 
H5::Group * group_
 
Attr_list_hdfgroup_attrs_
 

Detailed Description

generic_wrapper for writing to hdf files

Member Typedef Documentation

Enum for determining hdf file creation behavior.

Member Enumeration Documentation

Enum for determining hdf file creation behavior.

Enumerator
F_DISK_RDWR 

open existing file read-write

F_DISK_EXCL 

create a new file, must not previously exist

F_DISK_TRUNC 

creates new file, nukes existing file

F_MEM 

create file in memory

Constructor & Destructor Documentation

Generic_wrapper_hdf::~Generic_wrapper_hdf ( )

References close_wrapper(), and wrapper_open_.

Generic_wrapper_hdf::Generic_wrapper_hdf ( std::string  fname,
F_TYPE  f_type = F_DISK_RDWR 
)

Constructor.

Parameters
fnamethe name of the file to write to
add_to_fileif the file already exists
Todo:
replace bool with enum

Member Function Documentation

void Generic_wrapper_hdf::add_dset ( int  rank,
const unsigned int *  dims,
V_TYPE  vt,
const void *  data,
const std::string &  dset_name 
)
virtual

Adds data to the wrapper, must be the right size and type specified.

data will be written safely with in the wrapper during this call so it can be safely freed outside if needed

Parameters
[in]rankrank of data set
[in]dimensionsof data set
[in]vtdata type
[in]datapointer to data to be set
[in]dset_namename of data set
Todo:
add compression logic for higher sizes

Implements utilities::Generic_wrapper.

References CSIZE, file_, group_, group_open_, utilities::V_BOOL, utilities::V_COMPLEX, utilities::V_ERROR, utilities::V_FLOAT, utilities::V_GUID, utilities::V_INT, utilities::V_STRING, utilities::V_TIME, utilities::V_UINT, and wrapper_open_.

Referenced by main().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
float  val 
)
virtual

Adds a float meta-data.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
const Tuple< float, 3 > &  val 
)
virtual

Adds a Triple meta-data.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
const Tuple< float, 2 > &  val 
)
virtual

Adds a Pair meta-data.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
const std::string &  val 
)
virtual

Adds a string meta-data.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
int  val 
)
virtual

Adds an integer meta-data.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
unsigned int  val 
)
virtual

Adds an unsigned integer meta-data.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const Md_store md_store)
virtual
void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
float  val,
const std::string &  dset_name 
)
virtual

Adds a float meta-data for a data set.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
const Tuple< float, 3 > &  val,
const std::string &  dset_name 
)
virtual

Adds a Triple meta-data for a data set.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
const Tuple< float, 2 > &  val,
const std::string &  dset_name 
)
virtual

Adds a Pair meta-data for a data set.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
const std::string &  val,
const std::string &  dset_name 
)
virtual

Adds a string meta-data for a data set.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
int  val,
const std::string &  dset_name 
)
virtual

Adds an integer meta-data for a data set.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const std::string &  key,
unsigned int  val,
const std::string &  dset_name 
)
virtual

Adds an unsigned integer meta-data for a data set.

Implements utilities::Generic_wrapper.

References add_meta_data_priv().

void Generic_wrapper_hdf::add_meta_data ( const Md_store md_store,
const std::string &  dset_name 
)
virtual
template<class T >
void Generic_wrapper_hdf::add_meta_data_priv ( const std::string &  key,
const T &  val,
const std::string &  dset_name 
)
private

Private function to add meta-data to datasets.

References file_, group_, group_open_, and utilities::Attr_list_hdf::set_value().

Referenced by add_meta_data().

template<class T >
void Generic_wrapper_hdf::add_meta_data_priv ( const std::string &  key,
const T &  val 
)
private

Private function to add meta-data to the current group.

References group_attrs_, group_open_, and utilities::Attr_list_hdf::set_value().

void Generic_wrapper_hdf::close_group ( )
virtual

closes the current group

Implements utilities::Generic_wrapper.

References group_, group_attrs_, and group_open_.

Referenced by close_wrapper(), and main().

void Generic_wrapper_hdf::close_wrapper ( )
virtual

closes and cleans up the wrapper

Implements utilities::Generic_wrapper.

References close_group(), file_, group_open_, and wrapper_open_.

Referenced by main(), and ~Generic_wrapper_hdf().

void Generic_wrapper_hdf::get_dset ( std::vector< int > &  data,
std::vector< unsigned int > &  dims,
const std::string &  dset_name 
) const
virtual

Gets data from the wrapper.

Todo:
add compression logic for higher sizes

Implements utilities::Generic_wrapper_read.

References get_dset_priv().

Referenced by main().

void Generic_wrapper_hdf::get_dset ( std::vector< unsigned int > &  data,
std::vector< unsigned int > &  dims,
const std::string &  dset_name 
) const
virtual

Gets data from the wrapper.

Todo:
add compression logic for higher sizes

Implements utilities::Generic_wrapper_read.

References get_dset_priv().

void Generic_wrapper_hdf::get_dset ( std::vector< float > &  data,
std::vector< unsigned int > &  dims,
const std::string &  dset_name 
) const
virtual

Gets data from the wrapper.

Todo:
add compression logic for higher sizes

Implements utilities::Generic_wrapper_read.

References get_dset_priv().

void Generic_wrapper_hdf::get_dset_info ( std::vector< int > &  dims,
V_TYPE vt,
const std::string &  dset_name 
) const
virtual

Get dset size.

Parameters
[out]dimsa vector that gets filled with the dimensions
[out]dimsthe type of the data set
[in]dset_namethe name of the data set
Todo:
add compression logic for higher sizes

Implements utilities::Generic_wrapper_read.

References file_, group_, group_open_, utilities::V_ERROR, utilities::V_FLOAT, utilities::V_INT, utilities::V_UINT, and wrapper_open_.

template<class T >
void utilities::Generic_wrapper_hdf::get_dset_priv ( std::vector< T > &  data,
std::vector< unsigned int > &  dims,
const std::string &  dset_name,
const H5::DataType &  mtype 
) const
private

Private function to get dset data out.

Referenced by get_dset().

template<class T >
void utilities::Generic_wrapper_hdf::get_dset_priv ( vector< T > &  data,
std::vector< unsigned int > &  dims,
const std::string &  dset_name,
const DataType &  mtype 
) const

References file_, group_, group_open_, and wrapper_open_.

float Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
float &  val 
)
virtual

Gets a float meta-data.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

Tuple< float, 3 > Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
Tuple< float, 3 > &  val 
)
virtual

Gets a Triple meta-data.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

Tuple< float, 2 > Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
Tuple< float, 2 > &  val 
)
virtual

Gets a Pair meta-data.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

std::string Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
std::string &  val 
)
virtual

Gets a string meta-data.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

int Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
int &  val 
)
virtual

Gets an integer meta-data.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

unsigned int Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
unsigned int &  val 
)
virtual

Gets an unsigned integer meta-data.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

Md_store & Generic_wrapper_hdf::get_meta_data ( Md_store md_store)
virtual
float Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
float &  val,
const std::string &  dset_name 
)
virtual

Gets a float meta-data for a data set.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

Tuple< float, 3 > Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
Tuple< float, 3 > &  val,
const std::string &  dset_name 
)
virtual

Gets a Triple meta-data for a data set.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

Tuple< float, 2 > Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
Tuple< float, 2 > &  val,
const std::string &  dset_name 
)
virtual

Gets a Pair meta-data for a data set.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

std::string Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
std::string &  val,
const std::string &  dset_name 
)
virtual

Gets a string meta-data for a data set.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

int Generic_wrapper_hdf::get_meta_data ( const std::string &  key,
int &  val,
const std::string &  dset_name 
)
virtual

Gets an integer meta-data for a data set.

Implements utilities::Generic_wrapper_read.

References get_meta_data_priv().

Md_store & Generic_wrapper_hdf::get_meta_data ( Md_store md_store,
const std::string &  dset_name 
)
virtual
template<class T >
T Generic_wrapper_hdf::get_meta_data_priv ( const std::string &  key,
T &  val,
const std::string &  dset_name 
)
private

Private function to get meta data from datasets.

References file_, utilities::Attr_list_hdf::get_value(), group_, and group_open_.

Referenced by get_meta_data().

template<class T >
T Generic_wrapper_hdf::get_meta_data_priv ( const std::string &  key,
T &  val 
)
private

Private function to get meta data from the current group.

References utilities::Attr_list_hdf::get_value(), group_attrs_, and group_open_.

bool utilities::Generic_wrapper_hdf::is_open ( ) const
inlinevirtual

Returns if the wrapper is open or not.

Implements utilities::Generic_wrapper.

References wrapper_open_.

void Generic_wrapper_hdf::open_group ( const std::string &  name = "none")
virtual

Opens a group in the wrapper, ie a group in hdf or a cell in matlab.

Implements utilities::Generic_wrapper.

References file_, group_, group_attrs_, group_open_, and wrapper_open_.

Referenced by main().

void Generic_wrapper_hdf::open_wrapper ( )
virtual

Initializes the wrapper.

Implements utilities::Generic_wrapper.

References F_DISK_EXCL, F_DISK_RDWR, F_DISK_TRUNC, F_MEM, f_type_, file_, file_name_, and wrapper_open_.

Referenced by main().

Member Data Documentation

bool utilities::Generic_wrapper_hdf::dset_open_
private
F_TYPE utilities::Generic_wrapper_hdf::f_type_
private

Referenced by open_wrapper().

H5::H5File* utilities::Generic_wrapper_hdf::file_
private
std::string utilities::Generic_wrapper_hdf::file_name_
private

Referenced by open_wrapper().

H5::Group* utilities::Generic_wrapper_hdf::group_
private
Attr_list_hdf* utilities::Generic_wrapper_hdf::group_attrs_
private
bool utilities::Generic_wrapper_hdf::group_open_
private
bool utilities::Generic_wrapper_hdf::wrapper_open_
private

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