8 #ifndef UTOPIA_DATAIO_HDFGROUP_HH
9 #define UTOPIA_DATAIO_HDFGROUP_HH
52 template <
typename Attrdata >
66 template < HDFCategory cat >
72 "Opening group with path {} at parent {}", path, parent.
get_path());
83 throw std::runtime_error(
"Group opening for path '" + path +
90 hid_t group_plist = H5Pcreate(H5P_LINK_CREATE);
91 H5Pset_create_intermediate_group(group_plist, 1);
102 H5Pclose(group_plist);
106 throw std::runtime_error(
"Group creation for path '" + path +
119 std::shared_ptr< HDFGroup >
122 return std::make_shared< HDFGroup >(*
this, path);
133 std::shared_ptr< HDFDataset >
135 std::vector< hsize_t > capacity = {},
136 std::vector< hsize_t > chunksizes = {},
137 std::size_t compresslevel = 0)
139 return std::make_shared< HDFDataset >(
140 *
this, path, capacity, chunksizes, compresslevel);
151 this->
_log->debug(
"Deleting group {} in {}", path,
_path);
158 status = H5Ldelete(
get_C_id(), path.c_str(), H5P_DEFAULT);
161 throw std::runtime_error(
"Deletion of group at path '" + path +
162 "' failed! Wrong path?");
211 template < HDFCategory cat >
Class for hdf5 attribute, which can be attached to groups and datasets.
Definition: hdfattribute.hh:46
void write(Type attribute_data, std::vector< hsize_t > shape={})
Function for writing data to the attribute.
Definition: hdfattribute.hh:780
Class represting a HDFGroup, an object analogous to a folder for HDFFiles.
Definition: hdfgroup.hh:41
HDFGroup(const HDFGroup &other)=default
Construct a new HDFGroup object.
void add_attribute(std::string name, Attrdata attribute_data)
write attribute
Definition: hdfgroup.hh:54
HDFGroup()=default
Default constructor.
void open(HDFObject< cat > &parent, std::string path)
Bind the object to a new HDF5 Group, either opening existing or creating a new one at path 'path' in ...
Definition: hdfgroup.hh:68
std::shared_ptr< HDFDataset > open_dataset(std::string path, std::vector< hsize_t > capacity={}, std::vector< hsize_t > chunksizes={}, std::size_t compresslevel=0)
open a HDFDataset
Definition: hdfgroup.hh:134
HDFGroup & operator=(const HDFGroup &other)=default
Copy assignment operator.
void delete_group(std::string path)
Delete the group at the given relative path.
Definition: hdfgroup.hh:149
virtual ~HDFGroup()=default
Destroy the HDFGroup object.
HDFGroup & operator=(HDFGroup &&other)=default
assignment operator
std::shared_ptr< HDFGroup > open_group(std::string path)
Opens a group.
Definition: hdfgroup.hh:120
HDFGroup(HDFGroup &&other)=default
Construct a new HDFGroup object.
HDFGroup(HDFObject< cat > &parent, std::string path)
Construct a new HDFGroup object.
Definition: hdfgroup.hh:212
Common base class for all HDF5 classes in the DATAIO Module i.e., for all classes that wrap HDF5-C-Li...
Definition: hdfobject.hh:37
std::string _path
Name of the object.
Definition: hdfobject.hh:50
std::string get_path() const
Get the name or path object.
Definition: hdfobject.hh:88
virtual bool is_valid() const
Check if the object is still valid.
Definition: hdfobject.hh:143
void swap(HDFObject &other)
swap the state of the caller with the state of the argument
Definition: hdfobject.hh:71
std::shared_ptr< spdlog::logger > _log
pointer to the logger for dataio
Definition: hdfobject.hh:56
hid_t get_C_id() const
Get the C id object.
Definition: hdfobject.hh:120
void bind_to(hid_t id, std::function< herr_t(hid_t) > closing_func, std::string path={})
Open the object and bind it to a HDF5 object identified by 'id' with name 'path'. Object should be cr...
Definition: hdfobject.hh:186
void swap(WriteTask< BGB, DW, DB, AWG, AWD > &lhs, WriteTask< BGB, DW, DB, AWG, AWD > &rhs)
Swaps the state of lhs and rhs.
Definition: write_task.hh:240
auto 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 o...
Definition: hdfutilities.hh:150
This file implements a C++ class which wraps a C HDF5 attribute to a HDF5-object (group or dataset),...
This is the central file of the HDF5 dataIO module of Utopia and provides a class for writing to,...
This file provides metafunctions for automatically determining the nature of a C/C++ types at compile...