MISR Toolkit  1.5.1
H5Location.h
Go to the documentation of this file.
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 
22 class H5Location; // forward declaration for UserData4Aiterate
23 
24 // Define the operator function pointer for H5Aiterate().
25 typedef void (*attr_operator_t)(H5Location& loc/*in*/,
26  const H5std_string attr_name/*in*/,
27  void *operator_data/*in,out*/);
28 
29 class UserData4Aiterate { // user data for attribute iteration
30  public:
32  void* opData;
34 };
35 
41 // Inheritance: IdComponent
43  public:
44  // Determines the number of attributes belong to this object.
45  int getNumAttrs() const;
46 
47  // Checks if a link of a given name exists in this location
48  bool nameExists(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
49  bool nameExists(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
50 
51  // Flushes all buffers associated with this location to disk.
52  void flush(H5F_scope_t scope) const;
53 
54  // Gets the name of the file, specified by this location.
55  H5std_string getFileName() const;
56 
57  // Retrieves information about an object at this location
58  // specified by location
59  void getObjectInfo(H5O_info_t *oinfo) const;
60  // specified by the object's name
61  void getObjectInfo(const char *name, H5O_info_t *oinfo,
62  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
63  void getObjectInfo(const H5std_string& name, H5O_info_t *oinfo,
64  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
65 
66 #ifndef H5_NO_DEPRECATED_SYMBOLS
67  // Retrieves the type of object that an object reference points to.
68  H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
69 #endif /* H5_NO_DEPRECATED_SYMBOLS */
70 
71  // Retrieves the type of object that an object reference points to.
72  H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
73  // Note: getRefObjType deprecates getObjType, but getObjType's name is
74  // misleading, so getRefObjType is used in the new function instead.
75 
76  // Returns the object header version of an object
77  unsigned objVersion() const;
78 
79  // Sets the comment for an HDF5 object specified by its name.
80  void setComment(const char* name, const char* comment) const;
81  void setComment(const H5std_string& name, const H5std_string& comment) const;
82  void setComment(const char* comment) const;
83  void setComment(const H5std_string& comment) const;
84 
85  // Retrieves comment for the HDF5 object specified by its name.
86  ssize_t getComment(const char* name, size_t buf_size, char* comment) const;
87  H5std_string getComment(const char* name, size_t buf_size=0) const;
88  H5std_string getComment(const H5std_string& name, size_t buf_size=0) const;
89 
90  // Removes the comment for the HDF5 object specified by its name.
91  void removeComment(const char* name) const;
92  void removeComment(const H5std_string& name) const;
93 
94  // Creates a reference to a named object or to a dataset region
95  // in this object.
96  void reference(void* ref, const char* name,
97  H5R_type_t ref_type = H5R_OBJECT) const;
98  void reference(void* ref, const H5std_string& name,
99  H5R_type_t ref_type = H5R_OBJECT) const;
100  void reference(void* ref, const char* name, const DataSpace& dataspace,
101  H5R_type_t ref_type = H5R_DATASET_REGION) const;
102  void reference(void* ref, const H5std_string& name, const DataSpace& dataspace,
103  H5R_type_t ref_type = H5R_DATASET_REGION) const;
104 
105  // Open a referenced object whose location is specified by either
106  // a file, an HDF5 object, or an attribute.
107  void dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
108  void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT);
109 
110  // Retrieves a dataspace with the region pointed to selected.
111  DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
112 
113  // Opens an object at this location, without knowing the object type.
114  hid_t openObjId(const char* name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
115  hid_t openObjId(const H5std_string& name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
116 
117  // Closes an object opened by openObjId()
118  static void closeObjId(hid_t obj_id);
119 
120  // Creates a soft link from link_name to target_name.
121  void link(const char *target_name, const char *link_name,
123  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
124  void link(const H5std_string& target_name,
125  const H5std_string& link_name,
127  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
128 
129  // Creates a hard link from new_name to curr_name.
130  void link(const char *curr_name,
131  const H5Location& new_loc, const char *new_name,
133  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
134  void link(const H5std_string& curr_name,
135  const H5Location& new_loc, const H5std_string& new_name,
137  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
138 
139  // Creates a hard link from new_name to curr_name in same location.
140  void link(const char *curr_name,
141  const hid_t same_loc, const char *new_name,
143  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
144  void link(const H5std_string& curr_name,
145  const hid_t same_loc, const H5std_string& new_name,
147  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
148 
149  // Removes the specified link from this location.
150  void unlink(const char *link_name,
151  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
152  void unlink(const H5std_string& link_name,
153  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
154 
155  // Copies a link from this location to another.
156  void copyLink(const char *src_name,
157  const H5Location& dst, const char *dst_name,
159  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
160  void copyLink(const H5std_string& src_name,
161  const H5Location& dst, const H5std_string& dst_name,
163  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
164 
165  // Makes a copy of a link in the same location.
166  void copyLink(const char *src_name, const char *dst_name,
168  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
169  void copyLink(const H5std_string& src_name,
170  const H5std_string& dst_name,
172  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
173 
174  // Renames a link in this location and moves to a new location.
175  void moveLink(const char* src_name,
176  const H5Location& dst, const char* dst_name,
178  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
179  void moveLink(const H5std_string& src_name,
180  const H5Location& dst, const H5std_string& dst_name,
182  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
183 
184  // Renames a link in this location.
185  void moveLink(const char* src_name, const char* dst_name,
187  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
188  void moveLink(const H5std_string& src_name,
189  const H5std_string& dst_name,
191  const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
192 
193  // Returns the information of the named link.
194  H5L_info_t getLinkInfo(const char* link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
195  H5L_info_t getLinkInfo(const H5std_string& link_name, const LinkAccPropList& lapl = LinkAccPropList::DEFAULT) const;
196 
197  // Returns the value of a symbolic link.
198  H5std_string getLinkval(const char* link_name, size_t size=0) const;
199  H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const;
200 
202  virtual hid_t getId() const = 0;
203 
204 /***************************************************************************
205  Notes for H5A wrappers
206  ======================
207  These H5A wrappers are marked "deprecated" in 1.8.19.
208  They are moved to H5Object to prevent the object id from being
209  passed in to H5A APIs.
210  Updated: they are removed from source code in 1.8.21.
211 ***************************************************************************/
212 
213  // Creates an attribute for the specified object at this location
214  // PropList is currently not used, so always be default.
215  // Deprecated
216  //virtual Attribute createAttribute(const char* name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
217  //virtual Attribute createAttribute(const H5std_string& name, const DataType& type, const DataSpace& space, const PropList& create_plist = PropList::DEFAULT) const;
218 
219  // Given its name, opens the attribute that belongs to an object at
220  // this location.
221  // Deprecated
222  //virtual Attribute openAttribute(const char* name) const;
223  //virtual Attribute openAttribute(const H5std_string& name) const;
224 
225  // Given its index, opens the attribute that belongs to an object at
226  // this location.
227  //virtual Attribute openAttribute(const unsigned int idx) const; // Deprecated
228 
229  // Iterate user's function over the attributes at this location.
230  virtual int iterateAttrs(attr_operator_t user_op, unsigned* idx = NULL,
231  void* op_data = NULL); // Deprecated
232 
233  // Checks whether the named attribute exists at this location.
234  // Deprecated
235  //virtual bool attrExists(const char* name) const;
236  //virtual bool attrExists(const H5std_string& name) const;
237 
238  // Renames the named attribute to a new name.
239  // Deprecated
240  //virtual void renameAttr(const char* oldname, const char* newname) const;
241  //virtual void renameAttr(const H5std_string& oldname, const H5std_string& newname) const;
242 
243  // Removes the named attribute from this location.
244  // Deprecated
245  //virtual void removeAttr(const char* name) const;
246  //virtual void removeAttr(const H5std_string& name) const;
247 
248 /**************************** End of H5A note *******************************/
249 
250  protected:
251 #ifndef DOXYGEN_SHOULD_SKIP_THIS
252  // Default constructor
253  H5Location();
254 
255  // *** Deprecation warning ***
256  // The following two constructors are no longer appropriate after the
257  // data member "id" had been moved to the sub-classes.
258  // The copy constructor is a noop and is removed in 1.8.15 and the
259  // other will be removed from 1.10 release, and then from 1.8 if its
260  // removal does not raise any problems in two 1.10 releases.
261 
262  // Creates a copy of an existing object giving the location id.
263  H5Location(const hid_t loc_id);
264 
265  // Creates a reference to an HDF5 object or a dataset region.
266  void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
267 
268  // Dereferences a ref into an HDF5 id.
269  hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const char* from_func);
270 
271 #ifndef H5_NO_DEPRECATED_SYMBOLS
272  // Retrieves the type of object that an object reference points to.
273  H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
274 #endif /* H5_NO_DEPRECATED_SYMBOLS */
275 
276  // Retrieves the type of object that an object reference points to.
277  H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
278 
279  // Sets the identifier of this object to a new value. - this one
280  // doesn't increment reference count
281  virtual void p_setId(const hid_t new_id) = 0;
282 
283 #endif // DOXYGEN_SHOULD_SKIP_THIS
284 
285  // Noop destructor.
286  virtual ~H5Location();
287 
288 }; // end of H5Location
289 } // namespace H5
290 
291 #endif // __H5Location_H
292 
293 // Modification
294 // Oct 1, 2013 -BMR
295 // H5Location is added in version 1.8.12.
296 // Most of these methods were in H5Object but are now moved here
297 // because a location can be a file, group, dataset, or named datatype.
298 // May 04, 2017 -BMR
299 // Wrappers for H5A functions are copied to H5Object because H5A
300 // functions do not take an attribute id as loc_id. The original
301 // wrappers will be deprecated in future releases.
#define H5_DLLCPP
Definition: H5api_adpt.h:262
HDFFCLIBAPI intf * idx
Class IdComponent provides wrappers of the C functions that operate on an HDF5 identifier.
Definition: H5IdComponent.h:27
long long ssize_t
Definition: H5public.h:156
Class DataSpace inherits from IdComponent and provides wrappers for the HDF5's dataspaces.
Definition: H5DataSpace.h:25
Class Attribute operates on HDF5 attributes.
Definition: H5Attribute.h:29
H5F_scope_t
Definition: H5Fpublic.h:79
H5Location is an abstract base class, providing a collection of wrappers of the C functions that take...
Definition: H5Location.h:42
H5O_type_t
Definition: H5Opublic.h:81
HDFFCLIBAPI _fcd name
void(* attr_operator_t)(H5Location &loc, const H5std_string attr_name, void *operator_data)
Definition: H5Location.h:25
HDFFCLIBAPI intf intf * ref
#define H5std_string
Definition: H5Exception.h:25
HDFFCLIBAPI intf * size
int hid_t
Definition: H5Ipublic.h:54
H5Location * location
Definition: H5Location.h:33
H5R_type_t
Definition: H5Rpublic.h:28
attr_operator_t op
Definition: H5Location.h:31
H5G_obj_t
Definition: H5Gpublic.h:117

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:52