|
class | Utopia::DataIO::HDFAttribute |
| Class for hdf5 attribute, which can be attached to groups and datasets. More...
|
|
class | Utopia::DataIO::HDFBufferFactory |
| Class which turns non-vector or plain-array containers into vectors. If the value_types are containers themselves, these are turned into vectors as well, because HDF5 cannot write something else. More...
|
|
class | Utopia::DataIO::HDFDataset |
| Class representing a HDFDataset, wich reads and writes data and attributes. More...
|
|
class | Utopia::DataIO::HDFDataspace |
| Class that wraps an HDF5 dataspace and takes care of managing its resources. More...
|
|
class | Utopia::DataIO::HDFFile |
| Class representing a HDF5 file. More...
|
|
class | Utopia::DataIO::HDFGroup |
| Class represting a HDFGroup, an object analogous to a folder for HDFFiles. More...
|
|
class | Utopia::DataIO::HDFIdentifier |
| Wrapper class around an hdf5 identifier, used to manage reference counts of the object this identifier refers to. More...
|
|
class | Utopia::DataIO::HDFObject< objectcategory > |
| Common base class for all HDF5 classes in the DATAIO Module i.e., for all classes that wrap HDF5-C-Library functionality like HDFDataset, HDFGroup, HDFFile. This class is not intendet as something to be used independently, but only as a base class to be inherited from. More...
|
|
class | Utopia::DataIO::HDFType |
| Class which handles the conversion of C-types into hdf5types. More...
|
|
|
void | Utopia::DataIO::swap (HDFAttribute &lhs, HDFAttribute &rhs) |
| Swaps the states of Attributes rhs and lhs.
|
|
void | Utopia::DataIO::swap (HDFDataset &lhs, HDFDataset &rhs) |
| Exchange state between lhs and rhs.
|
|
hsize_t | Utopia::DataIO::HDFDataspace::rank () |
| Get thet dataspace's rank, i.e., number of dimensions.
|
|
std::pair< arma::Row< hsize_t >, arma::Row< hsize_t > > | Utopia::DataIO::HDFDataspace::get_properties () |
| Get the properties object: size and capacity.
|
|
arma::Row< hsize_t > | Utopia::DataIO::HDFDataspace::size () |
| Get the current size of the dataspace in each dimension.
|
|
arma::Row< hsize_t > | Utopia::DataIO::HDFDataspace::capacity () |
| Get the capacity of the dataspace in each dimension.
|
|
void | Utopia::DataIO::HDFDataspace::open () |
| Open the dataspace - set it to be equivalent to any data that later will be used to write or read.
|
|
template<typename Object > |
void | Utopia::DataIO::HDFDataspace::open (Object &&object) |
| Open the dataspace with an HDF5 object, i.e., dataset or attribute.
|
|
void | Utopia::DataIO::HDFDataspace::open (std::string name, hsize_t rank, arma::Row< hsize_t > extent, arma::Row< hsize_t > capacity) |
| Open a new dataset of type 'simple', which is equivalent to a N-dimensional array of dimension N = 'rank', a given extent, and a given maximum capacity that in each dimension must be greater or equal to the extent.
|
|
std::pair< arma::Row< hsize_t >, arma::Row< hsize_t > > | Utopia::DataIO::HDFDataspace::get_selection_bounds () |
| Get the selection bounding box, i.e., the start and end vector of the currently selected subset of the dataspace.
|
|
void | Utopia::DataIO::HDFDataspace::select_slice (arma::Row< hsize_t > start, arma::Row< hsize_t > end, arma::Row< hsize_t > stride) |
| Select a slice in the dataspace defined by [start, end, stride] in the manner of numpy. Overwrites old selections.
|
|
void | Utopia::DataIO::HDFDataspace::select_all () |
| Select the entire dataspace as hyperslap to be read/written to.
|
|
void | Utopia::DataIO::HDFDataspace::resize (arma::Row< hsize_t > new_size) |
| Resize the dataspace. The new size needs to fit into the dataspaces capacity.
|
|
void | Utopia::DataIO::HDFDataspace::release_selection () |
| Release a previously defined selection.
|
|
| Utopia::DataIO::HDFDataspace::HDFDataspace () |
| Construct HDFDataspace per default. Equivalent to using H5S_ALL when employing the pure C interface.
|
|
| Utopia::DataIO::HDFDataspace::HDFDataspace (const HDFDataspace &)=default |
| Copy constructor.
|
|
| Utopia::DataIO::HDFDataspace::HDFDataspace (HDFDataspace &&)=default |
| Move constructor.
|
|
HDFDataspace & | Utopia::DataIO::HDFDataspace::operator= (const HDFDataspace &)=default |
| Copy assign dataspace.
|
|
HDFDataspace & | Utopia::DataIO::HDFDataspace::operator= (HDFDataspace &&)=default |
| Move assign dataspace.
|
|
| Utopia::DataIO::HDFDataspace::HDFDataspace (std::string name, hsize_t rank, std::vector< hsize_t > extent, std::vector< hsize_t > capacity) |
| Construct HDFDataspace from the given arguments.
|
|
template<typename Object > |
| Utopia::DataIO::HDFDataspace::HDFDataspace (Object &&object, std::enable_if_t< not std::is_same_v< std::decay_t< Object >, HDFDataspace >, int >=0) |
| Construct a new HDFDataspace object from an HDFDataset or HDFAttribute. This loads the file-dataspace that belongs to the dataset or attribute such that it gets managed by this class.
|
|
virtual | Utopia::DataIO::HDFDataspace::~HDFDataspace ()=default |
| Destroy the HDFDataspace object.
|
|
void | Utopia::DataIO::HDFDataspace::swap (HDFDataspace &other) |
| Swap state with argument.
|
|
void | Utopia::DataIO::swap (HDFDataspace &lhs, HDFDataspace &rhs) |
| Swap states of lhs and rhs.
|
|
void | Utopia::DataIO::swap (HDFGroup &lhs, HDFGroup &rhs) |
| Swap lhs and rhs.
|
|
bool | Utopia::DataIO::operator== (const HDFIdentifier &lhs, const HDFIdentifier &rhs) |
| Comparsion operator for equality.
|
|
bool | Utopia::DataIO::operator!= (const HDFIdentifier &lhs, const HDFIdentifier &rhs) |
| Comparsion operator for inequality.
|
|
void | Utopia::DataIO::swap (HDFIdentifier &lhs, HDFIdentifier &rhs) |
| Exchange the states of lhs and rhs.
|
|
template<HDFCategory cat> |
void | Utopia::DataIO::swap (HDFObject< cat > &lhs, HDFObject< cat > &rhs) |
| Exchange state of lhs and rhs.
|
|
bool | Utopia::DataIO::operator== (const HDFType &lhs, const HDFType &rhs) |
| Check equality of argument typefactories. Two typefactories are considered equal when they refer to the same HDF5 type, e.g., H5T_INTEGER, or H5T_VLEN.
|
|
bool | Utopia::DataIO::operator!= (const HDFType &lhs, const HDFType &rhs) |
| TODO.
|
|
bool | Utopia::DataIO::check_validity (htri_t valid, const std::string_view object_name) |
| Check for validity of a hdf5 htri_t type or similar.
|
|
htri_t | Utopia::DataIO::path_exists (hid_t loc_id, std::string path, hid_t link_property_list=H5P_DEFAULT) |
| Checks iteratively if each segment of a path exists.
|
|
auto | Utopia::DataIO::path_is_valid (hid_t id, std::string path) |
| Check if the path given relative to the object identified by 'id' exists and points to a valid hdf5 object.
|
|
template<HDFCategory category> |
std::string | Utopia::DataIO::category_to_string () |
| Turn category enum into a string that names it.
|
|
template<class Object > |
std::string | Utopia::DataIO::generate_object_name (const Object &object) |
| Use category and path variable of object to make a string that identifies the object it is applied to.
|
|
template<typename Object > |
hid_t | Utopia::DataIO::open_dataspace (Object &&object) |
| Depending on object category, opens a dataset or attribute dataspace.
|
|
template<typename Object > |
hid_t | Utopia::DataIO::open_type (Object &&object) |
| Depending on object category, invokes H5Dget_type or H5Aget_type.
|
|
Low-level interface for using HDF5 with modern C++ and STL.
Overview
This backend is a replacement of the HDF5 C++ wrappers. It does not implement the full HDF5 standard, but only the features we deemed useful and needed for the Utopia project. It was created because the C++ wrappers supplied by the HDF5 group do not support STL containers and in general no modern C++ features. Furthermore, development of the pure C implementation is much faster and it is generally more complete.
Implementation
In this module, C++ classes are created which represent HDF5 files, groups, datasets and attributes, with the associated object creation- and data I/O- capabilities, limited to one and two-dimensional datasets of arrays, containers or scalars. Additionally, helper classes for organizing type mapping and type conversion are supplied, which normally are irelevant for users. Finally a number of helper functions are supplied which are used to assert correctness.
bool Utopia::DataIO::check_validity |
( |
htri_t |
valid, |
|
|
const std::string_view |
object_name |
|
) |
| |
Check for validity of a hdf5 htri_t type or similar.
- Parameters
-
[in] | valid | parameter to check |
[in] | object | name Name of object to be referenced in thrown exceptions if valid <= 0 |
- Returns
- The valid argument for further use
This function is necessary because for instance H5Iis_valid does not return a boolean (non existant in C), but a value which is > 0 if everything is fine, < 0 if some error occurred during checking and 0 if the object to check is invalid. This has to be taken into account in order to be able to track bugs or wrong usage properly. See here:
https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.6/hdf5-1.6.7/src/unpacked/src/H5public.h which yields the following snippet:
Boolean type. Successful return values are zero (false) or positive (true). The typical true value is 1 but don't bet on it. Boolean functions cannot fail. Functions that return ‘htri_t’ however return zero (false), positive (true), or negative (failure). The proper way to test for truth from a htri_t function is:
if ((retval = H5Tcommitted(type))>0) { printf("data type is committed\n"); } else if (!retval) { printf("data type is not committed\n"); } else { printf("error determining whether data type is committed\n"); }
74{
75 if (valid > 0)
76 {
77 return true;
78 }
79
80 else if (valid < 0)
81 {
82 throw std::runtime_error("Object " + std::string(object_name) + ": " +
83 "Error in validity check");
84 return false;
85 }
86 else
87 {
88 return false;
89 }
90}