9#ifndef H5EASY_BITS_SCALAR_HPP
10#define H5EASY_BITS_SCALAR_HPP
12#include "../H5Easy.hpp"
13#include "H5Easy_misc.hpp"
23template <
typename T,
typename =
void>
27 const std::string& path,
30 DataSet dataset = initScalarDataset(file, path, data, options);
32 if (options.
flush()) {
38 inline static T load(
const File& file,
const std::string& path) {
46 const std::string& path,
47 const std::string& key,
50 Attribute attribute = initScalarAttribute(file, path, key, data, options);
51 attribute.
write(data);
52 if (options.
flush()) {
58 inline static T loadAttribute(
const File& file,
59 const std::string& path,
60 const std::string& key) {
69 const std::string& path,
71 const std::vector<size_t>& idx,
73 std::vector<size_t> ones(idx.size(), 1);
75 if (file.
exist(path)) {
78 std::vector<size_t> shape = dims;
79 if (dims.size() != idx.size()) {
80 throw detail::error(file, path,
81 "H5Easy::dump: Dimension of the index and the existing field do not match");
83 for (
size_t i = 0; i < dims.size(); ++i) {
84 shape[i] = std::max(dims[i], idx[i] + 1);
90 if (options.
flush()) {
96 detail::createGroupsToDataSet(file, path);
97 std::vector<size_t> shape = idx;
98 const size_t unlim = DataSpace::UNLIMITED;
99 std::vector<size_t> unlim_shape(idx.size(), unlim);
100 std::vector<hsize_t> chunks(idx.size(), 10);
103 if (chunks.size() != idx.size()) {
104 throw error(file, path,
"H5Easy::dump: Incorrect dimension ChunkSize");
107 for (
size_t& i : shape) {
112 props.setChunk(chunks);
116 if (options.
flush()) {
122 inline static T load_part(
const File& file,
123 const std::string& path,
124 const std::vector<size_t>& idx) {
125 std::vector<size_t> ones(idx.size(), 1);
Options for dumping data.
Definition H5Easy.hpp:112
bool flush() const
Check to flush.
Definition H5Easy_public.hpp:73
bool isChunked() const
Check if chunk-size is manually set (or should be computed automatically).
Definition H5Easy_public.hpp:88
std::vector< hsize_t > getChunkSize() const
Get chunk size.
Definition H5Easy_public.hpp:93
Attribute getAttribute(const std::string &attr_name) const
open an existing attribute with the name attr_name
Definition H5Annotate_traits_misc.hpp:69
create an HDF5 DataType from a C++ type
Definition H5DataType.hpp:124
Class representing an attribute of a dataset or group.
Definition H5Attribute.hpp:22
void write(const T &buffer)
Definition H5Attribute_misc.hpp:113
void read(T &array) const
Definition H5Attribute_misc.hpp:68
Definition H5PropertyList.hpp:171
Class representing a dataset.
Definition H5DataSet.hpp:28
void resize(const std::vector< size_t > &dims)
Change the size of the dataset.
Definition H5DataSet_misc.hpp:128
std::vector< size_t > getDimensions() const
Get the dimensions of the whole DataSet. This is a shorthand for getSpace().getDimensions()
Definition H5DataSet.hpp:104
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:37
File class.
Definition H5File.hpp:25
Definition H5PropertyList.hpp:129
DataSet createDataSet(const std::string &dataset_name, const DataSpace &space, const DataType &type, const LinkCreateProps &linkCreateProps=LinkCreateProps(), const DataSetCreateProps &dsetCreateProps=DataSetCreateProps(), const DataSetAccessProps &dsetAccessProps=DataSetAccessProps())
createDataSet Create a new dataset in the current file of datatype type and of size space
Definition H5Node_traits_misc.hpp:39
DataSet getDataSet(const std::string &dataset_name, const DataSetAccessProps &accessProps=DataSetAccessProps()) const
get an existing dataset in the current file
Definition H5Node_traits_misc.hpp:102
bool exist(const std::string &obj_name, const LinkAccessProps &linkAccessProps=LinkAccessProps(), bool raise_errors=false) const
check a dataset or group exists in the current node / group
Definition H5Node_traits_misc.hpp:284
void flush(bool globalScope=true)
flush
Definition H5Object_misc.hpp:150
void write(const T &buffer)
Definition H5Slice_traits_misc.hpp:275
void read(T &array) const
Definition H5Slice_traits_misc.hpp:224
Selection select(const std::vector< size_t > &offset, const std::vector< size_t > &count, const std::vector< size_t > &stride=std::vector< size_t >(), const std::vector< size_t > &block=std::vector< size_t >()) const
Select a region in the current Slice/Dataset of count points at offset separated by stride....
Definition H5Slice_traits_misc.hpp:76
Definition H5Easy_scalar.hpp:24