h5gt 0.2.0
C++ wrapper for HDF5 library (based on HighFive project)
Loading...
Searching...
No Matches
H5Node_traits.hpp
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 h5gt {
18
22template <typename Derivate>
24public:
25
38 createDataSet(const std::string& dataset_name,
39 const DataSpace& space,
40 const DataType& type,
41 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
42 const DataSetCreateProps& dsetCreateProps = DataSetCreateProps(),
43 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps());
44
55 template<typename Type>
57 createDataSet(const std::string& dataset_name,
58 const DataSpace& space,
59 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
60 const DataSetCreateProps& dsetCreateProps = DataSetCreateProps(),
61 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps());
62
73 template <typename T>
75 createDataSet(const std::string& dataset_name,
76 const T& data,
77 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
78 const DataSetCreateProps& dsetCreateProps = DataSetCreateProps(),
79 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps());
80
81
82 template <std::size_t N>
84 createDataSet(const std::string& dataset_name,
85 const FixedLenStringArray<N>& data,
86 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
87 const DataSetCreateProps& dsetCreateProps = DataSetCreateProps(),
88 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps());
89
90 DataType getDataType(
91 const std::string& dtype_name,
92 const DataTypeAccessProps& dtypeAccessProps = DataTypeAccessProps()) const ;
93
100 const std::string& dataset_name,
101 const DataSetAccessProps& accessProps = DataSetAccessProps()) const;
102
110 Group createGroup(const std::string& group_name,
111 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
112 const GroupCreateProps& groupCreateProps = GroupCreateProps(),
113 const GroupAccessProps& groupAccessProps = GroupAccessProps());
114
119 Group getGroup(const std::string& group_name,
120 const GroupAccessProps& groupAccessProps = GroupAccessProps()) const;
121
122 File getFile() const;
123
127 size_t getNumberObjects() const;
128
133 std::string getObjectName(size_t index, const LinkAccessProps& linkAccessProps = LinkAccessProps()) const;
134
135 LinkInfo getLinkInfo(const std::string& objName) const;
136
142 std::string unpackSoftLink(const std::string& objName);
143
150 std::string unpackExternalLink(const std::string& objName, std::string& fileName_out);
151
159 bool rename(const std::string& src_path,
160 const std::string& dest_path,
161 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
162 const LinkAccessProps& linkAccessProps = LinkAccessProps()) const;
163
167 std::vector<std::string> listObjectNames() const;
168
174 bool exist(const std::string& obj_name,
175 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
176 bool raise_errors = false) const;
177
185 bool resolved(const std::string& obj_name,
186 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
187 bool raise_errors = false) const;
188
191 bool existAndResolved(const std::string& obj_name,
192 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
193 bool raise_errors = false) const;
194
195 bool hasObject(const std::string& objName, const ObjectType& objType,
196 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
197 bool raise_errors = false) const;
198
203 void unlink(const std::string& obj_name, const LinkAccessProps& linkAccessProps = LinkAccessProps()) const;
204
209 LinkType getLinkType(const std::string& obj_name,
210 const LinkAccessProps& linkAccessProps = LinkAccessProps()) const;
211
216 inline ObjectType getObjectType(const std::string& obj_name, const LinkAccessProps& accessProps = LinkAccessProps()) const;
217
218
223 Group copy(const Group& obj, const std::string& objNewName,
224 const ObjectCopyProps& copyProps = ObjectCopyProps(),
225 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
226 const GroupAccessProps& groupAccessProps = GroupAccessProps());
227
228 DataSet copy(const DataSet& obj, const std::string& objNewName,
229 const ObjectCopyProps& copyProps = ObjectCopyProps(),
230 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
231 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps());
232
234 DataType copy(const DataType& obj, const std::string& objNewName,
235 const ObjectCopyProps& copyProps = ObjectCopyProps(),
236 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
237 const DataTypeAccessProps& dtypeAccessProps = DataTypeAccessProps());
238
239 template<typename Node,
240 typename std::enable_if<
241 std::is_same<Node, File>::value |
242 std::is_same<Node, Group>::value>::type* = nullptr>
243 Group createLink(
244 const Node& target,
245 const std::string& linkName,
246 const LinkType& linkType,
247 const std::string& targetPath = "",
248 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
249 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
250 const GroupAccessProps& groupAccessProps = GroupAccessProps());
251
252 DataSet createLink(
253 const DataSet& target,
254 const std::string& linkName,
255 const LinkType& linkType,
256 const std::string& targetPath = "",
257 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
258 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
259 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps());
260
261 DataType createLink(
262 const DataType& target,
263 const std::string& linkName,
264 const LinkType& linkType,
265 const std::string& targetPath = "",
266 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
267 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
268 const DataTypeAccessProps& dtypeAccessProps = DataTypeAccessProps());
269
270private:
271 typedef Derivate derivate_type;
272
273 // A wrapper over the low-level H5Lexist
274 // It makes behavior consistent among versions and by default transforms
275 // errors to exceptions
276 bool _exist(const std::string& node_name,
277 const LinkAccessProps& accessProps = LinkAccessProps(),
278 bool raise_errors = false) const;
279
280 bool _resolved(const std::string& node_name,
281 const LinkAccessProps& accessProps = LinkAccessProps(),
282 bool raise_errors = false) const;
283
284 // Opens an arbitrary object to obtain info
285 Object _open(const std::string& node_name,
286 const LinkAccessProps& accessProps = LinkAccessProps()) const;
287
288 template<typename T>
289 void _copy(const T& obj, const std::string& newName,
290 const ObjectCopyProps& copyProps = ObjectCopyProps(),
291 const LinkCreateProps& linkCreateProps = LinkCreateProps());
292
294 template<typename T>
295 void _createLink(
296 T& target,
297 const std::string& linkName,
298 const LinkType& linkType,
299 std::string targetPath = "",
300 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
301 const LinkAccessProps& linkAccessProps = LinkAccessProps());
302};
303
304
305} // namespace h5gt
306
307
308#endif // H5NODE_TRAITS_HPP
Definition H5PropertyList.hpp:255
Definition H5PropertyList.hpp:171
Class representing a dataset.
Definition H5DataSet.hpp:28
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:37
Definition H5PropertyList.hpp:295
HDF5 Data Type.
Definition H5DataType.hpp:48
File class.
Definition H5File.hpp:25
A structure representing a set of fixed-length strings.
Definition H5DataType.hpp:305
Definition H5PropertyList.hpp:162
Definition H5PropertyList.hpp:157
Represents an hdf5 group.
Definition H5Group.hpp:23
NodeTraits: Base class for Group and File.
Definition H5Node_traits.hpp:23
std::string unpackExternalLink(const std::string &objName, std::string &fileName_out)
unpackExternalLink retrieve target path object path and file path
Definition H5Node_traits_misc.hpp:194
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
void unlink(const std::string &obj_name, const LinkAccessProps &linkAccessProps=LinkAccessProps()) const
unlink the given dataset or group
Definition H5Node_traits_misc.hpp:339
std::string getObjectName(size_t index, const LinkAccessProps &linkAccessProps=LinkAccessProps()) const
return the name of the object with the given index
Definition H5Node_traits_misc.hpp:175
size_t getNumberObjects() const
return the number of leaf objects of the node / group
Definition H5Node_traits_misc.hpp:165
ObjectType getObjectType(const std::string &obj_name, const LinkAccessProps &accessProps=LinkAccessProps()) const
A shorthand to get the kind of object pointed to (group, dataset, type...)
Definition H5Node_traits_misc.hpp:362
std::string unpackSoftLink(const std::string &objName)
unpackSoftLink retrieve target path object path
Definition H5Node_traits_misc.hpp:189
bool existAndResolved(const std::string &obj_name, const LinkAccessProps &linkAccessProps=LinkAccessProps(), bool raise_errors=false) const
existAndResolved invokes exist() and then reoslved()
Definition H5Node_traits_misc.hpp:312
bool resolved(const std::string &obj_name, const LinkAccessProps &linkAccessProps=LinkAccessProps(), bool raise_errors=false) const
resolved Hard links always resolved but Soft/External links may point to unexistant objects
Definition H5Node_traits_misc.hpp:298
Group copy(const Group &obj, const std::string &objNewName, const ObjectCopyProps &copyProps=ObjectCopyProps(), const LinkCreateProps &linkCreateProps=LinkCreateProps(), const GroupAccessProps &groupAccessProps=GroupAccessProps())
Copies specified object to the new destination (this File/Group) under new name. The destination must...
Definition H5Node_traits_misc.hpp:368
bool rename(const std::string &src_path, const std::string &dest_path, const LinkCreateProps &linkCreateProps=LinkCreateProps(), const LinkAccessProps &linkAccessProps=LinkAccessProps()) const
moves an object and its content within an HDF5 file.
Definition H5Node_traits_misc.hpp:200
Group getGroup(const std::string &group_name, const GroupAccessProps &groupAccessProps=GroupAccessProps()) const
open an existing group with the name group_name
Definition H5Node_traits_misc.hpp:142
LinkType getLinkType(const std::string &obj_name, const LinkAccessProps &linkAccessProps=LinkAccessProps()) const
Returns the kind of link of the given name (soft, hard...)
Definition H5Node_traits_misc.hpp:349
std::vector< std::string > listObjectNames() const
list all leaf objects name of the node / group
Definition H5Node_traits_misc.hpp:216
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
Group createGroup(const std::string &group_name, const LinkCreateProps &linkCreateProps=LinkCreateProps(), const GroupCreateProps &groupCreateProps=GroupCreateProps(), const GroupAccessProps &groupAccessProps=GroupAccessProps())
create a new group, and eventually intermediate groups
Definition H5Node_traits_misc.hpp:127
Definition H5PropertyList.hpp:305
Definition H5Object.hpp:55