gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
hdf5tools.hpp File Reference

A collection of tools for interacting with HDF5 databases. More...

#include <cstdint>
#include <memory>
#include <sstream>
#include <iostream>
#include <algorithm>
#include "gambit/Utils/standalone_error_handlers.hpp"
#include "gambit/Utils/mpiwrapper.hpp"
#include <hdf5.h>
#include <boost/utility/enable_if.hpp>
Include dependency graph for hdf5tools.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Gambit::Printers::get_hdf5_data_type< T, Enable >
 Base template is left undefined in order to raise a compile error if specialisation doesn't exist. More...
 
struct  Gambit::Printers::get_hdf5_data_type< char >
 True types. More...
 
struct  Gambit::Printers::get_hdf5_data_type< short >
 
struct  Gambit::Printers::get_hdf5_data_type< int >
 
struct  Gambit::Printers::get_hdf5_data_type< long >
 
struct  Gambit::Printers::get_hdf5_data_type< long long >
 
struct  Gambit::Printers::get_hdf5_data_type< unsigned char >
 
struct  Gambit::Printers::get_hdf5_data_type< unsigned short >
 
struct  Gambit::Printers::get_hdf5_data_type< unsigned int >
 
struct  Gambit::Printers::get_hdf5_data_type< unsigned long >
 
struct  Gambit::Printers::get_hdf5_data_type< unsigned long long >
 
struct  Gambit::Printers::get_hdf5_data_type< float >
 
struct  Gambit::Printers::get_hdf5_data_type< double >
 
struct  Gambit::Printers::get_hdf5_data_type< long double >
 
struct  Gambit::Printers::get_hdf5_data_type< bool >
 

Namespaces

 Gambit
 TODO: see if we can use this one:
 
 Gambit::Printers
 Forward declaration of Printers::BasePrinter class for use in print functions.
 
 Gambit::Printers::HDF5
 

Macros

#define SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED(TYPEDEFD_TYPE, RETURN_HDF5_TYPE)
 Provide template specialisation of get_hdf5_data_type only if the requested type hasn't been used to define one already. More...
 

Functions

template<class T >
H5T_NATIVE_UINT8 H5T_NATIVE_UINT16 H5T_NATIVE_UINT32 H5T_NATIVE_UINT64 constexpr int Gambit::Printers::h5v2_type ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< int > ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< unsigned int > ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< long > ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< unsigned long > ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< long long > ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< unsigned long long > ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< float > ()
 
template<>
constexpr int Gambit::Printers::h5v2_type< double > ()
 
hid_t Gambit::Printers::HDF5::openFile (const std::string &fname, bool overwrite, bool &oldfile, const char access_type='r')
 File and group manipulation. More...
 
hid_t Gambit::Printers::HDF5::openFile (const std::string &fname, bool overwrite, const char access_type)
 Create or open hdf5 file (ignoring feedback regarding whether file already existed) More...
 
hid_t Gambit::Printers::HDF5::closeFile (hid_t file)
 Close hdf5 file. More...
 
bool Gambit::Printers::HDF5::checkFileReadable (const std::string &fname, std::string &msg)
 Check if hdf5 file exists and can be opened in read/write mode. More...
 
bool Gambit::Printers::HDF5::checkFileReadable (const std::string &fname)
 Thin wrapper for the above to discard failure message. More...
 
bool Gambit::Printers::HDF5::checkGroupReadable (hid_t location, const std::string &groupname, std::string &msg)
 Check if a group exists and can be accessed. More...
 
bool Gambit::Printers::HDF5::checkGroupReadable (hid_t location, const std::string &groupname)
 Thin wrapper for the above to discard failure message. More...
 
std::pair< bool, std::size_t > Gambit::Printers::HDF5::checkDatasetReadable (hid_t location, const std::string &dsetname)
 Check if a dataset exists and can be read from fully (Reads through entire dataset to make sure! May take some time) More...
 
hid_t Gambit::Printers::HDF5::createFile (const std::string &fname)
 Create hdf5 file (always overwrite existing files) More...
 
hid_t Gambit::Printers::HDF5::createGroup (hid_t location, const std::string &name)
 Create a group inside the specified location. More...
 
void Gambit::Printers::HDF5::errorsOff ()
 Silence error report (e.g. while probing for file existence) More...
 
void Gambit::Printers::HDF5::errorsOn ()
 Restore error report. More...
 
hid_t Gambit::Printers::HDF5::openGroup (hid_t file_id, const std::string &name, bool nocreate=false)
 
hid_t Gambit::Printers::HDF5::closeGroup (hid_t group)
 Close group. More...
 
std::vector< std::string > Gambit::Printers::HDF5::lsGroup (hid_t group_id)
 List object names in a group. More...
 
hid_t Gambit::Printers::HDF5::getH5DatasetType (hid_t group_id, const std::string &dset_name)
 Get type of an object in a group. More...
 
hid_t Gambit::Printers::HDF5::closeType (hid_t type_id)
 Release datatype identifier. More...
 
hid_t Gambit::Printers::HDF5::openDataset (hid_t dset_id, const std::string &name, bool error_off=false)
 Dataset and dataspace manipulation. More...
 
hid_t Gambit::Printers::HDF5::closeDataset (hid_t dset_id)
 Close dataset. More...
 
hid_t Gambit::Printers::HDF5::getSpace (hid_t dset_id)
 Get dataspace. More...
 
hid_t Gambit::Printers::HDF5::closeSpace (hid_t space_id)
 Close dataspace. More...
 
hssize_t Gambit::Printers::HDF5::getSimpleExtentNpoints (hid_t dset_id)
 Get simple dataspace extent. More...
 
std::string Gambit::Printers::HDF5::getName (hid_t dset_id)
 Get name of dataset. More...
 
std::pair< hid_t, hid_t > Gambit::Printers::HDF5::selectChunk (const hid_t dset_id, std::size_t offset, std::size_t length)
 Select a simple hyperslab in a 1D dataset. More...
 
bool Gambit::Printers::HDF5::isDataSet (hid_t group_id, const std::string &name)
 Check if an object in a group is a dataset. More...
 
template<class T >
std::vector< T > Gambit::Printers::HDF5::getChunk (const hid_t dset_id, std::size_t offset, std::size_t length)
 Retrieve a chunk of data from a simple dataset NOTE! Doesn't work for T=bool! Have a custom specialisation in the source file for that. More...
 
template<>
std::vector< bool > Gambit::Printers::HDF5::getChunk (const hid_t dset_id, std::size_t offset, std::size_t length)
 
int Gambit::Printers::HDF5::inttype_from_h5type (hid_t h5type)
 
bool Gambit::Printers::HDF5::is_float_type (int inttype)
 
 Gambit::Printers::SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED (int8_t, H5T_NATIVE_INT8) SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED(uint8_t
 Typedef'd types; enabled only where they differ from the true types. More...
 
H5T_NATIVE_UINT8 Gambit::Printers::SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED (int16_t, H5T_NATIVE_INT16) SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED(uint16_t
 
H5T_NATIVE_UINT8 H5T_NATIVE_UINT16 Gambit::Printers::SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED (int32_t, H5T_NATIVE_INT32) SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED(uint32_t
 
H5T_NATIVE_UINT8 H5T_NATIVE_UINT16 H5T_NATIVE_UINT32 Gambit::Printers::SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED (int64_t, H5T_NATIVE_INT64) SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED(uint64_t
 
#define H5_OUTPUT_TYPES
 
void Gambit::Printers::printAllH5Types (void)
 DEBUG: print to stdout all HDF5 type IDs. More...
 

Detailed Description

A collection of tools for interacting with HDF5 databases.

Currently I am using the C++ bindings for HDF5, however they are a bit crap and it may be better to just write our own.


Authors (add name and date if you modify):

Author
Ben Farmer (benja.nosp@m.min..nosp@m.farme.nosp@m.r@fy.nosp@m.sik.s.nosp@m.u.se)
Date
2015 May
Author
Pat Scott (p.sco.nosp@m.tt@i.nosp@m.mperi.nosp@m.al.a.nosp@m.c.uk)
Date
2015 Jul

Definition in file hdf5tools.hpp.

Macro Definition Documentation

◆ H5_OUTPUT_TYPES

#define H5_OUTPUT_TYPES
Value:
(char) \
(short) \
(int) \
(long) \
(long long) \
(unsigned char) \
(unsigned short) \
(unsigned int) \
(unsigned long) \
(unsigned long long) \
(float) \
(double) \
(long double) \
(bool)
DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry DecayTable::Entry double
DS5_MSPCTM DS_INTDOF int

Definition at line 244 of file hdf5tools.hpp.

Referenced by Gambit::Printers::HDF5::checkDatasetReadable(), Gambit::Printers::HDF5Reader::get_type(), Gambit::Printers::HDF5::inttype_from_h5type(), and Gambit::Printers::printAllH5Types().

◆ SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED

#define SPECIALISE_HDF5_DATA_TYPE_IF_NEEDED (   TYPEDEFD_TYPE,
  RETURN_HDF5_TYPE 
)
Value:
template<typename T> \
struct get_hdf5_data_type<T, typename boost::enable_if_c< std::is_same<T, TYPEDEFD_TYPE>::value && \
!std::is_same<char, TYPEDEFD_TYPE>::value && \
!std::is_same<short, TYPEDEFD_TYPE>::value && \
!std::is_same<int, TYPEDEFD_TYPE>::value && \
!std::is_same<long, TYPEDEFD_TYPE>::value && \
!std::is_same<long long, TYPEDEFD_TYPE>::value && \
!std::is_same<unsigned char, TYPEDEFD_TYPE>::value && \
!std::is_same<unsigned short, TYPEDEFD_TYPE>::value && \
!std::is_same<unsigned int, TYPEDEFD_TYPE>::value && \
!std::is_same<unsigned long, TYPEDEFD_TYPE>::value && \
!std::is_same<unsigned long long, TYPEDEFD_TYPE>::value && \
!std::is_same<float, TYPEDEFD_TYPE>::value && \
!std::is_same<double, TYPEDEFD_TYPE>::value && \
!std::is_same<long double, TYPEDEFD_TYPE>::value && \
!std::is_same<bool, TYPEDEFD_TYPE>::value>::type > \
{ \
static hid_t type() { return RETURN_HDF5_TYPE; } \
}; \

Provide template specialisation of get_hdf5_data_type only if the requested type hasn't been used to define one already.

Definition at line 47 of file hdf5tools.hpp.