H5DataSpace.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 H5DataSpace_H
  15. #define H5DataSpace_H
  16. namespace H5 {
  17. /*! \class DataSpace
  18. \brief Class DataSpace inherits from IdComponent and provides wrappers for
  19. the HDF5's dataspaces.
  20. */
  21. // Inheritance: IdComponent
  22. class H5_DLLCPP DataSpace : public IdComponent {
  23. public:
  24. ///\brief Default DataSpace objects
  25. static const DataSpace &ALL;
  26. // Creates a dataspace object given the space type
  27. DataSpace(H5S_class_t type = H5S_SCALAR);
  28. // Creates a simple dataspace
  29. DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims = NULL);
  30. // Creates a DataSpace object using an existing dataspace id.
  31. DataSpace(const hid_t space_id);
  32. // Copy constructor - same as the original DataSpace.
  33. DataSpace(const DataSpace &original);
  34. // Assignment operator
  35. DataSpace &operator=(const DataSpace &rhs);
  36. // Closes this dataspace.
  37. virtual void close() override;
  38. // Makes copy of an existing dataspace.
  39. void copy(const DataSpace &like_space);
  40. // Copies the extent of this dataspace.
  41. void extentCopy(const DataSpace &dest_space) const;
  42. // removed from 1.8.18 and 1.10.1
  43. // void extentCopy(DataSpace& dest_space) const;
  44. // Gets the bounding box containing the current selection.
  45. void getSelectBounds(hsize_t *start, hsize_t *end) const;
  46. // Gets the number of element points in the current selection.
  47. hssize_t getSelectElemNpoints() const;
  48. // Retrieves the list of element points currently selected.
  49. void getSelectElemPointlist(hsize_t startpoint, hsize_t numpoints, hsize_t *buf) const;
  50. // Gets the list of hyperslab blocks currently selected.
  51. void getSelectHyperBlocklist(hsize_t startblock, hsize_t numblocks, hsize_t *buf) const;
  52. // Get number of hyperslab blocks.
  53. hssize_t getSelectHyperNblocks() const;
  54. // Gets the number of elements in this dataspace selection.
  55. hssize_t getSelectNpoints() const;
  56. // Retrieves dataspace dimension size and maximum size.
  57. int getSimpleExtentDims(hsize_t *dims, hsize_t *maxdims = NULL) const;
  58. // Gets the dimensionality of this dataspace.
  59. int getSimpleExtentNdims() const;
  60. // Gets the number of elements in this dataspace.
  61. // 12/05/00 - changed return type to hssize_t from hsize_t - C API
  62. hssize_t getSimpleExtentNpoints() const;
  63. // Gets the current class of this dataspace.
  64. H5S_class_t getSimpleExtentType() const;
  65. // Determines if this dataspace is a simple one.
  66. bool isSimple() const;
  67. // Sets the offset of this simple dataspace.
  68. void offsetSimple(const hssize_t *offset) const;
  69. // Selects the entire dataspace.
  70. void selectAll() const;
  71. // Selects array elements to be included in the selection for
  72. // this dataspace.
  73. void selectElements(H5S_seloper_t op, const size_t num_elements, const hsize_t *coord) const;
  74. // Selects a hyperslab region to add to the current selected region.
  75. void selectHyperslab(H5S_seloper_t op, const hsize_t *count, const hsize_t *start,
  76. const hsize_t *stride = NULL, const hsize_t *block = NULL) const;
  77. // Resets the selection region to include no elements.
  78. void selectNone() const;
  79. // Verifies that the selection is within the extent of the dataspace.
  80. bool selectValid() const;
  81. // Removes the extent from this dataspace.
  82. void setExtentNone() const;
  83. // Sets or resets the size of this dataspace.
  84. void setExtentSimple(int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL) const;
  85. ///\brief Returns this class name.
  86. virtual H5std_string
  87. fromClass() const override
  88. {
  89. return ("DataSpace");
  90. }
  91. // Gets the dataspace id.
  92. virtual hid_t getId() const override;
  93. // Deletes the global constant
  94. static void deleteConstants();
  95. // Destructor: properly terminates access to this dataspace.
  96. virtual ~DataSpace() override;
  97. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  98. protected:
  99. // Sets the dataspace id.
  100. virtual void p_setId(const hid_t new_id) override;
  101. #endif // DOXYGEN_SHOULD_SKIP_THIS
  102. private:
  103. hid_t id; // HDF5 dataspace id
  104. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  105. static DataSpace *ALL_;
  106. // Creates the global constant
  107. static DataSpace *getConstant();
  108. // Friend function to set DataSpace id. For library use only.
  109. friend void f_DataSpace_setId(DataSpace *dspace, hid_t new_id);
  110. #endif // DOXYGEN_SHOULD_SKIP_THIS
  111. }; // end of DataSpace
  112. } // namespace H5
  113. #endif // H5DataSpace_H