HighFive 2.3.1
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
H5Node_traits.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
3 *
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 */
9#ifndef H5NODE_TRAITS_HPP
10#define H5NODE_TRAITS_HPP
11
12#include <string>
13
14#include "../H5PropertyList.hpp"
15#include "H5_definitions.hpp"
16
17namespace HighFive {
18
22template <typename Derivate>
24 public:
36 createDataSet(const std::string& dataset_name,
37 const DataSpace& space,
38 const DataType& type,
41 bool parents = true);
42
52 template <typename Type>
54 createDataSet(const std::string& dataset_name,
55 const DataSpace& space,
58 bool parents = true);
59
70 template <typename T>
72 createDataSet(const std::string& dataset_name,
73 const T& data,
76 bool parents = true);
77
78
79 template <std::size_t N>
81 createDataSet(const std::string& dataset_name,
82 const FixedLenStringArray<N>& data,
85 bool parents = true);
86
93 const std::string& dataset_name,
94 const DataSetAccessProps& accessProps = DataSetAccessProps::Default()) const;
95
101 Group createGroup(const std::string& group_name, bool parents = true);
102
107 Group getGroup(const std::string& group_name) const;
108
112 size_t getNumberObjects() const;
113
117 std::string getObjectName(size_t index) const;
118
125 bool rename(const std::string& src_path,
126 const std::string& dest_path,
127 bool parents = true) const;
128
132 std::vector<std::string> listObjectNames() const;
133
138 bool exist(const std::string& node_name) const;
139
143 void unlink(const std::string& node_name) const;
144
148 LinkType getLinkType(const std::string& node_name) const;
149
153 ObjectType getObjectType(const std::string& node_name) const;
154
158 template <typename T, typename = decltype(&T::getPath)>
159 void createSoftLink(const std::string& linkName, const T& obj) {
160 static_assert(!std::is_same<T, Attribute>::value,
161 "hdf5 doesn't support soft links to Attributes");
162 createSoftLink(linkName, obj.getPath());
163 }
164
172 void createSoftLink(const std::string& link_name,
173 const std::string& obj_path,
174 LinkCreateProps linkCreateProps = LinkCreateProps(),
175 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
176 const bool parents = true);
177
178 void createExternalLink(const std::string& link_name,
179 const std::string& h5_file,
180 const std::string& obj_path,
181 LinkCreateProps linkCreateProps = LinkCreateProps(),
182 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
183 const bool parents = true);
184
185 private:
186 typedef Derivate derivate_type;
187
188 // A wrapper over the low-level H5Lexist
189 // It makes behavior consistent among versions and by default transforms
190 // errors to exceptions
191 bool _exist(const std::string& node_name, bool raise_errors = true) const;
192
193 // Opens an arbitrary object to obtain info
194 Object _open(const std::string& node_name,
195 const DataSetAccessProps& accessProps = DataSetAccessProps::Default()) const;
196};
197
198
202enum class LinkType {
203 Hard,
204 Soft,
205 External,
206 Other // Reserved or User-defined
207};
208
209
210} // namespace HighFive
211
212
213#endif // H5NODE_TRAITS_HPP
Class representing a dataset.
Definition H5DataSet.hpp:31
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:37
HDF5 Data Type.
Definition H5DataType.hpp:42
A structure representing a set of fixed-length strings.
Definition H5DataType.hpp:239
Represents an hdf5 group.
Definition H5Group.hpp:25
NodeTraits: Base class for Group and File.
Definition H5Node_traits.hpp:23
Group getGroup(const std::string &group_name) const
open an existing group with the name group_name
Definition H5Node_traits_misc.hpp:127
void unlink(const std::string &node_name) const
unlink the given dataset or group
Definition H5Node_traits_misc.hpp:226
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:294
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:99
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:159
Group createGroup(const std::string &group_name, bool parents=true)
create a new group, and eventually intermediate groups
Definition H5Node_traits_misc.hpp:111
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:36
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:157
bool exist(const std::string &node_name) const
check a dataset or group exists in the current node / group
Definition H5Node_traits_misc.hpp:213
std::vector< std::string > listObjectNames() const
list all leaf objects name of the node / group
Definition H5Node_traits_misc.hpp:173
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:268
size_t getNumberObjects() const
return the number of leaf objects of the node / group
Definition H5Node_traits_misc.hpp:138
std::string getObjectName(size_t index) const
return the name of the object with the given index
Definition H5Node_traits_misc.hpp:148
LinkType getLinkType(const std::string &node_name) const
Returns the kind of link of the given name (soft, hard...)
Definition H5Node_traits_misc.hpp:256
Definition H5Object.hpp:36
HDF5 property Lists.
Definition H5PropertyList.hpp:62
static const PropertyList< T > & Default() noexcept
Return the Default property type object.
Definition H5PropertyList.hpp:81
Definition H5_definitions.hpp:15
PropertyList< PropertyType::LINK_CREATE > LinkCreateProps
Definition H5PropertyList.hpp:103
LinkType
The possible types of group entries (link concept)
Definition H5Node_traits.hpp:202
PropertyList< PropertyType::LINK_ACCESS > LinkAccessProps
Definition H5PropertyList.hpp:104
ObjectType
Enum of the types of objects (H5O api)
Definition H5Object.hpp:25