21#include "../H5DataSet.hpp"
22#include "../H5Group.hpp"
23#include "../H5Selection.hpp"
24#include "../H5Utility.hpp"
33template <
typename Derivate>
42 const auto hid = H5Dcreate2(
static_cast<Derivate*
>(
this)->getId(),
51 std::string(
"Unable to create the dataset \"") + dataset_name +
"\":");
56template <
typename Derivate>
58 typename std::enable_if<
59 std::is_same<typename details::inspector<T>::base_type, details::Boolean>::value,
66 return createDataSet(dataset_name,
74template <
typename Derivate>
76 typename std::enable_if<
77 !std::is_same<typename details::inspector<T>::base_type, details::Boolean>::value,
85 dataset_name, space, create_and_check_datatype<T>(), createProps, accessProps, parents);
88template <
typename Derivate>
96 createDataSet(dataset_name,
106template <
typename Derivate>
107template <std::
size_t N>
113 DataSet ds = createDataSet<char[N]>(
119template <
typename Derivate>
122 const auto hid = H5Dopen2(
static_cast<const Derivate*
>(
this)->getId(),
123 dataset_name.c_str(),
124 accessProps.
getId());
127 dataset_name +
"\":");
132template <
typename Derivate>
136 const auto hid = H5Gcreate2(
static_cast<Derivate*
>(
this)->getId(),
145 return detail::make_group(hid);
148template <
typename Derivate>
154 const auto hid = H5Gcreate2(
static_cast<Derivate*
>(
this)->getId(),
163 return detail::make_group(hid);
166template <
typename Derivate>
169 H5Gopen2(
static_cast<const Derivate*
>(
this)->getId(), group_name.c_str(), H5P_DEFAULT);
174 return detail::make_group(hid);
177template <
typename Derivate>
180 if (H5Gget_num_objs(
static_cast<const Derivate*
>(
this)->getId(), &res) < 0) {
182 std::string(
"Unable to count objects in existing group or file"));
184 return static_cast<size_t>(res);
187template <
typename Derivate>
189 return details::get_name([&](
char* buffer,
size_t length) {
190 return H5Lget_name_by_idx(
static_cast<const Derivate*
>(
this)->getId(),
201template <
typename Derivate>
203 const std::string& dst_path,
204 bool parents)
const {
207 herr_t status = H5Lmove(
static_cast<const Derivate*
>(
this)->getId(),
209 static_cast<const Derivate*
>(
this)->getId(),
221template <
typename Derivate>
223 std::vector<std::string> names;
224 details::HighFiveIterateData iterateData(names);
226 size_t num_objs = getNumberObjects();
227 names.reserve(num_objs);
229 if (H5Literate(
static_cast<const Derivate*
>(
this)->getId(),
230 static_cast<H5_index_t
>(idx_type),
233 &details::internal_high_five_iterate<H5L_info_t>,
234 static_cast<void*
>(&iterateData)) < 0) {
241template <
typename Derivate>
245 H5Lexists(
static_cast<const Derivate*
>(
this)->getId(), node_name.c_str(), H5P_DEFAULT);
257 return (node_name ==
"/") ? true : (val > 0);
260template <
typename Derivate>
264 if (group_path.find(
'/') != std::string::npos) {
267 return (group_path ==
"/") ? true : _exist(group_path,
false);
269 return _exist(group_path);
273template <
typename Derivate>
276 H5Ldelete(
static_cast<const Derivate*
>(
this)->getId(), node_name.c_str(), H5P_DEFAULT);
285static inline LinkType _convert_link_type(
const H5L_type_t& ltype)
noexcept {
291 case H5L_TYPE_EXTERNAL:
300template <
typename Derivate>
303 if (H5Lget_info(
static_cast<const Derivate*
>(
this)->getId(),
307 linkinfo.type == H5L_TYPE_ERROR) {
311 return _convert_link_type(linkinfo.type);
314template <
typename Derivate>
316 return _open(node_name).getType();
320template <
typename Derivate>
322 const std::string& obj_path,
325 const bool parents) {
329 auto status = H5Lcreate_soft(obj_path.c_str(),
330 static_cast<const Derivate*
>(
this)->getId(),
332 linkCreateProps.
getId(),
333 linkAccessProps.
getId());
340template <
typename Derivate>
342 const std::string& h5_file,
343 const std::string& obj_path,
346 const bool parents) {
350 auto status = H5Lcreate_external(h5_file.c_str(),
352 static_cast<const Derivate*
>(
this)->getId(),
354 linkCreateProps.
getId(),
355 linkAccessProps.
getId());
362template <
typename Derivate>
365 const auto id = H5Oopen(
static_cast<const Derivate*
>(
this)->getId(),
367 accessProps.
getId());
372 return detail::make_object(
id);
Class representing a dataset.
Definition H5DataSet.hpp:30
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:25
static DataSpace From(const T &value)
Create a dataspace matching a type accepted by details::inspector.
Definition H5Dataspace_misc.hpp:131
HDF5 Data Type.
Definition H5DataType.hpp:54
A structure representing a set of fixed-length strings.
Definition H5DataType.hpp:284
std::size_t size() const noexcept
Definition H5DataType.hpp:326
Represents an hdf5 group.
Definition H5Group.hpp:46
NodeTraits: Base class for Group and File.
Definition H5Node_traits.hpp:28
Group getGroup(const std::string &group_name) const
open an existing group with the name group_name
Definition H5Node_traits_misc.hpp:167
std::vector< std::string > listObjectNames(IndexType idx_type=IndexType::NAME) const
list all leaf objects name of the node / group
Definition H5Node_traits_misc.hpp:222
void unlink(const std::string &node_name) const
unlink the given dataset or group
Definition H5Node_traits_misc.hpp:274
void createExternalLink(const std::string &link_name, const std::string &h5_file, const std::string &obj_path, LinkCreateProps linkCreateProps=LinkCreateProps(), const LinkAccessProps &linkAccessProps=LinkAccessProps(), const bool parents=true)
Definition H5Node_traits_misc.hpp:341
DataSet getDataSet(const std::string &dataset_name, const DataSetAccessProps &accessProps=DataSetAccessProps::Default()) const
get an existing dataset in the current file
Definition H5Node_traits_misc.hpp:120
void createSoftLink(const std::string &linkName, const T &obj)
A shorthand to create softlink to any object which provides getPath The link will be created with def...
Definition H5Node_traits.hpp:185
Group createGroup(const std::string &group_name, bool parents=true)
create a new group, and eventually intermediate groups
Definition H5Node_traits_misc.hpp:133
DataSet createDataSet(const std::string &dataset_name, const DataSpace &space, const DataType &type, const DataSetCreateProps &createProps=DataSetCreateProps::Default(), const DataSetAccessProps &accessProps=DataSetAccessProps::Default(), bool parents=true)
createDataSet Create a new dataset in the current file of datatype type and of size space
Definition H5Node_traits_misc.hpp:34
bool rename(const std::string &src_path, const std::string &dest_path, bool parents=true) const
moves an object and its content within an HDF5 file.
Definition H5Node_traits_misc.hpp:202
bool exist(const std::string &node_name) const
check a dataset or group exists in the current node / group
Definition H5Node_traits_misc.hpp:261
ObjectType getObjectType(const std::string &node_name) const
A shorthand to get the kind of object pointed to (group, dataset, type...)
Definition H5Node_traits_misc.hpp:315
size_t getNumberObjects() const
return the number of leaf objects of the node / group
Definition H5Node_traits_misc.hpp:178
std::string getObjectName(size_t index) const
return the name of the object with the given index
Definition H5Node_traits_misc.hpp:188
LinkType getLinkType(const std::string &node_name) const
Returns the kind of link of the given name (soft, hard...)
Definition H5Node_traits_misc.hpp:301
Definition H5Object.hpp:54
hid_t getId() const noexcept
getId
Definition H5Object_misc.hpp:65
HDF5 property Lists.
Definition H5PropertyList.hpp:79
void add(const P &property)
Definition H5PropertyList_misc.hpp:74
Utility class to disable HDF5 stack printing inside a scope.
Definition H5Utility.hpp:24
void write(const T &buffer, const DataTransferProps &xfer_props=DataTransferProps())
Definition H5Slice_traits_misc.hpp:241
Definition H5_definitions.hpp:15
DataType create_and_check_datatype()
Create a DataType instance representing type T and perform a sanity check on its size.
Definition H5DataType_misc.hpp:479
LinkType
The possible types of group entries (link concept)
Definition H5Node_traits.hpp:228
ObjectType
Enum of the types of objects (H5O api)
Definition H5Object.hpp:24
IndexType
Definition H5Node_traits.hpp:19
static void ToException(const std::string &prefix_msg)
Definition H5Exception_misc.hpp:42