HDF5 C++ API  1.10.1
 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 // Class forwarding
31 class ArrayType;
32 class LinkAccPropList;
33 class VarLenType;
34 
35 // Inheritance: IdComponent
36 class H5_DLLCPP H5Location : public IdComponent {
37  public:
38  // Checks if a link of a given name exists in a location
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 // From CommonFG
94  // Creates a new group at this location which can be a file
95  // or another group.
96  Group createGroup(const char* name, size_t size_hint = 0) const;
97  Group createGroup(const H5std_string& name, size_t size_hint = 0) const;
98 
99  // Opens an existing group in a location which can be a file
100  // or another group.
101  Group openGroup(const char* name) const;
102  Group openGroup(const H5std_string& name) const;
103 
104  // Creates a new dataset in this group.
105  DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const;
106  DataSet createDataSet(const H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const;
107 
108  // Opens an existing dataset at this location.
109  DataSet openDataSet(const char* name) const;
110  DataSet openDataSet(const H5std_string& name) const;
111 
112  // Returns the value of a symbolic link.
113  H5std_string getLinkval(const char* link_name, size_t size=0) const;
114  H5std_string getLinkval(const H5std_string& link_name, size_t size=0) const;
115 
116  // Determines the number of attributes belong to this object.
117  int getNumAttrs() const;
118 
119  // Retrieves the name of an object in this group, given the
120  // object's index.
121  H5std_string getObjnameByIdx(hsize_t idx) const;
122  ssize_t getObjnameByIdx(hsize_t idx, char* name, size_t size) const;
123  ssize_t getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) const;
124 
125  // Retrieves the type of an object in this file or group, given the
126  // object's name
127  H5O_type_t childObjType(const H5std_string& objname) const;
128  H5O_type_t childObjType(const char* objname) const;
129  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;
130 
131  // Returns the object header version of an object in this file or group,
132  // given the object's name.
133  unsigned childObjVersion(const char* objname) const;
134  unsigned childObjVersion(const H5std_string& objname) const;
135 
136 #ifndef H5_NO_DEPRECATED_SYMBOLS
137  // Returns the type of an object in this group, given the
138  // object's index.
139  H5G_obj_t getObjTypeByIdx(hsize_t idx) const;
140  H5G_obj_t getObjTypeByIdx(hsize_t idx, char* type_name) const;
141  H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const;
142 
143  // Returns information about an HDF5 object, given by its name,
144  // at this location.
145  void getObjinfo(const char* name, hbool_t follow_link, H5G_stat_t& statbuf) const;
146  void getObjinfo(const H5std_string& name, hbool_t follow_link, H5G_stat_t& statbuf) const;
147  void getObjinfo(const char* name, H5G_stat_t& statbuf) const;
148  void getObjinfo(const H5std_string& name, H5G_stat_t& statbuf) const;
149 
150  // Iterates over the elements of this group - not implemented in
151  // C++ style yet.
152  int iterateElems(const char* name, int *idx, H5G_iterate_t op, void *op_data);
153  int iterateElems(const H5std_string& name, int *idx, H5G_iterate_t op, void *op_data);
154 #endif /* H5_NO_DEPRECATED_SYMBOLS */
155 
156  // Creates a link of the specified type from new_name to current_name;
157  // both names are interpreted relative to the specified location id.
158  void link(H5L_type_t link_type, const char* curr_name, const char* new_name) const;
159  void link(H5L_type_t link_type, const H5std_string& curr_name, const H5std_string& new_name) const;
160 
161  // Removes the specified name at this location.
162  void unlink(const char* name) const;
163  void unlink(const H5std_string& name) const;
164 
165  // Mounts the file 'child' onto this location.
166  void mount(const char* name, const H5File& child, const PropList& plist) const;
167  //void mount(const char* name, H5File& child, PropList& plist) const; // removed from 1.8.18 and 1.10.1
168  void mount(const H5std_string& name, const H5File& child, const PropList& plist) const;
169  //void mount(const H5std_string& name, H5File& child, PropList& plist) const; // removed from 1.8.18 and 1.10.1
170 
171  // Unmounts the file named 'name' from this parent location.
172  void unmount(const char* name) const;
173  void unmount(const H5std_string& name) const;
174 
175  // Renames an object at this location.
176  void move(const char* src, const char* dst) const;
177  void move(const H5std_string& src, const H5std_string& dst) const;
178 
179 // end From CommonFG
180 
182  virtual void throwException(const H5std_string& func_name, const H5std_string& msg) const;
183 
184  // Default constructor
185  H5Location();
186 
187  protected:
188 #ifndef DOXYGEN_SHOULD_SKIP_THIS
189  // *** Deprecation warning ***
190  // The following two constructors are no longer appropriate after the
191  // data member "id" had been moved to the sub-classes.
192  // The copy constructor is a noop and is removed in 1.8.15 and the
193  // other will be removed from 1.10 release, and then from 1.8 if its
194  // removal does not raise any problems in two 1.10 releases.
195 
196  // Creates a copy of an existing object giving the location id.
197  H5Location(const hid_t loc_id);
198 
199  // Creates a reference to an HDF5 object or a dataset region.
200  void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const;
201 
202  // Dereferences a ref into an HDF5 id.
203  hid_t p_dereference(hid_t loc_id, const void* ref, H5R_type_t ref_type, const PropList& plist, const char* from_func);
204 
205 #ifndef H5_NO_DEPRECATED_SYMBOLS
206  // Retrieves the type of object that an object reference points to.
207  H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
208 #endif /* H5_NO_DEPRECATED_SYMBOLS */
209 
210  // Retrieves the type of object that an object reference points to.
211  H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
212 
213  // Sets the identifier of this object to a new value. - this one
214  // doesn't increment reference count
215  //virtual void p_setId(const hid_t new_id);
216 
217 #endif // DOXYGEN_SHOULD_SKIP_THIS
218 
219  // Noop destructor.
220  virtual ~H5Location();
221 
222 }; // end of H5Location
223 } // namespace H5
224 
225 #endif // __H5Location_H
Class Group represents an HDF5 group.
Definition: H5Group.h:28
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:24
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:36
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:24
static const DSetCreatPropList & DEFAULT
Default dataset creation property list.
Definition: H5DcreatProp.h:32
static const PropList & DEFAULT
Default property list.
Definition: H5PropList.h:27
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