My Project  1.12.2
H5Location.h
1 // C++ informative line for the emacs editor: -*- C++ -*-
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3  * Copyright by The HDF Group. *
4  * Copyright by the Board of Trustees of the University of Illinois. *
5  * All rights reserved. *
6  * *
7  * This file is part of HDF5. The full HDF5 copyright notice, including *
8  * terms governing use, modification, and redistribution, is contained in *
9  * the COPYING file, which can be found at the root of the source code *
10  * distribution tree, or in https://www.hdfgroup.org/licenses. *
11  * If you do not have access to either file, you may request a copy from *
12  * help@hdfgroup.org. *
13  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 #ifndef H5Location_H
16 #define H5Location_H
17 
18 #include "H5Classes.h" // contains forward class declarations
19 
20 namespace H5 {
21 
30 // Inheritance: IdComponent
31 class H5_DLLCPP H5Location : public IdComponent {
32  public:
33  // Checks if a link of a given name exists in a location
34  bool nameExists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
35  bool nameExists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
36 
37  // Checks if a link of a given name exists in a location
38  // Deprecated in favor of nameExists for better name.
39  bool exists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
40  bool exists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
41 
42  // Flushes all buffers associated with this location to disk.
43  void flush(H5F_scope_t scope) const;
44 
45  // Gets the name of the file, specified by this location.
46  H5std_string getFileName() const;
47 
48 #ifndef H5_NO_DEPRECATED_SYMBOLS
49  // Retrieves the type of object that an object reference points to.
50  H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
51 #endif /* H5_NO_DEPRECATED_SYMBOLS */
52 
53  // Retrieves the type of object that an object reference points to.
54  H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
55  // Note: getRefObjType deprecates getObjType, but getObjType's name is
56  // misleading, so getRefObjType is used in the new function instead.
57 
58  // Sets the comment for an HDF5 object specified by its name.
59  void setComment(const char *name, const char *comment) const;
60  void setComment(const H5std_string &name, const H5std_string &comment) const;
61  void setComment(const char *comment) const;
62  void setComment(const H5std_string &comment) const;
63 
64  // Retrieves comment for the HDF5 object specified by its name.
65  ssize_t getComment(const char *name, size_t buf_size, char *comment) const;
66  H5std_string getComment(const char *name, size_t buf_size = 0) const;
67  H5std_string getComment(const H5std_string &name, size_t buf_size = 0) const;
68 
69  // Removes the comment for the HDF5 object specified by its name.
70  void removeComment(const char *name) const;
71  void removeComment(const H5std_string &name) const;
72 
73  // Creates a reference to a named object or to a dataset region
74  // in this object.
75  void reference(void *ref, const char *name, H5R_type_t ref_type = H5R_OBJECT) const;
76  void reference(void *ref, const H5std_string &name, H5R_type_t ref_type = H5R_OBJECT) const;
77  void reference(void *ref, const char *name, const DataSpace &dataspace,
78  H5R_type_t ref_type = H5R_DATASET_REGION) const;
79  void reference(void *ref, const H5std_string &name, const DataSpace &dataspace,
80  H5R_type_t ref_type = H5R_DATASET_REGION) const;
81 
82  // Open a referenced object whose location is specified by either
83  // a file, an HDF5 object, or an attribute.
84  void dereference(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT,
85  const PropList &plist = PropList::DEFAULT);
86  // Removed in 1.10.1, because H5Location is baseclass
87  // void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const
88  // PropList& plist = PropList::DEFAULT);
89 
90  // Retrieves a dataspace with the region pointed to selected.
91  DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
92 
93  // Create a new group with using link create property list.
94  Group createGroup(const char *name, const LinkCreatPropList &lcpl) const;
95  Group createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const;
96 
97  // From CommonFG
98  // Creates a new group at this location which can be a file
99  // or another group.
100  Group createGroup(const char *name, size_t size_hint = 0) const;
101  Group createGroup(const H5std_string &name, size_t size_hint = 0) const;
102 
103  // Opens an existing group in a location which can be a file
104  // or another group.
105  Group openGroup(const char *name) const;
106  Group openGroup(const H5std_string &name) const;
107 
108  // Creates a new dataset in this location.
109  DataSet createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space,
110  const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT,
112  const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const;
113  DataSet createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space,
114  const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT,
116  const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const;
117 
118  // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3
119  // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const
120  // DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; DataSet createDataSet(const
121  // H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList&
122  // create_plist = DSetCreatPropList::DEFAULT) const;
123 
124  // Opens an existing dataset at this location.
125  // DSetAccPropList is added - 1.10.3
126  DataSet openDataSet(const char *name, const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const;
127  DataSet openDataSet(const H5std_string & name,
128  const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const;
129 
130  H5L_info2_t getLinkInfo(const char * link_name,
131  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
132  H5L_info2_t getLinkInfo(const H5std_string & link_name,
133  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
134 
135  // Returns the value of a symbolic link.
136  H5std_string getLinkval(const char *link_name, size_t size = 0) const;
137  H5std_string getLinkval(const H5std_string &link_name, size_t size = 0) const;
138 
139  // Returns the number of objects in this group.
140  // Deprecated - moved to H5::Group in 1.10.2.
141  hsize_t getNumObjs() const;
142 
143  // Retrieves the name of an object in this group, given the
144  // object's index.
145  H5std_string getObjnameByIdx(hsize_t idx) const;
146  ssize_t getObjnameByIdx(hsize_t idx, char *name, size_t size) const;
147  ssize_t getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const;
148 
149  // Retrieves the type of an object in this file or group, given the
150  // object's name
151  H5O_type_t childObjType(const H5std_string &objname) const;
152  H5O_type_t childObjType(const char *objname) const;
153  H5O_type_t childObjType(hsize_t index, H5_index_t index_type = H5_INDEX_NAME,
154  H5_iter_order_t order = H5_ITER_INC, const char *objname = ".") const;
155 
156  // Returns the object header version of an object in this file or group,
157  // given the object's name.
158  unsigned childObjVersion(const char *objname) const;
159  unsigned childObjVersion(const H5std_string &objname) const;
160 
161  // Retrieves information about an HDF5 object.
162  void getObjinfo(H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC) const;
163 
164  // Retrieves information about an HDF5 object, given its name.
165  void getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
166  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
167  void getObjinfo(const H5std_string &name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
168  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
169 
170  // Retrieves information about an HDF5 object, given its index.
171  void getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx,
172  H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
173  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
174  void getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx,
175  H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
176  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
177 
178  // Retrieves native native information about an HDF5 object.
179  void getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const;
180 
181  // Retrieves native information about an HDF5 object, given its name.
182  void getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR,
183  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
184  void getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo,
185  unsigned fields = H5O_NATIVE_INFO_HDR,
186  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
187 
188  // Retrieves native information about an HDF5 object, given its index.
189  void getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx,
190  H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR,
191  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
192  void getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order,
193  hsize_t idx, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR,
194  const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
195 
196 #ifndef H5_NO_DEPRECATED_SYMBOLS
197  // Returns the type of an object in this group, given the
198  // object's index.
199  H5G_obj_t getObjTypeByIdx(hsize_t idx) const;
200  H5G_obj_t getObjTypeByIdx(hsize_t idx, char *type_name) const;
201  H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const;
202 
203  // Returns information about an HDF5 object, given by its name,
204  // at this location. - Deprecated
205  void getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const;
206  void getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const;
207  void getObjinfo(const char *name, H5G_stat_t &statbuf) const;
208  void getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const;
209 
210  // Iterates over the elements of this group - not implemented in
211  // C++ style yet.
212  int iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data);
213  int iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data);
214 #endif /* H5_NO_DEPRECATED_SYMBOLS */
215 
216  // Creates a soft link from link_name to target_name.
217  void link(const char *target_name, const char *link_name,
219  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
220  void link(const H5std_string &target_name, const H5std_string &link_name,
222  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
223 
224  // Creates a hard link from new_name to curr_name.
225  void link(const char *curr_name, const Group &new_loc, const char *new_name,
227  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
228  void link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name,
230  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
231 
232  // Creates a hard link from new_name to curr_name in same location.
233  void link(const char *curr_name, const hid_t same_loc, const char *new_name,
235  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
236  void link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name,
238  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
239 
240  // Creates a link of the specified type from new_name to current_name;
241  // both names are interpreted relative to the specified location id.
242  // Deprecated due to inadequate functionality.
243  void link(H5L_type_t link_type, const char *curr_name, const char *new_name) const;
244  void link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const;
245 
246  // Removes the specified link from this location.
247  void unlink(const char *link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
248  void unlink(const H5std_string &link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
249 
250  // Mounts the file 'child' onto this location.
251  void mount(const char *name, const H5File &child, const PropList &plist) const;
252  void mount(const H5std_string &name, const H5File &child, const PropList &plist) const;
253 
254  // Unmounts the file named 'name' from this parent location.
255  void unmount(const char *name) const;
256  void unmount(const H5std_string &name) const;
257 
258  // Copies a link from a group to another.
259  void copyLink(const char *src_name, const Group &dst, const char *dst_name,
261  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
262  void copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name,
264  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
265 
266  // Makes a copy of a link in the same group.
267  void copyLink(const char *src_name, const char *dst_name,
269  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
270  void copyLink(const H5std_string &src_name, const H5std_string &dst_name,
272  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
273 
274  // Renames a link in this group and moves to a new location.
275  void moveLink(const char *src_name, const Group &dst, const char *dst_name,
277  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
278  void moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name,
280  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
281 
282  // Renames a link in this group.
283  void moveLink(const char *src_name, const char *dst_name,
285  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
286  void moveLink(const H5std_string &src_name, const H5std_string &dst_name,
288  const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
289 
290  // Renames an object at this location.
291  // Deprecated due to inadequate functionality.
292  void move(const char *src, const char *dst) const;
293  void move(const H5std_string &src, const H5std_string &dst) const;
294 
295  // end From CommonFG
296 
298  virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const;
299 
300  // Default constructor
302 
303  protected:
304 #ifndef DOXYGEN_SHOULD_SKIP_THIS
305  // *** Deprecation warning ***
306  // The following two constructors are no longer appropriate after the
307  // data member "id" had been moved to the sub-classes.
308  // The copy constructor is a noop and is removed in 1.8.15 and the
309  // other will be removed from 1.10 release, and then from 1.8 if its
310  // removal does not raise any problems in two 1.10 releases.
311 
312  // Creates a copy of an existing object giving the location id.
313  // H5Location(const hid_t loc_id);
314 
315  // Creates a reference to an HDF5 object or a dataset region.
316  void p_reference(void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const;
317 
318  // Dereferences a ref into an HDF5 id.
319  hid_t p_dereference(hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist,
320  const char *from_func);
321 
322 #ifndef H5_NO_DEPRECATED_SYMBOLS
323  // Retrieves the type of object that an object reference points to.
324  H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
325 #endif /* H5_NO_DEPRECATED_SYMBOLS */
326 
327  // Retrieves the type of object that an object reference points to.
328  H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
329 
330  // Sets the identifier of this object to a new value. - this one
331  // doesn't increment reference count
332  // virtual void p_setId(const hid_t new_id);
333 
334 #endif // DOXYGEN_SHOULD_SKIP_THIS
335 
336  // Noop destructor.
337  virtual ~H5Location() H5_OVERRIDE;
338 
339 }; // end of H5Location
340 } // namespace H5
341 
342 #endif // H5Location_H
Class DSetAccPropList inherits from LinkAccPropList and provides wrappers for the HDF5 dataset access...
Definition: H5DaccProp.h:25
static const DSetAccPropList & DEFAULT
Default dataset creation property list.
Definition: H5DaccProp.h:28
Class DSetCreatPropList inherits from ObjCreatPropList and provides wrappers for the HDF5 dataset cre...
Definition: H5DcreatProp.h:29
static const DSetCreatPropList & DEFAULT
Default dataset creation property list.
Definition: H5DcreatProp.h:32
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
Class Group represents an HDF5 group.
Definition: H5Group.h:24
Class H5File represents an HDF5 file and inherits from class Group as file is a root group.
Definition: H5File.h:25
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:31
Class IdComponent provides wrappers of the C functions that operate on an HDF5 identifier.
Definition: H5IdComponent.h:27
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list.
Definition: H5PropList.h:25
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:28
Definition: H5AbstractDs.cpp:34


The HDF Group Help Desk:
  Copyright by The HDF Group
and the Board of Trustees of the University of Illinois