All Classes Namespaces Functions Variables Typedefs Friends Pages
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://support.hdfgroup.org/ftp/HDF5/releases. *
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" // constains 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,
76  H5R_type_t ref_type = H5R_OBJECT) const;
77  void reference(void* ref, const H5std_string& name,
78  H5R_type_t ref_type = H5R_OBJECT) const;
79  void reference(void* ref, const char* name, const DataSpace& dataspace,
80  H5R_type_t ref_type = H5R_DATASET_REGION) const;
81  void reference(void* ref, const H5std_string& name, const DataSpace& dataspace,
82  H5R_type_t ref_type = H5R_DATASET_REGION) const;
83 
84  // Open a referenced object whose location is specified by either
85  // a file, an HDF5 object, or an attribute.
86  void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const PropList& plist = PropList::DEFAULT);
87  // Removed in 1.10.1, because H5Location is baseclass
88  //void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const 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, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const;
110  DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT, const LinkCreatPropList& lcpl = LinkCreatPropList::DEFAULT) const;
111 
112  // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3
113  // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const;
114  // DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const;
115 
116  // Opens an existing dataset at this location.
117  // DSetAccPropList is added - 1.10.3
118  DataSet openDataSet(const char* name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const;
119  DataSet openDataSet(const H5std_string& name, const DSetAccPropList& dapl = DSetAccPropList::DEFAULT) const;
120 
121  H5L_info2_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
122  H5L_info2_t getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
123 
124  // Returns the value of a symbolic link.
125  H5std_string getLinkval(const char* link_name, size_t size=0) const;
126  H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const;
127 
128  // Returns the number of objects in this group.
129  // Deprecated - moved to H5::Group in 1.10.2.
130  hsize_t getNumObjs() const;
131 
132  // Retrieves the name of an object in this group, given the
133  // object's index.
134  H5std_string getObjnameByIdx(hsize_t idx) const;
135  ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const;
136  ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const;
137 
138  // Retrieves the type of an object in this file or group, given the
139  // object's name
140  H5O_type_t childObjType(const H5std_string& objname) const;
141  H5O_type_t childObjType(const char* objname) const;
142  H5O_type_t childObjType(hsize_t index, H5_index_t index_type=H5_INDEX_NAME, H5_iter_order_t order=H5_ITER_INC, const char* objname=".") const;
143 
144  // Returns the object header version of an object in this file or group,
145  // given the object's name.
146  unsigned childObjVersion(const char* objname) const;
147  unsigned childObjVersion(const H5std_string& objname) const;
148 
149  // Retrieves information about an HDF5 object.
150  void getObjinfo(H5O_info2_t& objinfo, unsigned fields = H5O_INFO_BASIC) const;
151 
152  // Retrieves information about an HDF5 object, given its name.
153  void getObjinfo(const char* name, H5O_info2_t& objinfo,
154  unsigned fields = H5O_INFO_BASIC,
155  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
156  void getObjinfo(const H5std_string& name, H5O_info2_t& objinfo,
157  unsigned fields = H5O_INFO_BASIC,
158  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
159 
160  // Retrieves information about an HDF5 object, given its index.
161  void getObjinfo(const char* grp_name, H5_index_t idx_type,
162  H5_iter_order_t order, hsize_t idx, H5O_info2_t& objinfo,
163  unsigned fields = H5O_INFO_BASIC,
164  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
165  void getObjinfo(const H5std_string& grp_name, H5_index_t idx_type,
166  H5_iter_order_t order, hsize_t idx, H5O_info2_t& objinfo,
167  unsigned fields = H5O_INFO_BASIC,
168  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
169 
170  // Retrieves native native information about an HDF5 object.
171  void getNativeObjinfo(H5O_native_info_t& objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const;
172 
173  // Retrieves native information about an HDF5 object, given its name.
174  void getNativeObjinfo(const char* name, H5O_native_info_t& objinfo,
175  unsigned fields = H5O_NATIVE_INFO_HDR,
176  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
177  void getNativeObjinfo(const H5std_string& name, H5O_native_info_t& objinfo,
178  unsigned fields = H5O_NATIVE_INFO_HDR,
179  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
180 
181  // Retrieves native information about an HDF5 object, given its index.
182  void getNativeObjinfo(const char* grp_name, H5_index_t idx_type,
183  H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo,
184  unsigned fields = H5O_NATIVE_INFO_HDR,
185  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
186  void getNativeObjinfo(const H5std_string& grp_name, H5_index_t idx_type,
187  H5_iter_order_t order, hsize_t idx, H5O_native_info_t& objinfo,
188  unsigned fields = H5O_NATIVE_INFO_HDR,
189  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
190 
191 #ifndef H5_NO_DEPRECATED_SYMBOLS
192  // Returns the type of an object in this group, given the
193  // object's index.
194  H5G_obj_t getObjTypeByIdx(hsize_t idx) const;
195  H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const;
196  H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const;
197 
198  // Returns information about an HDF5 object, given by its name,
199  // at this location. - Deprecated
200  void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const;
201  void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const;
202  void getObjinfo(const char* name, H5G_stat_t& statbuf) const;
203  void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const;
204 
205  // Iterates over the elements of this group - not implemented in
206  // C++ style yet.
207  int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data);
208  int iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op, void *op_data);
209 #endif /* H5_NO_DEPRECATED_SYMBOLS */
210 
211  // Creates a soft link from link_name to target_name.
212  void link(const char *target_name, const char *link_name,
214  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
215  void link(const H5std_string& target_name,
216  const H5std_string& link_name,
218  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
219 
220  // Creates a hard link from new_name to curr_name.
221  void link(const char *curr_name,
222  const Group& new_loc, const char *new_name,
224  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
225  void link(const H5std_string& curr_name,
226  const Group& new_loc, const H5std_string& new_name,
228  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
229 
230  // Creates a hard link from new_name to curr_name in same location.
231  void link(const char *curr_name,
232  const hid_t same_loc, const char *new_name,
234  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
235  void link(const H5std_string& curr_name,
236  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,
248  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
249  void unlink(const H5std_string& link_name,
250  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
251 
252  // Mounts the file 'child' onto this location.
253  void mount(const char* name, const H5File& child, const PropList& plist) const;
254  void mount(const H5std_string& name, const H5File& child, const PropList& plist) const;
255 
256  // Unmounts the file named 'name' from this parent location.
257  void unmount(const char* name) const;
258  void unmount(const H5std_string& name) const;
259 
260  // Copies a link from a group to another.
261  void copyLink(const char *src_name,
262  const Group& dst, const char *dst_name,
264  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
265  void copyLink(const H5std_string& src_name,
266  const Group& dst, const H5std_string& dst_name,
268  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
269 
270  // Makes a copy of a link in the same group.
271  void copyLink(const char *src_name, const char *dst_name,
273  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
274  void copyLink(const H5std_string& src_name,
275  const H5std_string& dst_name,
277  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
278 
279  // Renames a link in this group and moves to a new location.
280  void moveLink(const char* src_name,
281  const Group& dst, const char* dst_name,
283  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
284  void moveLink(const H5std_string& src_name,
285  const Group& dst, const H5std_string& dst_name,
287  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
288 
289  // Renames a link in this group.
290  void moveLink(const char* src_name, const char* dst_name,
292  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
293  void moveLink(const H5std_string& src_name,
294  const H5std_string& dst_name,
296  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
297 
298  // Renames an object at this location.
299  // Deprecated due to inadequate functionality.
300  void move(const char* src, const char* dst) const;
301  void move(const H5std_string& src, const H5std_string& dst) const;
302 
303 // end From CommonFG
304 
306  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
307 
308  // Default constructor
309  H5Location();
310 
311  protected:
312 #ifndef DOXYGEN_SHOULD_SKIP_THIS
313  // *** Deprecation warning ***
314  // The following two constructors are no longer appropriate after the
315  // data member "id" had been moved to the sub-classes.
316  // The copy constructor is a noop and is removed in 1.8.15 and the
317  // other will be removed from 1.10 release, and then from 1.8 if its
318  // removal does not raise any problems in two 1.10 releases.
319 
320  // Creates a copy of an existing object giving the location id.
321  // H5Location(const hid_t loc_id);
322 
323  // Creates a reference to an HDF5 object or a dataset region.
324  void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
325 
326  // Dereferences a ref into an HDF5 id.
327  hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func);
328 
329 #ifndef H5_NO_DEPRECATED_SYMBOLS
330  // Retrieves the type of object that an object reference points to.
331  H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
332 #endif /* H5_NO_DEPRECATED_SYMBOLS */
333 
334  // Retrieves the type of object that an object reference points to.
335  H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
336 
337  // Sets the identifier of this object to a new value. - this one
338  // doesn't increment reference count
339  //virtual void p_setId(const hid_t new_id);
340 
341 #endif // DOXYGEN_SHOULD_SKIP_THIS
342 
343  // Noop destructor.
344  virtual ~H5Location();
345 
346 }; // end of H5Location
347 } // namespace H5
348 
349 #endif // __H5Location_H
Class Group represents an HDF5 group.
Definition: H5Group.h:24
Class IdComponent provides wrappers of the C functions that operate on an HDF5 identifier.
Definition: H5IdComponent.h:27
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.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
Class DataType provides generic operations on HDF5 datatypes.
Definition: H5DataType.h:28
H5Location is an abstract base class, added in version 1.8.12.
Definition: H5Location.h:31
Class DataSet operates on HDF5 datasets.
Definition: H5DataSet.h:28
Class PropList inherits from IdComponent and provides wrappers for the HDF5 generic property list...
Definition: H5PropList.h:25
Class DSetAccPropList inherits from LinkAccPropList and provides wrappers for the HDF5 dataset access...
Definition: H5DaccProp.h:25
static const DSetCreatPropList & DEFAULT
Default dataset creation property list.
Definition: H5DcreatProp.h:32
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:28
Class H5File represents an HDF5 file and inherits from class Group as file is a root group...
Definition: H5File.h:25


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