h5gt 0.2.0
C++ wrapper for HDF5 library (based on HighFive project)
Loading...
Searching...
No Matches
H5NodeTraits_py.h
1#include "h5gt_py.h"
2
3namespace h5gtpy {
4
5namespace ext {
6
7template <typename Derivate>
8DataSet createDataSet_wrap1(
10 const std::string& dset_name,
11 const DataSpace& space,
12 const DataType& type,
13 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
14 const DataSetCreateProps& dsetCreateProps = DataSetCreateProps(),
15 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps()){
16 return self.createDataSet(dset_name, space, type, linkCreateProps, dsetCreateProps, dsetAccessProps);
17}
18
19template <typename Derivate>
20DataSet createDataSet_wrap2(
22 const std::string& dset_name,
23 const std::vector<size_t>& dims,
24 const DataType& type,
25 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
26 const DataSetCreateProps& dsetCreateProps = DataSetCreateProps(),
27 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps()){
28 return self.createDataSet(dset_name, DataSpace(dims), type, linkCreateProps, dsetCreateProps, dsetAccessProps);
29}
30
31template <typename Derivate>
32DataSet createDataSet_wrap3(
34 const std::string& dset_name,
35 const size_t& dim,
36 const DataType& type,
37 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
38 const DataSetCreateProps& dsetCreateProps = DataSetCreateProps(),
39 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps()){
40 return self.createDataSet(dset_name, DataSpace(dim), type, linkCreateProps, dsetCreateProps, dsetAccessProps);
41}
42
43template <typename Derivate>
44Group copy_wrap1(
46 const Group& obj, const std::string& objNewName,
47 const ObjectCopyProps& copyProps = ObjectCopyProps(),
48 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
49 const GroupAccessProps& groupAccessProps = GroupAccessProps()){
50 return self.copy(obj, objNewName, copyProps, linkCreateProps, groupAccessProps);
51}
52
53template <typename Derivate>
54DataSet copy_wrap2(
56 const DataSet& obj, const std::string& objNewName,
57 const ObjectCopyProps& copyProps = ObjectCopyProps(),
58 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
59 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps()){
60 return self.copy(obj, objNewName, copyProps, linkCreateProps, dsetAccessProps);
61}
62
63template <typename Derivate>
64DataType copy_wrap3(
66 const DataType& obj, const std::string& objNewName,
67 const ObjectCopyProps& copyProps = ObjectCopyProps(),
68 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
69 const DataTypeAccessProps& dtypeAccessProps = DataTypeAccessProps()){
70 return self.copy(obj, objNewName, copyProps, linkCreateProps, dtypeAccessProps);
71}
72
73template <typename Derivate>
74DataSet createLink_wrap1(
76 const DataSet& target,
77 const std::string& linkName,
78 const LinkType& linkType,
79 const std::string& targetPath = "",
80 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
81 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
82 const DataSetAccessProps& dsetAccessProps = DataSetAccessProps()){
83 return self.createLink(target, linkName, linkType, targetPath, linkCreateProps, linkAccessProps, dsetAccessProps);
84}
85
86template <typename Derivate>
87DataType createLink_wrap2(
89 const DataType& target,
90 const std::string& linkName,
91 const LinkType& linkType,
92 const std::string& targetPath = "",
93 const LinkCreateProps& linkCreateProps = LinkCreateProps(),
94 const LinkAccessProps& linkAccessProps = LinkAccessProps(),
95 const DataTypeAccessProps& dtypeAccessProps = DataTypeAccessProps()){
96 return self.createLink(target, linkName, linkType, targetPath, linkCreateProps, linkAccessProps, dtypeAccessProps);
97}
98
99template <typename Derivate>
100std::tuple<std::string, std::string> unpackExternalLink(
102 const std::string& objName){
103 std::string fileName_out;
104 std::string objName_out = self.unpackExternalLink(objName, fileName_out);
105 return std::make_tuple(fileName_out, objName_out);
106}
107
108
109} // ext
110
111
112template <typename Derivate>
113void NodeTraits_py(py::class_<NodeTraits<Derivate> >& py_obj) {
114 py_obj
115 .def("createDataSet", &ext::createDataSet_wrap1<Derivate>,
116 py::arg("dset_name"),
117 py::arg("space"),
118 py::arg("type"),
119 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
120 py::arg_v("dsetCreateProps", DataSetCreateProps(), "DataSetCreateProps()"),
121 py::arg_v("dsetAccessProps", DataSetAccessProps(), "DataSetAccessProps()"))
122 .def("createDataSet", &ext::createDataSet_wrap2<Derivate>,
123 py::arg("dset_name"),
124 py::arg("dims"),
125 py::arg("type"),
126 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
127 py::arg_v("dsetCreateProps", DataSetCreateProps(), "DataSetCreateProps()"),
128 py::arg_v("dsetAccessProps", DataSetAccessProps(), "DataSetAccessProps()"))
129 .def("createDataSet", &ext::createDataSet_wrap3<Derivate>,
130 py::arg("dset_name"),
131 py::arg("dim"),
132 py::arg("type"),
133 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
134 py::arg_v("dsetCreateProps", DataSetCreateProps(), "DataSetCreateProps()"),
135 py::arg_v("dsetAccessProps", DataSetAccessProps(), "DataSetAccessProps()"))
136 .def("getDataType", &NodeTraits<Derivate>::getDataType,
137 py::arg("dtype_name"),
138 py::arg_v("dtypeAccessProps", DataTypeAccessProps(), "DataTypeAccessProps()"))
139 .def("getDataSet", &NodeTraits<Derivate>::getDataSet,
140 py::arg("dset_name"),
141 py::arg_v("dsetAccessProps", DataSetAccessProps(), "DataSetAccessProps()"),
142 "Get an existing dataset in the current file")
143 .def("createGroup", &NodeTraits<Derivate>::createGroup,
144 py::arg("group_name"),
145 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
146 py::arg_v("groupCreateProps", GroupCreateProps(), "GroupCreateProps()"),
147 py::arg_v("groupAccessProps", GroupAccessProps(), "GroupAccessProps()"),
148 "Create a new group, and eventually intermediate groups")
149 .def("getGroup", &NodeTraits<Derivate>::getGroup,
150 py::arg("group_name"),
151 py::arg_v("groupAccessProps", GroupAccessProps(), "GroupAccessProps()"),
152 "return the number of leaf objects of the node / group")
153 .def("getFile", &NodeTraits<Derivate>::getFile)
154 .def("getNumberObjects", &NodeTraits<Derivate>::getNumberObjects)
155 .def("getObjectName", &NodeTraits<Derivate>::getObjectName,
156 py::arg("index"),
157 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"))
158 .def("getLinkInfo", &NodeTraits<Derivate>::getLinkInfo,
159 py::arg("objName"))
160 .def("unpackSoftLink", &NodeTraits<Derivate>::unpackSoftLink,
161 py::arg("objName"),
162 "Return target object name")
163 .def("unpackExternalLink", &ext::unpackExternalLink<Derivate>,
164 py::arg("objName"),
165 "Return target file name and object name")
166 .def("rename", &NodeTraits<Derivate>::rename,
167 py::arg("src_path"),
168 py::arg("dest_path"),
169 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
170 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"),
171 "Moves an object and its content within an HDF5 file.")
172 .def("listObjectNames", &NodeTraits<Derivate>::listObjectNames)
173 .def("exist", &NodeTraits<Derivate>::exist,
174 py::arg("obj_name"),
175 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"),
176 py::arg_v("raise_errors", false, "False"),
177 "Check a dataset or group exists in the current node / group")
178 .def("resolved", &NodeTraits<Derivate>::resolved,
179 py::arg("obj_name"),
180 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"),
181 py::arg_v("raise_errors", false, "False"),
182 "Check a dataset or group in the current node / group may be resolved or not")
183 .def("existAndResolved", &NodeTraits<Derivate>::existAndResolved,
184 py::arg("obj_name"),
185 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"),
186 py::arg_v("raise_errors", false, "False"),
187 "Call 'exist()' with subsequent call to 'resolved()' if successful")
188 .def("hasObject", &NodeTraits<Derivate>::hasObject,
189 py::arg("objName"),
190 py::arg("objectType"),
191 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"),
192 py::arg_v("raise_errors", false, "False"),
193 "Advanced version of `exist` that also checks the type of object")
194 .def("unlink", &NodeTraits<Derivate>::unlink,
195 py::arg("obj_name"),
196 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"))
197 .def("getLinkType", &NodeTraits<Derivate>::getLinkType,
198 py::arg("obj_name"),
199 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"),
200 "Unlink the given dataset or group. NOTE: unlink doesn't frees memory. Use `h5repack` to free unused space")
201 .def("getObjectType", &NodeTraits<Derivate>::getObjectType,
202 py::arg("obj_name"),
203 py::arg_v("linkAccessProps", LinkAccessProps(), "LinkAccessProps()"),
204 "A shorthand to get the kind of object pointed to (group, dataset, type...)")
205 .def("copy", &ext::copy_wrap1<Derivate>,
206 py::arg("group"),
207 py::arg("objNewName"),
208 py::arg_v("copyProps", ObjectCopyProps(), "ObjectCopyProps()"),
209 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
210 py::arg_v("groupAccessProps", LinkAccessProps(), "LinkAccessProps()"))
211 .def("copy", &ext::copy_wrap2<Derivate>,
212 py::arg("dset"),
213 py::arg("objNewName"),
214 py::arg_v("copyProps", ObjectCopyProps(), "ObjectCopyProps()"),
215 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
216 py::arg_v("dsetAccessProps", DataSetAccessProps(), "DataSetAccessProps()"))
217 .def("copy", &ext::copy_wrap3<Derivate>,
218 py::arg("dtype"),
219 py::arg("objNewName"),
220 py::arg_v("copyProps", ObjectCopyProps(), "ObjectCopyProps()"),
221 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
222 py::arg_v("dtypeAccessProps", DataTypeAccessProps(), "DataTypeAccessProps()"))
223 .def("createLink", py::overload_cast<
224 const File&,
225 const std::string&,
226 const LinkType&,
227 const std::string&,
228 const LinkCreateProps&,
229 const LinkAccessProps&,
230 const GroupAccessProps&>(&NodeTraits<Derivate>::template createLink<File>),
231 py::arg("file"),// "target object",
232 py::arg("linkName"),// "name for a new link",
233 py::arg("linkType"),
234 py::arg_v("targetPath", std::string(), "str()"),
235 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
236 py::arg_v("linkAccesProps", LinkAccessProps(), "LinkAccessProps()"),
237 py::arg_v("groupAccessProps", GroupAccessProps(), "GroupAccessProps()"),
238 "Creates link to a `File`")
239 .def("createLink", py::overload_cast<
240 const Group&,
241 const std::string&,
242 const LinkType&,
243 const std::string&,
244 const LinkCreateProps&,
245 const LinkAccessProps&,
246 const GroupAccessProps&>(&NodeTraits<Derivate>::template createLink<Group>),
247 py::arg("group"),// "target object",
248 py::arg("linkName"),// "name for a new link",
249 py::arg("linkType"),
250 py::arg_v("targetPath", std::string(), "str()"),
251 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
252 py::arg_v("linkAccesProps", LinkAccessProps(), "LinkAccessProps()"),
253 py::arg_v("groupAccessProps", GroupAccessProps(), "GroupAccessProps()"),
254 "Creates link to a `Group`")
255 .def("createLink", &ext::createLink_wrap1<Derivate>,
256 py::arg("dset"),// "target object",
257 py::arg("linkName"),// "name for a new link",
258 py::arg("linkType"),
259 py::arg_v("targetPath", std::string(), "str()"),
260 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
261 py::arg_v("linkAccesProps", LinkAccessProps(), "LinkAccessProps()"),
262 py::arg_v("dsetAccessProps", DataSetAccessProps(), "DataSetAccessProps()"),
263 "Creates link to a `DataSet`")
264 .def("createLink", &ext::createLink_wrap2<Derivate>,
265 py::arg("dtype"),// "target object",
266 py::arg("linkName"),// "name for a new link",
267 py::arg("linkType"),
268 py::arg_v("targetPath", std::string(), "str()"),
269 py::arg_v("linkCreateProps", LinkCreateProps(), "LinkCreateProps()"),
270 py::arg_v("linkAccesProps", LinkAccessProps(), "LinkAccessProps()"),
271 py::arg_v("dtypeAccessProps", DataTypeAccessProps(), "DataTypeAccessProps()"),
272 "Creates link to a `DataType`");
273}
274
275
276} // h5gtpy
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
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
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
Definition H5PropertyList.hpp:305