H5Location.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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. #ifndef H5Location_H
  15. #define H5Location_H
  16. #include "H5Classes.h" // contains forward class declarations
  17. namespace H5 {
  18. /*! \class H5Location
  19. \brief H5Location is an abstract base class, added in version 1.8.12.
  20. It provides a collection of wrappers for the C functions that take a
  21. location identifier to specify the HDF5 object. The location identifier
  22. can be either file, group, dataset, attribute, or named datatype.
  23. Wrappers for H5A functions stay in H5Object.
  24. */
  25. // Inheritance: IdComponent
  26. class H5_DLLCPP H5Location : public IdComponent {
  27. public:
  28. // Checks if a link of a given name exists in a location
  29. bool nameExists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  30. bool nameExists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  31. // Checks if a link of a given name exists in a location
  32. // Deprecated in favor of nameExists for better name.
  33. bool exists(const char *name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  34. bool exists(const H5std_string &name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  35. // Flushes all buffers associated with this location to disk.
  36. void flush(H5F_scope_t scope) const;
  37. // Gets the name of the file, specified by this location.
  38. H5std_string getFileName() const;
  39. #ifndef H5_NO_DEPRECATED_SYMBOLS
  40. // Retrieves the type of object that an object reference points to.
  41. H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
  42. #endif /* H5_NO_DEPRECATED_SYMBOLS */
  43. // Retrieves the type of object that an object reference points to.
  44. H5O_type_t getRefObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const;
  45. // Note: getRefObjType deprecates getObjType, but getObjType's name is
  46. // misleading, so getRefObjType is used in the new function instead.
  47. // Sets the comment for an HDF5 object specified by its name.
  48. void setComment(const char *name, const char *comment) const;
  49. void setComment(const H5std_string &name, const H5std_string &comment) const;
  50. void setComment(const char *comment) const;
  51. void setComment(const H5std_string &comment) const;
  52. // Retrieves comment for the HDF5 object specified by its name.
  53. ssize_t getComment(const char *name, size_t buf_size, char *comment) const;
  54. H5std_string getComment(const char *name, size_t buf_size = 0) const;
  55. H5std_string getComment(const H5std_string &name, size_t buf_size = 0) const;
  56. // Removes the comment for the HDF5 object specified by its name.
  57. void removeComment(const char *name) const;
  58. void removeComment(const H5std_string &name) const;
  59. // Creates a reference to a named object or to a dataset region
  60. // in this object.
  61. void reference(void *ref, const char *name, H5R_type_t ref_type = H5R_OBJECT) const;
  62. void reference(void *ref, const H5std_string &name, H5R_type_t ref_type = H5R_OBJECT) const;
  63. void reference(void *ref, const char *name, const DataSpace &dataspace,
  64. H5R_type_t ref_type = H5R_DATASET_REGION) const;
  65. void reference(void *ref, const H5std_string &name, const DataSpace &dataspace,
  66. H5R_type_t ref_type = H5R_DATASET_REGION) const;
  67. // Open a referenced object whose location is specified by either
  68. // a file, an HDF5 object, or an attribute.
  69. void dereference(const H5Location &loc, const void *ref, H5R_type_t ref_type = H5R_OBJECT,
  70. const PropList &plist = PropList::DEFAULT);
  71. // Removed in 1.10.1, because H5Location is baseclass
  72. // void dereference(const Attribute& attr, const void* ref, H5R_type_t ref_type = H5R_OBJECT, const
  73. // PropList& plist = PropList::DEFAULT);
  74. // Retrieves a dataspace with the region pointed to selected.
  75. DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const;
  76. // Create a new group with using link create property list.
  77. Group createGroup(const char *name, const LinkCreatPropList &lcpl) const;
  78. Group createGroup(const H5std_string &name, const LinkCreatPropList &lcpl) const;
  79. // From CommonFG
  80. // Creates a new group at this location which can be a file
  81. // or another group.
  82. Group createGroup(const char *name, size_t size_hint = 0) const;
  83. Group createGroup(const H5std_string &name, size_t size_hint = 0) const;
  84. // Opens an existing group in a location which can be a file
  85. // or another group.
  86. Group openGroup(const char *name) const;
  87. Group openGroup(const H5std_string &name) const;
  88. // Creates a new dataset in this location.
  89. DataSet createDataSet(const char *name, const DataType &data_type, const DataSpace &data_space,
  90. const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT,
  91. const DSetAccPropList & dapl = DSetAccPropList::DEFAULT,
  92. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const;
  93. DataSet createDataSet(const H5std_string &name, const DataType &data_type, const DataSpace &data_space,
  94. const DSetCreatPropList &create_plist = DSetCreatPropList::DEFAULT,
  95. const DSetAccPropList & dapl = DSetAccPropList::DEFAULT,
  96. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT) const;
  97. // Deprecated to add LinkCreatPropList and DSetAccPropList - 1.10.3
  98. // DataSet createDataSet(const char* name, const DataType& data_type, const DataSpace& data_space, const
  99. // DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT) const; DataSet createDataSet(const
  100. // H5std_string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList&
  101. // create_plist = DSetCreatPropList::DEFAULT) const;
  102. // Opens an existing dataset at this location.
  103. // DSetAccPropList is added - 1.10.3
  104. DataSet openDataSet(const char *name, const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const;
  105. DataSet openDataSet(const H5std_string & name,
  106. const DSetAccPropList &dapl = DSetAccPropList::DEFAULT) const;
  107. H5L_info2_t getLinkInfo(const char * link_name,
  108. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  109. H5L_info2_t getLinkInfo(const H5std_string & link_name,
  110. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  111. // Returns the value of a symbolic link.
  112. H5std_string getLinkval(const char *link_name, size_t size = 0) const;
  113. H5std_string getLinkval(const H5std_string &link_name, size_t size = 0) const;
  114. // Returns the number of objects in this group.
  115. // Deprecated - moved to H5::Group in 1.10.2.
  116. hsize_t getNumObjs() const;
  117. // Retrieves the name of an object in this group, given the
  118. // object's index.
  119. H5std_string getObjnameByIdx(hsize_t idx) const;
  120. ssize_t getObjnameByIdx(hsize_t idx, char *name, size_t size) const;
  121. ssize_t getObjnameByIdx(hsize_t idx, H5std_string &name, size_t size) const;
  122. // Retrieves the type of an object in this file or group, given the
  123. // object's name
  124. H5O_type_t childObjType(const H5std_string &objname) const;
  125. H5O_type_t childObjType(const char *objname) const;
  126. H5O_type_t childObjType(hsize_t index, H5_index_t index_type = H5_INDEX_NAME,
  127. H5_iter_order_t order = H5_ITER_INC, const char *objname = ".") const;
  128. // Returns the object header version of an object in this file or group,
  129. // given the object's name.
  130. unsigned childObjVersion(const char *objname) const;
  131. unsigned childObjVersion(const H5std_string &objname) const;
  132. // Retrieves information about an HDF5 object.
  133. void getObjinfo(H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC) const;
  134. // Retrieves information about an HDF5 object, given its name.
  135. void getObjinfo(const char *name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
  136. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  137. void getObjinfo(const H5std_string &name, H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
  138. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  139. // Retrieves information about an HDF5 object, given its index.
  140. void getObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx,
  141. H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
  142. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  143. void getObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx,
  144. H5O_info2_t &objinfo, unsigned fields = H5O_INFO_BASIC,
  145. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  146. // Retrieves native native information about an HDF5 object.
  147. void getNativeObjinfo(H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR) const;
  148. // Retrieves native information about an HDF5 object, given its name.
  149. void getNativeObjinfo(const char *name, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR,
  150. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  151. void getNativeObjinfo(const H5std_string &name, H5O_native_info_t &objinfo,
  152. unsigned fields = H5O_NATIVE_INFO_HDR,
  153. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  154. // Retrieves native information about an HDF5 object, given its index.
  155. void getNativeObjinfo(const char *grp_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx,
  156. H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR,
  157. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  158. void getNativeObjinfo(const H5std_string &grp_name, H5_index_t idx_type, H5_iter_order_t order,
  159. hsize_t idx, H5O_native_info_t &objinfo, unsigned fields = H5O_NATIVE_INFO_HDR,
  160. const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  161. #ifndef H5_NO_DEPRECATED_SYMBOLS
  162. // Returns the type of an object in this group, given the
  163. // object's index.
  164. H5G_obj_t getObjTypeByIdx(hsize_t idx) const;
  165. H5G_obj_t getObjTypeByIdx(hsize_t idx, char *type_name) const;
  166. H5G_obj_t getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const;
  167. // Returns information about an HDF5 object, given by its name,
  168. // at this location. - Deprecated
  169. void getObjinfo(const char *name, hbool_t follow_link, H5G_stat_t &statbuf) const;
  170. void getObjinfo(const H5std_string &name, hbool_t follow_link, H5G_stat_t &statbuf) const;
  171. void getObjinfo(const char *name, H5G_stat_t &statbuf) const;
  172. void getObjinfo(const H5std_string &name, H5G_stat_t &statbuf) const;
  173. // Iterates over the elements of this group - not implemented in
  174. // C++ style yet.
  175. int iterateElems(const char *name, int *idx, H5G_iterate_t op, void *op_data);
  176. int iterateElems(const H5std_string &name, int *idx, H5G_iterate_t op, void *op_data);
  177. #endif /* H5_NO_DEPRECATED_SYMBOLS */
  178. // Creates a soft link from link_name to target_name.
  179. void link(const char *target_name, const char *link_name,
  180. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  181. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  182. void link(const H5std_string &target_name, const H5std_string &link_name,
  183. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  184. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  185. // Creates a hard link from new_name to curr_name.
  186. void link(const char *curr_name, const Group &new_loc, const char *new_name,
  187. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  188. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  189. void link(const H5std_string &curr_name, const Group &new_loc, const H5std_string &new_name,
  190. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  191. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  192. // Creates a hard link from new_name to curr_name in same location.
  193. void link(const char *curr_name, const hid_t same_loc, const char *new_name,
  194. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  195. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  196. void link(const H5std_string &curr_name, const hid_t same_loc, const H5std_string &new_name,
  197. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  198. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  199. // Creates a link of the specified type from new_name to current_name;
  200. // both names are interpreted relative to the specified location id.
  201. // Deprecated due to inadequate functionality.
  202. void link(H5L_type_t link_type, const char *curr_name, const char *new_name) const;
  203. void link(H5L_type_t link_type, const H5std_string &curr_name, const H5std_string &new_name) const;
  204. // Removes the specified link from this location.
  205. void unlink(const char *link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  206. void unlink(const H5std_string &link_name, const LinkAccPropList &lapl = LinkAccPropList::DEFAULT) const;
  207. // Mounts the file 'child' onto this location.
  208. void mount(const char *name, const H5File &child, const PropList &plist) const;
  209. void mount(const H5std_string &name, const H5File &child, const PropList &plist) const;
  210. // Unmounts the file named 'name' from this parent location.
  211. void unmount(const char *name) const;
  212. void unmount(const H5std_string &name) const;
  213. // Copies a link from a group to another.
  214. void copyLink(const char *src_name, const Group &dst, const char *dst_name,
  215. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  216. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  217. void copyLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name,
  218. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  219. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  220. // Makes a copy of a link in the same group.
  221. void copyLink(const char *src_name, const char *dst_name,
  222. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  223. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  224. void copyLink(const H5std_string &src_name, const H5std_string &dst_name,
  225. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  226. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  227. // Renames a link in this group and moves to a new location.
  228. void moveLink(const char *src_name, const Group &dst, const char *dst_name,
  229. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  230. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  231. void moveLink(const H5std_string &src_name, const Group &dst, const H5std_string &dst_name,
  232. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  233. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  234. // Renames a link in this group.
  235. void moveLink(const char *src_name, const char *dst_name,
  236. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  237. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  238. void moveLink(const H5std_string &src_name, const H5std_string &dst_name,
  239. const LinkCreatPropList &lcpl = LinkCreatPropList::DEFAULT,
  240. const LinkAccPropList & lapl = LinkAccPropList::DEFAULT) const;
  241. // Renames an object at this location.
  242. // Deprecated due to inadequate functionality.
  243. void move(const char *src, const char *dst) const;
  244. void move(const H5std_string &src, const H5std_string &dst) const;
  245. // end From CommonFG
  246. /// For subclasses, H5File and Group, to throw appropriate exception.
  247. virtual void throwException(const H5std_string &func_name, const H5std_string &msg) const;
  248. // Default constructor
  249. H5Location();
  250. protected:
  251. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  252. // *** Deprecation warning ***
  253. // The following two constructors are no longer appropriate after the
  254. // data member "id" had been moved to the sub-classes.
  255. // The copy constructor is a noop and is removed in 1.8.15 and the
  256. // other will be removed from 1.10 release, and then from 1.8 if its
  257. // removal does not raise any problems in two 1.10 releases.
  258. // Creates a copy of an existing object giving the location id.
  259. // H5Location(const hid_t loc_id);
  260. // Creates a reference to an HDF5 object or a dataset region.
  261. void p_reference(void *ref, const char *name, hid_t space_id, H5R_type_t ref_type) const;
  262. // Dereferences a ref into an HDF5 id.
  263. hid_t p_dereference(hid_t loc_id, const void *ref, H5R_type_t ref_type, const PropList &plist,
  264. const char *from_func);
  265. #ifndef H5_NO_DEPRECATED_SYMBOLS
  266. // Retrieves the type of object that an object reference points to.
  267. H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const;
  268. #endif /* H5_NO_DEPRECATED_SYMBOLS */
  269. // Retrieves the type of object that an object reference points to.
  270. H5O_type_t p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const;
  271. // Sets the identifier of this object to a new value. - this one
  272. // doesn't increment reference count
  273. // virtual void p_setId(const hid_t new_id);
  274. #endif // DOXYGEN_SHOULD_SKIP_THIS
  275. // Noop destructor.
  276. virtual ~H5Location() override;
  277. }; // end of H5Location
  278. } // namespace H5
  279. #endif // H5Location_H